diff --git a/sdk/insights/Azure.ResourceManager.Insights/Azure.ResourceManager.Insights.sln b/sdk/insights/Azure.ResourceManager.Insights/Azure.ResourceManager.Insights.sln new file mode 100644 index 000000000000..7f8a76898e3d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/Azure.ResourceManager.Insights.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{777F92EC-C448-487F-8296-282356D9BAF8}") = "Azure.ResourceManager.Insights", "src\Azure.ResourceManager.Insights.csproj", "{A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}" +EndProject +Project("{777F92EC-C448-487F-8296-282356D9BAF8}") = "Azure.ResourceManager.Insights.Tests", "tests\Azure.ResourceManager.Insights.Tests.csproj", "{93133479-68E2-4E4B-9CC7-0FC8CAB16E30}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Debug|x64.ActiveCfg = Debug|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Debug|x64.Build.0 = Debug|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Debug|x86.ActiveCfg = Debug|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Debug|x86.Build.0 = Debug|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Release|Any CPU.Build.0 = Release|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Release|x64.ActiveCfg = Release|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Release|x64.Build.0 = Release|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Release|x86.ActiveCfg = Release|Any CPU + {A8FF99B2-B8CD-4CFF-A9AC-14058FAFBB13}.Release|x86.Build.0 = Release|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Debug|x64.ActiveCfg = Debug|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Debug|x64.Build.0 = Debug|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Debug|x86.ActiveCfg = Debug|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Debug|x86.Build.0 = Debug|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Release|Any CPU.Build.0 = Release|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Release|x64.ActiveCfg = Release|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Release|x64.Build.0 = Release|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Release|x86.ActiveCfg = Release|Any CPU + {93133479-68E2-4E4B-9CC7-0FC8CAB16E30}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/sdk/insights/Azure.ResourceManager.Insights/CHANGELOG.md b/sdk/insights/Azure.ResourceManager.Insights/CHANGELOG.md new file mode 100644 index 000000000000..fb4896e58647 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +- Started changelog to capture release notes. \ No newline at end of file diff --git a/sdk/insights/Azure.ResourceManager.Insights/Directory.Build.props b/sdk/insights/Azure.ResourceManager.Insights/Directory.Build.props new file mode 100644 index 000000000000..1a9611bd4924 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/insights/Azure.ResourceManager.Insights/README.md b/sdk/insights/Azure.ResourceManager.Insights/README.md new file mode 100644 index 000000000000..1dd341e71db9 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/README.md @@ -0,0 +1,96 @@ +# README.md template + +Use the guidelines in each section of this template to ensure consistency and readability of your README. The README resides in your package's GitHub repository at the root of its directory within the repo. It's also used as the package distribution page (NuGet, PyPi, npm, etc.) and as a Quickstart on docs.microsoft.com. See [Azure.Template/README.md](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/template/Azure.Template/README.md) for an example following this template. + +This package follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html) which provide a number of core capabilities that are shared amongst all Azure SDKs, including the intuitive Azure Identity library, an HTTP Pipeline with custom policies, error-handling, distributed tracing, and much more. + +# Azure Management Insights client library for .NET + +**Introduction**: The introduction appears directly under the title (H1) of your README. + +* **DO NOT** use an "Introduction" or "Overview" heading (H2) for this section. +* First sentence: **Describe the service** briefly. You can usually use the first line of the service's docs landing page for this (Example: [Cosmos DB docs landing page](https://docs.microsoft.com/azure/cosmos-db/)). +* Next, add a **bulleted list** of the **most common tasks** supported by the package or library, prefaced with "Use the client library for [Product Name] to:". Then, provide code snippets for these tasks in the [Examples](#examples) section later in the document. Keep the task list short but include those tasks most developers need to perform with your package. +* Include this single line of links targeting your product's content at the bottom of the introduction, making any adjustments as necessary (for example, NuGet instead of PyPi): + + [Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/batch/azure-batch) | [Package (PyPi)](https://pypi.org/project/azure-batch/) | [API reference documentation](https://docs.microsoft.com/python/api/overview/azure/batch?view=azure-python) | [Product documentation](https://docs.microsoft.com/azure/batch/) + +> TIP: Your README should be as **brief** as possible but **no more brief** than necessary to get a developer new to Azure, the service, or the package up and running quickly. Keep it brief, but include everything a developer needs to make their first API call successfully. + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `pip install package-name`, but should enable a developer to successfully install the package from NuGet, pip, npm, Maven, or even cloning a GitHub repository. + +Include a **Prerequisites** line after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +**Prerequisites**: You must have an [Azure subscription](https://azure.microsoft.com/free/), [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API), and [Python 3.6+](https://www.python.org/downloads/) to use this package. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +## Examples + +Include code snippets and short descriptions for each task you listed in the [Introduction](#introduction) (the bulleted list). Briefly explain each operation, but include enough clarity to explain complex or otherwise tricky operations. + +If possible, use the same example snippets that your in-code documentation uses. For example, use the snippets in your `examples.py` that Sphinx ingests via its [literalinclude](https://www.sphinx-doc.org/en/1.5/markup/code.html?highlight=code%20examples#includes) directive. The `examples.py` file containing the snippets should reside alongside your package's code, and should be tested in an automated fashion. + +Each example in the *Examples* section starts with an H3 that describes the example. At the top of this section, just under the *Examples* H2, add a bulleted list linking to each example H3. Each example should deep-link to the types and/or members used in the example. + +* [Create the thing](#create-the-thing) +* [Get the thing](#get-the-thing) +* [List the things](#list-the-things) + +### Create the thing + +Use the `create_thing` method to create a Thing reference; this method does not make a network call. To persist the Thing in the service, call `Thing.save`. + +```Python +thing = client.create_thing(id, name) +thing.save() +``` + +### Get the thing + +The `get_thing` method retrieves a Thing from the service. The `id` parameter is the unique ID of the Thing, not its "name" property. + +```C# Snippet:GetSecret +var client = new MiniSecretClient(new Uri(endpoint), new DefaultAzureCredential()); + +SecretBundle secret = client.GetSecret("TestSecret"); + +Console.WriteLine(secret.Value); +```Python +things = client.list_things() +``` + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net%2Fsdk%2Ftemplate%2FAzure.Template%2FREADME.png) diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Azure.ResourceManager.Insights.csproj b/sdk/insights/Azure.ResourceManager.Insights/src/Azure.ResourceManager.Insights.csproj new file mode 100644 index 000000000000..3c24c5b949ad --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Azure.ResourceManager.Insights.csproj @@ -0,0 +1,13 @@ + + + 1.0.0-preview.1 + Azure.ResourceManager.Insights + Azure Resource Manager client SDK for Azure resource provider Microsoft.Insights + azure;management;arm;resource manager;insights + + + + + $(NoWarn);AZC0001 + + diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActionGroupsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActionGroupsOperations.cs new file mode 100644 index 000000000000..e1bd4a55cf3d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActionGroupsOperations.cs @@ -0,0 +1,338 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The ActionGroups service client. + public partial class ActionGroupsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal ActionGroupsRestOperations RestClient { get; } + /// Initializes a new instance of ActionGroupsOperations for mocking. + protected ActionGroupsOperations() + { + } + /// Initializes a new instance of ActionGroupsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal ActionGroupsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new ActionGroupsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Create a new action group or update an existing one. + /// The name of the resource group. + /// The name of the action group. + /// The action group to create or use for the update. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateAsync(string resourceGroupName, string actionGroupName, ActionGroupResource actionGroup, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateAsync(resourceGroupName, actionGroupName, actionGroup, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create a new action group or update an existing one. + /// The name of the resource group. + /// The name of the action group. + /// The action group to create or use for the update. + /// The cancellation token to use. + public virtual Response CreateOrUpdate(string resourceGroupName, string actionGroupName, ActionGroupResource actionGroup, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return RestClient.CreateOrUpdate(resourceGroupName, actionGroupName, actionGroup, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get an action group. + /// The name of the resource group. + /// The name of the action group. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceGroupName, actionGroupName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get an action group. + /// The name of the resource group. + /// The name of the action group. + /// The cancellation token to use. + public virtual Response Get(string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceGroupName, actionGroupName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete an action group. + /// The name of the resource group. + /// The name of the action group. + /// The cancellation token to use. + public virtual async Task DeleteAsync(string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.Delete"); + scope.Start(); + try + { + return await RestClient.DeleteAsync(resourceGroupName, actionGroupName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete an action group. + /// The name of the resource group. + /// The name of the action group. + /// The cancellation token to use. + public virtual Response Delete(string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.Delete"); + scope.Start(); + try + { + return RestClient.Delete(resourceGroupName, actionGroupName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the action group. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(string resourceGroupName, string actionGroupName, ActionGroupPatchBody actionGroupPatch, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.Update"); + scope.Start(); + try + { + return await RestClient.UpdateAsync(resourceGroupName, actionGroupName, actionGroupPatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the action group. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual Response Update(string resourceGroupName, string actionGroupName, ActionGroupPatchBody actionGroupPatch, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.Update"); + scope.Start(); + try + { + return RestClient.Update(resourceGroupName, actionGroupName, actionGroupPatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. + /// The name of the resource group. + /// The name of the action group. + /// The receiver to re-enable. + /// The cancellation token to use. + public virtual async Task EnableReceiverAsync(string resourceGroupName, string actionGroupName, EnableRequest enableRequest, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.EnableReceiver"); + scope.Start(); + try + { + return await RestClient.EnableReceiverAsync(resourceGroupName, actionGroupName, enableRequest, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. + /// The name of the resource group. + /// The name of the action group. + /// The receiver to re-enable. + /// The cancellation token to use. + public virtual Response EnableReceiver(string resourceGroupName, string actionGroupName, EnableRequest enableRequest, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.EnableReceiver"); + scope.Start(); + try + { + return RestClient.EnableReceiver(resourceGroupName, actionGroupName, enableRequest, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get a list of all action groups in a subscription. + /// The cancellation token to use. + public virtual AsyncPageable ListBySubscriptionIdAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.ListBySubscriptionId"); + scope.Start(); + try + { + var response = await RestClient.ListBySubscriptionIdAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Get a list of all action groups in a subscription. + /// The cancellation token to use. + public virtual Pageable ListBySubscriptionId(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.ListBySubscriptionId"); + scope.Start(); + try + { + var response = RestClient.ListBySubscriptionId(cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + + /// Get a list of all action groups in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Get a list of all action groups in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual Pageable ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActionGroupsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActionGroupsRestOperations.cs new file mode 100644 index 000000000000..7c4cd25cf6aa --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActionGroupsRestOperations.cs @@ -0,0 +1,611 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class ActionGroupsRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of ActionGroupsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public ActionGroupsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string actionGroupName, ActionGroupResource actionGroup) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/actionGroups/", false); + uri.AppendPath(actionGroupName, true); + uri.AppendQuery("api-version", "2019-06-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(actionGroup); + request.Content = content; + return message; + } + + /// Create a new action group or update an existing one. + /// The name of the resource group. + /// The name of the action group. + /// The action group to create or use for the update. + /// The cancellation token to use. + /// , , or is null. + public async Task> CreateOrUpdateAsync(string resourceGroupName, string actionGroupName, ActionGroupResource actionGroup, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + if (actionGroup == null) + { + throw new ArgumentNullException(nameof(actionGroup)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, actionGroupName, actionGroup); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + ActionGroupResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActionGroupResource.DeserializeActionGroupResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Create a new action group or update an existing one. + /// The name of the resource group. + /// The name of the action group. + /// The action group to create or use for the update. + /// The cancellation token to use. + /// , , or is null. + public Response CreateOrUpdate(string resourceGroupName, string actionGroupName, ActionGroupResource actionGroup, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + if (actionGroup == null) + { + throw new ArgumentNullException(nameof(actionGroup)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, actionGroupName, actionGroup); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + ActionGroupResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActionGroupResource.DeserializeActionGroupResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string resourceGroupName, string actionGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/actionGroups/", false); + uri.AppendPath(actionGroupName, true); + uri.AppendQuery("api-version", "2019-06-01", true); + request.Uri = uri; + return message; + } + + /// Get an action group. + /// The name of the resource group. + /// The name of the action group. + /// The cancellation token to use. + /// or is null. + public async Task> GetAsync(string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + + using var message = CreateGetRequest(resourceGroupName, actionGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ActionGroupResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActionGroupResource.DeserializeActionGroupResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get an action group. + /// The name of the resource group. + /// The name of the action group. + /// The cancellation token to use. + /// or is null. + public Response Get(string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + + using var message = CreateGetRequest(resourceGroupName, actionGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ActionGroupResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActionGroupResource.DeserializeActionGroupResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string resourceGroupName, string actionGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/actionGroups/", false); + uri.AppendPath(actionGroupName, true); + uri.AppendQuery("api-version", "2019-06-01", true); + request.Uri = uri; + return message; + } + + /// Delete an action group. + /// The name of the resource group. + /// The name of the action group. + /// The cancellation token to use. + /// or is null. + public async Task DeleteAsync(string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, actionGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Delete an action group. + /// The name of the resource group. + /// The name of the action group. + /// The cancellation token to use. + /// or is null. + public Response Delete(string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, actionGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string resourceGroupName, string actionGroupName, ActionGroupPatchBody actionGroupPatch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/actionGroups/", false); + uri.AppendPath(actionGroupName, true); + uri.AppendQuery("api-version", "2019-06-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(actionGroupPatch); + request.Content = content; + return message; + } + + /// Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the action group. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public async Task> UpdateAsync(string resourceGroupName, string actionGroupName, ActionGroupPatchBody actionGroupPatch, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + if (actionGroupPatch == null) + { + throw new ArgumentNullException(nameof(actionGroupPatch)); + } + + using var message = CreateUpdateRequest(resourceGroupName, actionGroupName, actionGroupPatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ActionGroupResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActionGroupResource.DeserializeActionGroupResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the action group. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public Response Update(string resourceGroupName, string actionGroupName, ActionGroupPatchBody actionGroupPatch, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + if (actionGroupPatch == null) + { + throw new ArgumentNullException(nameof(actionGroupPatch)); + } + + using var message = CreateUpdateRequest(resourceGroupName, actionGroupName, actionGroupPatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ActionGroupResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActionGroupResource.DeserializeActionGroupResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionIdRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/actionGroups", false); + uri.AppendQuery("api-version", "2019-06-01", true); + request.Uri = uri; + return message; + } + + /// Get a list of all action groups in a subscription. + /// The cancellation token to use. + public async Task> ListBySubscriptionIdAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionIdRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ActionGroupList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActionGroupList.DeserializeActionGroupList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get a list of all action groups in a subscription. + /// The cancellation token to use. + public Response ListBySubscriptionId(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionIdRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ActionGroupList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActionGroupList.DeserializeActionGroupList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/actionGroups", false); + uri.AppendQuery("api-version", "2019-06-01", true); + request.Uri = uri; + return message; + } + + /// Get a list of all action groups in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public async Task> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ActionGroupList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActionGroupList.DeserializeActionGroupList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get a list of all action groups in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public Response ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ActionGroupList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActionGroupList.DeserializeActionGroupList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateEnableReceiverRequest(string resourceGroupName, string actionGroupName, EnableRequest enableRequest) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/actionGroups/", false); + uri.AppendPath(actionGroupName, true); + uri.AppendPath("/subscribe", false); + uri.AppendQuery("api-version", "2019-06-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(enableRequest); + request.Content = content; + return message; + } + + /// Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. + /// The name of the resource group. + /// The name of the action group. + /// The receiver to re-enable. + /// The cancellation token to use. + /// , , or is null. + public async Task EnableReceiverAsync(string resourceGroupName, string actionGroupName, EnableRequest enableRequest, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + if (enableRequest == null) + { + throw new ArgumentNullException(nameof(enableRequest)); + } + + using var message = CreateEnableReceiverRequest(resourceGroupName, actionGroupName, enableRequest); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 409: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. + /// The name of the resource group. + /// The name of the action group. + /// The receiver to re-enable. + /// The cancellation token to use. + /// , , or is null. + public Response EnableReceiver(string resourceGroupName, string actionGroupName, EnableRequest enableRequest, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (actionGroupName == null) + { + throw new ArgumentNullException(nameof(actionGroupName)); + } + if (enableRequest == null) + { + throw new ArgumentNullException(nameof(enableRequest)); + } + + using var message = CreateEnableReceiverRequest(resourceGroupName, actionGroupName, enableRequest); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 409: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogAlertsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogAlertsOperations.cs new file mode 100644 index 000000000000..0a12168d4ef1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogAlertsOperations.cs @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The ActivityLogAlerts service client. + public partial class ActivityLogAlertsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal ActivityLogAlertsRestOperations RestClient { get; } + /// Initializes a new instance of ActivityLogAlertsOperations for mocking. + protected ActivityLogAlertsOperations() + { + } + /// Initializes a new instance of ActivityLogAlertsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal ActivityLogAlertsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new ActivityLogAlertsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Create a new activity log alert or update an existing one. + /// The name of the resource group. + /// The name of the activity log alert. + /// The activity log alert to create or use for the update. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateAsync(string resourceGroupName, string activityLogAlertName, ActivityLogAlertResource activityLogAlert, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateAsync(resourceGroupName, activityLogAlertName, activityLogAlert, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create a new activity log alert or update an existing one. + /// The name of the resource group. + /// The name of the activity log alert. + /// The activity log alert to create or use for the update. + /// The cancellation token to use. + public virtual Response CreateOrUpdate(string resourceGroupName, string activityLogAlertName, ActivityLogAlertResource activityLogAlert, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return RestClient.CreateOrUpdate(resourceGroupName, activityLogAlertName, activityLogAlert, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get an activity log alert. + /// The name of the resource group. + /// The name of the activity log alert. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceGroupName, activityLogAlertName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get an activity log alert. + /// The name of the resource group. + /// The name of the activity log alert. + /// The cancellation token to use. + public virtual Response Get(string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceGroupName, activityLogAlertName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete an activity log alert. + /// The name of the resource group. + /// The name of the activity log alert. + /// The cancellation token to use. + public virtual async Task DeleteAsync(string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.Delete"); + scope.Start(); + try + { + return await RestClient.DeleteAsync(resourceGroupName, activityLogAlertName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete an activity log alert. + /// The name of the resource group. + /// The name of the activity log alert. + /// The cancellation token to use. + public virtual Response Delete(string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.Delete"); + scope.Start(); + try + { + return RestClient.Delete(resourceGroupName, activityLogAlertName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the activity log alert. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(string resourceGroupName, string activityLogAlertName, ActivityLogAlertPatchBody activityLogAlertPatch, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.Update"); + scope.Start(); + try + { + return await RestClient.UpdateAsync(resourceGroupName, activityLogAlertName, activityLogAlertPatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the activity log alert. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual Response Update(string resourceGroupName, string activityLogAlertName, ActivityLogAlertPatchBody activityLogAlertPatch, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.Update"); + scope.Start(); + try + { + return RestClient.Update(resourceGroupName, activityLogAlertName, activityLogAlertPatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get a list of all activity log alerts in a subscription. + /// The cancellation token to use. + public virtual AsyncPageable ListBySubscriptionIdAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.ListBySubscriptionId"); + scope.Start(); + try + { + var response = await RestClient.ListBySubscriptionIdAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Get a list of all activity log alerts in a subscription. + /// The cancellation token to use. + public virtual Pageable ListBySubscriptionId(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.ListBySubscriptionId"); + scope.Start(); + try + { + var response = RestClient.ListBySubscriptionId(cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + + /// Get a list of all activity log alerts in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Get a list of all activity log alerts in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual Pageable ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogAlertsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogAlertsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogAlertsRestOperations.cs new file mode 100644 index 000000000000..6184b5f54b8b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogAlertsRestOperations.cs @@ -0,0 +1,522 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class ActivityLogAlertsRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of ActivityLogAlertsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public ActivityLogAlertsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string activityLogAlertName, ActivityLogAlertResource activityLogAlert) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/activityLogAlerts/", false); + uri.AppendPath(activityLogAlertName, true); + uri.AppendQuery("api-version", "2017-04-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(activityLogAlert); + request.Content = content; + return message; + } + + /// Create a new activity log alert or update an existing one. + /// The name of the resource group. + /// The name of the activity log alert. + /// The activity log alert to create or use for the update. + /// The cancellation token to use. + /// , , or is null. + public async Task> CreateOrUpdateAsync(string resourceGroupName, string activityLogAlertName, ActivityLogAlertResource activityLogAlert, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (activityLogAlertName == null) + { + throw new ArgumentNullException(nameof(activityLogAlertName)); + } + if (activityLogAlert == null) + { + throw new ArgumentNullException(nameof(activityLogAlert)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, activityLogAlertName, activityLogAlert); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + ActivityLogAlertResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActivityLogAlertResource.DeserializeActivityLogAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Create a new activity log alert or update an existing one. + /// The name of the resource group. + /// The name of the activity log alert. + /// The activity log alert to create or use for the update. + /// The cancellation token to use. + /// , , or is null. + public Response CreateOrUpdate(string resourceGroupName, string activityLogAlertName, ActivityLogAlertResource activityLogAlert, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (activityLogAlertName == null) + { + throw new ArgumentNullException(nameof(activityLogAlertName)); + } + if (activityLogAlert == null) + { + throw new ArgumentNullException(nameof(activityLogAlert)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, activityLogAlertName, activityLogAlert); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + ActivityLogAlertResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActivityLogAlertResource.DeserializeActivityLogAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string resourceGroupName, string activityLogAlertName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/activityLogAlerts/", false); + uri.AppendPath(activityLogAlertName, true); + uri.AppendQuery("api-version", "2017-04-01", true); + request.Uri = uri; + return message; + } + + /// Get an activity log alert. + /// The name of the resource group. + /// The name of the activity log alert. + /// The cancellation token to use. + /// or is null. + public async Task> GetAsync(string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (activityLogAlertName == null) + { + throw new ArgumentNullException(nameof(activityLogAlertName)); + } + + using var message = CreateGetRequest(resourceGroupName, activityLogAlertName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ActivityLogAlertResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActivityLogAlertResource.DeserializeActivityLogAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get an activity log alert. + /// The name of the resource group. + /// The name of the activity log alert. + /// The cancellation token to use. + /// or is null. + public Response Get(string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (activityLogAlertName == null) + { + throw new ArgumentNullException(nameof(activityLogAlertName)); + } + + using var message = CreateGetRequest(resourceGroupName, activityLogAlertName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ActivityLogAlertResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActivityLogAlertResource.DeserializeActivityLogAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string resourceGroupName, string activityLogAlertName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/activityLogAlerts/", false); + uri.AppendPath(activityLogAlertName, true); + uri.AppendQuery("api-version", "2017-04-01", true); + request.Uri = uri; + return message; + } + + /// Delete an activity log alert. + /// The name of the resource group. + /// The name of the activity log alert. + /// The cancellation token to use. + /// or is null. + public async Task DeleteAsync(string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (activityLogAlertName == null) + { + throw new ArgumentNullException(nameof(activityLogAlertName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, activityLogAlertName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Delete an activity log alert. + /// The name of the resource group. + /// The name of the activity log alert. + /// The cancellation token to use. + /// or is null. + public Response Delete(string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (activityLogAlertName == null) + { + throw new ArgumentNullException(nameof(activityLogAlertName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, activityLogAlertName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string resourceGroupName, string activityLogAlertName, ActivityLogAlertPatchBody activityLogAlertPatch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/activityLogAlerts/", false); + uri.AppendPath(activityLogAlertName, true); + uri.AppendQuery("api-version", "2017-04-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(activityLogAlertPatch); + request.Content = content; + return message; + } + + /// Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the activity log alert. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public async Task> UpdateAsync(string resourceGroupName, string activityLogAlertName, ActivityLogAlertPatchBody activityLogAlertPatch, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (activityLogAlertName == null) + { + throw new ArgumentNullException(nameof(activityLogAlertName)); + } + if (activityLogAlertPatch == null) + { + throw new ArgumentNullException(nameof(activityLogAlertPatch)); + } + + using var message = CreateUpdateRequest(resourceGroupName, activityLogAlertName, activityLogAlertPatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ActivityLogAlertResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActivityLogAlertResource.DeserializeActivityLogAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the activity log alert. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public Response Update(string resourceGroupName, string activityLogAlertName, ActivityLogAlertPatchBody activityLogAlertPatch, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (activityLogAlertName == null) + { + throw new ArgumentNullException(nameof(activityLogAlertName)); + } + if (activityLogAlertPatch == null) + { + throw new ArgumentNullException(nameof(activityLogAlertPatch)); + } + + using var message = CreateUpdateRequest(resourceGroupName, activityLogAlertName, activityLogAlertPatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ActivityLogAlertResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActivityLogAlertResource.DeserializeActivityLogAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionIdRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/activityLogAlerts", false); + uri.AppendQuery("api-version", "2017-04-01", true); + request.Uri = uri; + return message; + } + + /// Get a list of all activity log alerts in a subscription. + /// The cancellation token to use. + public async Task> ListBySubscriptionIdAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionIdRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ActivityLogAlertList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActivityLogAlertList.DeserializeActivityLogAlertList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get a list of all activity log alerts in a subscription. + /// The cancellation token to use. + public Response ListBySubscriptionId(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionIdRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ActivityLogAlertList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActivityLogAlertList.DeserializeActivityLogAlertList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/activityLogAlerts", false); + uri.AppendQuery("api-version", "2017-04-01", true); + request.Uri = uri; + return message; + } + + /// Get a list of all activity log alerts in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public async Task> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ActivityLogAlertList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ActivityLogAlertList.DeserializeActivityLogAlertList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get a list of all activity log alerts in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public Response ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ActivityLogAlertList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ActivityLogAlertList.DeserializeActivityLogAlertList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogsOperations.cs new file mode 100644 index 000000000000..680813836b37 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogsOperations.cs @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The ActivityLogs service client. + public partial class ActivityLogsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal ActivityLogsRestOperations RestClient { get; } + /// Initializes a new instance of ActivityLogsOperations for mocking. + protected ActivityLogsOperations() + { + } + /// Initializes a new instance of ActivityLogsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal ActivityLogsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new ActivityLogsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Provides the list of records from the activity logs. + /// Reduces the set of data collected.<br>This argument is required and it also requires at least the start date/time.<br>The **$filter** argument is very restricted and allows only the following patterns.<br>- *List events for a resource group*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.<br>- *List events for resource*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.<br>- *List events for a subscription in a time range*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'.<br>- *List events for a resource provider*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.<br>- *List events for a correlation Id*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq 'correlationID'.<br><br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListAsync(string filter, string select = null, CancellationToken cancellationToken = default) + { + if (filter == null) + { + throw new ArgumentNullException(nameof(filter)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogsOperations.List"); + scope.Start(); + try + { + var response = await RestClient.ListAsync(filter, select, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogsOperations.List"); + scope.Start(); + try + { + var response = await RestClient.ListNextPageAsync(nextLink, filter, select, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Provides the list of records from the activity logs. + /// Reduces the set of data collected.<br>This argument is required and it also requires at least the start date/time.<br>The **$filter** argument is very restricted and allows only the following patterns.<br>- *List events for a resource group*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.<br>- *List events for resource*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.<br>- *List events for a subscription in a time range*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'.<br>- *List events for a resource provider*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.<br>- *List events for a correlation Id*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq 'correlationID'.<br><br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + /// is null. + public virtual Pageable List(string filter, string select = null, CancellationToken cancellationToken = default) + { + if (filter == null) + { + throw new ArgumentNullException(nameof(filter)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogsOperations.List"); + scope.Start(); + try + { + var response = RestClient.List(filter, select, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ActivityLogsOperations.List"); + scope.Start(); + try + { + var response = RestClient.ListNextPage(nextLink, filter, select, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogsRestOperations.cs new file mode 100644 index 000000000000..d1415c220298 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ActivityLogsRestOperations.cs @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class ActivityLogsRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of ActivityLogsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public ActivityLogsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListRequest(string filter, string select) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/eventtypes/management/values", false); + uri.AppendQuery("api-version", "2015-04-01", true); + uri.AppendQuery("$filter", filter, true); + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + request.Uri = uri; + return message; + } + + /// Provides the list of records from the activity logs. + /// Reduces the set of data collected.<br>This argument is required and it also requires at least the start date/time.<br>The **$filter** argument is very restricted and allows only the following patterns.<br>- *List events for a resource group*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.<br>- *List events for resource*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.<br>- *List events for a subscription in a time range*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'.<br>- *List events for a resource provider*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.<br>- *List events for a correlation Id*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq 'correlationID'.<br><br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string filter, string select = null, CancellationToken cancellationToken = default) + { + if (filter == null) + { + throw new ArgumentNullException(nameof(filter)); + } + + using var message = CreateListRequest(filter, select); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EventDataCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EventDataCollection.DeserializeEventDataCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Provides the list of records from the activity logs. + /// Reduces the set of data collected.<br>This argument is required and it also requires at least the start date/time.<br>The **$filter** argument is very restricted and allows only the following patterns.<br>- *List events for a resource group*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.<br>- *List events for resource*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.<br>- *List events for a subscription in a time range*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'.<br>- *List events for a resource provider*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.<br>- *List events for a correlation Id*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq 'correlationID'.<br><br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + /// is null. + public Response List(string filter, string select = null, CancellationToken cancellationToken = default) + { + if (filter == null) + { + throw new ArgumentNullException(nameof(filter)); + } + + using var message = CreateListRequest(filter, select); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EventDataCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EventDataCollection.DeserializeEventDataCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string filter, string select) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + return message; + } + + /// Provides the list of records from the activity logs. + /// The URL to the next page of results. + /// Reduces the set of data collected.<br>This argument is required and it also requires at least the start date/time.<br>The **$filter** argument is very restricted and allows only the following patterns.<br>- *List events for a resource group*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.<br>- *List events for resource*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.<br>- *List events for a subscription in a time range*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'.<br>- *List events for a resource provider*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.<br>- *List events for a correlation Id*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq 'correlationID'.<br><br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + /// or is null. + public async Task> ListNextPageAsync(string nextLink, string filter, string select = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (filter == null) + { + throw new ArgumentNullException(nameof(filter)); + } + + using var message = CreateListNextPageRequest(nextLink, filter, select); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EventDataCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EventDataCollection.DeserializeEventDataCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Provides the list of records from the activity logs. + /// The URL to the next page of results. + /// Reduces the set of data collected.<br>This argument is required and it also requires at least the start date/time.<br>The **$filter** argument is very restricted and allows only the following patterns.<br>- *List events for a resource group*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.<br>- *List events for resource*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.<br>- *List events for a subscription in a time range*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'.<br>- *List events for a resource provider*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.<br>- *List events for a correlation Id*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq 'correlationID'.<br><br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + /// or is null. + public Response ListNextPage(string nextLink, string filter, string select = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (filter == null) + { + throw new ArgumentNullException(nameof(filter)); + } + + using var message = CreateListNextPageRequest(nextLink, filter, select); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EventDataCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EventDataCollection.DeserializeEventDataCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRuleIncidentsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRuleIncidentsOperations.cs new file mode 100644 index 000000000000..1fd546589bc3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRuleIncidentsOperations.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The AlertRuleIncidents service client. + public partial class AlertRuleIncidentsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal AlertRuleIncidentsRestOperations RestClient { get; } + /// Initializes a new instance of AlertRuleIncidentsOperations for mocking. + protected AlertRuleIncidentsOperations() + { + } + /// Initializes a new instance of AlertRuleIncidentsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal AlertRuleIncidentsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new AlertRuleIncidentsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Gets an incident associated to an alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The name of the incident to retrieve. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceGroupName, string ruleName, string incidentName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRuleIncidentsOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceGroupName, ruleName, incidentName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets an incident associated to an alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The name of the incident to retrieve. + /// The cancellation token to use. + public virtual Response Get(string resourceGroupName, string ruleName, string incidentName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRuleIncidentsOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceGroupName, ruleName, incidentName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of incidents associated to an alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public virtual AsyncPageable ListByAlertRuleAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AlertRuleIncidentsOperations.ListByAlertRule"); + scope.Start(); + try + { + var response = await RestClient.ListByAlertRuleAsync(resourceGroupName, ruleName, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Gets a list of incidents associated to an alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public virtual Pageable ListByAlertRule(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AlertRuleIncidentsOperations.ListByAlertRule"); + scope.Start(); + try + { + var response = RestClient.ListByAlertRule(resourceGroupName, ruleName, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRuleIncidentsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRuleIncidentsRestOperations.cs new file mode 100644 index 000000000000..ed11738836b0 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRuleIncidentsRestOperations.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class AlertRuleIncidentsRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of AlertRuleIncidentsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public AlertRuleIncidentsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateGetRequest(string resourceGroupName, string ruleName, string incidentName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/alertrules/", false); + uri.AppendPath(ruleName, true); + uri.AppendPath("/incidents/", false); + uri.AppendPath(incidentName, true); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + return message; + } + + /// Gets an incident associated to an alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The name of the incident to retrieve. + /// The cancellation token to use. + /// , , or is null. + public async Task> GetAsync(string resourceGroupName, string ruleName, string incidentName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (incidentName == null) + { + throw new ArgumentNullException(nameof(incidentName)); + } + + using var message = CreateGetRequest(resourceGroupName, ruleName, incidentName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Incident value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Incident.DeserializeIncident(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets an incident associated to an alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The name of the incident to retrieve. + /// The cancellation token to use. + /// , , or is null. + public Response Get(string resourceGroupName, string ruleName, string incidentName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (incidentName == null) + { + throw new ArgumentNullException(nameof(incidentName)); + } + + using var message = CreateGetRequest(resourceGroupName, ruleName, incidentName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Incident value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Incident.DeserializeIncident(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByAlertRuleRequest(string resourceGroupName, string ruleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/alertrules/", false); + uri.AppendPath(ruleName, true); + uri.AppendPath("/incidents", false); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + return message; + } + + /// Gets a list of incidents associated to an alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public async Task> ListByAlertRuleAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateListByAlertRuleRequest(resourceGroupName, ruleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + IncidentListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IncidentListResult.DeserializeIncidentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of incidents associated to an alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public Response ListByAlertRule(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateListByAlertRuleRequest(resourceGroupName, ruleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + IncidentListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IncidentListResult.DeserializeIncidentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRulesOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRulesOperations.cs new file mode 100644 index 000000000000..3e45a0ed2778 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRulesOperations.cs @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The AlertRules service client. + public partial class AlertRulesOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal AlertRulesRestOperations RestClient { get; } + /// Initializes a new instance of AlertRulesOperations for mocking. + protected AlertRulesOperations() + { + } + /// Initializes a new instance of AlertRulesOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal AlertRulesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new AlertRulesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Creates or updates a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateAsync(string resourceGroupName, string ruleName, AlertRuleResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.CreateOrUpdate"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateAsync(resourceGroupName, ruleName, parameters, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates or updates a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + public virtual Response CreateOrUpdate(string resourceGroupName, string ruleName, AlertRuleResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.CreateOrUpdate"); + scope.Start(); + try + { + return RestClient.CreateOrUpdate(resourceGroupName, ruleName, parameters, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual async Task DeleteAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.Delete"); + scope.Start(); + try + { + return await RestClient.DeleteAsync(resourceGroupName, ruleName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual Response Delete(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.Delete"); + scope.Start(); + try + { + return RestClient.Delete(resourceGroupName, ruleName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceGroupName, ruleName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual Response Get(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceGroupName, ruleName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the rule. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.Update"); + scope.Start(); + try + { + return await RestClient.UpdateAsync(resourceGroupName, ruleName, alertRulesResource, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the rule. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual Response Update(string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.Update"); + scope.Start(); + try + { + return RestClient.Update(resourceGroupName, ruleName, alertRulesResource, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the classic metric alert rules within a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// List the classic metric alert rules within a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual Pageable ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + + /// List the classic metric alert rules within a subscription. + /// The cancellation token to use. + public virtual AsyncPageable ListBySubscriptionAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.ListBySubscription"); + scope.Start(); + try + { + var response = await RestClient.ListBySubscriptionAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// List the classic metric alert rules within a subscription. + /// The cancellation token to use. + public virtual Pageable ListBySubscription(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AlertRulesOperations.ListBySubscription"); + scope.Start(); + try + { + var response = RestClient.ListBySubscription(cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRulesRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRulesRestOperations.cs new file mode 100644 index 000000000000..475cad72a626 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AlertRulesRestOperations.cs @@ -0,0 +1,524 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class AlertRulesRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of AlertRulesRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public AlertRulesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string ruleName, AlertRuleResource parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/alertrules/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + return message; + } + + /// Creates or updates a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + /// , , or is null. + public async Task> CreateOrUpdateAsync(string resourceGroupName, string ruleName, AlertRuleResource parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, ruleName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + AlertRuleResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AlertRuleResource.DeserializeAlertRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Creates or updates a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + /// , , or is null. + public Response CreateOrUpdate(string resourceGroupName, string ruleName, AlertRuleResource parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, ruleName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + AlertRuleResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AlertRuleResource.DeserializeAlertRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string resourceGroupName, string ruleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/alertrules/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + return message; + } + + /// Deletes a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public async Task DeleteAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, ruleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Deletes a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public Response Delete(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, ruleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string resourceGroupName, string ruleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/alertrules/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + return message; + } + + /// Gets a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public async Task> GetAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateGetRequest(resourceGroupName, ruleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AlertRuleResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AlertRuleResource.DeserializeAlertRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a classic metric alert rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public Response Get(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateGetRequest(resourceGroupName, ruleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AlertRuleResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AlertRuleResource.DeserializeAlertRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/alertrules/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(alertRulesResource); + request.Content = content; + return message; + } + + /// Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the rule. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public async Task> UpdateAsync(string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (alertRulesResource == null) + { + throw new ArgumentNullException(nameof(alertRulesResource)); + } + + using var message = CreateUpdateRequest(resourceGroupName, ruleName, alertRulesResource); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + AlertRuleResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AlertRuleResource.DeserializeAlertRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The name of the rule. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public Response Update(string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (alertRulesResource == null) + { + throw new ArgumentNullException(nameof(alertRulesResource)); + } + + using var message = CreateUpdateRequest(resourceGroupName, ruleName, alertRulesResource); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + AlertRuleResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AlertRuleResource.DeserializeAlertRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/alertrules", false); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + return message; + } + + /// List the classic metric alert rules within a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public async Task> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AlertRuleResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AlertRuleResourceCollection.DeserializeAlertRuleResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// List the classic metric alert rules within a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public Response ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AlertRuleResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AlertRuleResourceCollection.DeserializeAlertRuleResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/alertrules", false); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + return message; + } + + /// List the classic metric alert rules within a subscription. + /// The cancellation token to use. + public async Task> ListBySubscriptionAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AlertRuleResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AlertRuleResourceCollection.DeserializeAlertRuleResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// List the classic metric alert rules within a subscription. + /// The cancellation token to use. + public Response ListBySubscription(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AlertRuleResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AlertRuleResourceCollection.DeserializeAlertRuleResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AutoscaleSettingsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AutoscaleSettingsOperations.cs new file mode 100644 index 000000000000..93f2fc8c8abc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AutoscaleSettingsOperations.cs @@ -0,0 +1,358 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The AutoscaleSettings service client. + public partial class AutoscaleSettingsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal AutoscaleSettingsRestOperations RestClient { get; } + /// Initializes a new instance of AutoscaleSettingsOperations for mocking. + protected AutoscaleSettingsOperations() + { + } + /// Initializes a new instance of AutoscaleSettingsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal AutoscaleSettingsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new AutoscaleSettingsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Creates or updates an autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateAsync(resourceGroupName, autoscaleSettingName, parameters, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates or updates an autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual Response CreateOrUpdate(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return RestClient.CreateOrUpdate(resourceGroupName, autoscaleSettingName, parameters, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes and autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// The cancellation token to use. + public virtual async Task DeleteAsync(string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.Delete"); + scope.Start(); + try + { + return await RestClient.DeleteAsync(resourceGroupName, autoscaleSettingName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes and autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// The cancellation token to use. + public virtual Response Delete(string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.Delete"); + scope.Start(); + try + { + return RestClient.Delete(resourceGroupName, autoscaleSettingName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets an autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceGroupName, autoscaleSettingName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets an autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// The cancellation token to use. + public virtual Response Get(string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceGroupName, autoscaleSettingName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The autoscale setting name. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.Update"); + scope.Start(); + try + { + return await RestClient.UpdateAsync(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The autoscale setting name. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual Response Update(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.Update"); + scope.Start(); + try + { + return RestClient.Update(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists the autoscale settings for a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = await RestClient.ListByResourceGroupNextPageAsync(nextLink, resourceGroupName, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Lists the autoscale settings for a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual Pageable ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = RestClient.ListByResourceGroupNextPage(nextLink, resourceGroupName, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Lists the autoscale settings for a subscription. + /// The cancellation token to use. + public virtual AsyncPageable ListBySubscriptionAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.ListBySubscription"); + scope.Start(); + try + { + var response = await RestClient.ListBySubscriptionAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.ListBySubscription"); + scope.Start(); + try + { + var response = await RestClient.ListBySubscriptionNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Lists the autoscale settings for a subscription. + /// The cancellation token to use. + public virtual Pageable ListBySubscription(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.ListBySubscription"); + scope.Start(); + try + { + var response = RestClient.ListBySubscription(cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("AutoscaleSettingsOperations.ListBySubscription"); + scope.Start(); + try + { + var response = RestClient.ListBySubscriptionNextPage(nextLink, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AutoscaleSettingsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AutoscaleSettingsRestOperations.cs new file mode 100644 index 000000000000..40f4c2ae1b0f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/AutoscaleSettingsRestOperations.cs @@ -0,0 +1,664 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class AutoscaleSettingsRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of AutoscaleSettingsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public AutoscaleSettingsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/autoscalesettings", false); + uri.AppendQuery("api-version", "2015-04-01", true); + request.Uri = uri; + return message; + } + + /// Lists the autoscale settings for a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public async Task> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AutoscaleSettingResourceCollection.DeserializeAutoscaleSettingResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Lists the autoscale settings for a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public Response ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AutoscaleSettingResourceCollection.DeserializeAutoscaleSettingResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResource parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/autoscalesettings/", false); + uri.AppendPath(autoscaleSettingName, true); + uri.AppendQuery("api-version", "2015-04-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + return message; + } + + /// Creates or updates an autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public async Task> CreateOrUpdateAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResource parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (autoscaleSettingName == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, autoscaleSettingName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + AutoscaleSettingResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AutoscaleSettingResource.DeserializeAutoscaleSettingResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Creates or updates an autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public Response CreateOrUpdate(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResource parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (autoscaleSettingName == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, autoscaleSettingName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + AutoscaleSettingResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AutoscaleSettingResource.DeserializeAutoscaleSettingResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string resourceGroupName, string autoscaleSettingName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/autoscalesettings/", false); + uri.AppendPath(autoscaleSettingName, true); + uri.AppendQuery("api-version", "2015-04-01", true); + request.Uri = uri; + return message; + } + + /// Deletes and autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// The cancellation token to use. + /// or is null. + public async Task DeleteAsync(string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (autoscaleSettingName == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, autoscaleSettingName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Deletes and autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// The cancellation token to use. + /// or is null. + public Response Delete(string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (autoscaleSettingName == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, autoscaleSettingName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string resourceGroupName, string autoscaleSettingName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/autoscalesettings/", false); + uri.AppendPath(autoscaleSettingName, true); + uri.AppendQuery("api-version", "2015-04-01", true); + request.Uri = uri; + return message; + } + + /// Gets an autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// The cancellation token to use. + /// or is null. + public async Task> GetAsync(string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (autoscaleSettingName == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingName)); + } + + using var message = CreateGetRequest(resourceGroupName, autoscaleSettingName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AutoscaleSettingResource.DeserializeAutoscaleSettingResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets an autoscale setting. + /// The name of the resource group. + /// The autoscale setting name. + /// The cancellation token to use. + /// or is null. + public Response Get(string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (autoscaleSettingName == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingName)); + } + + using var message = CreateGetRequest(resourceGroupName, autoscaleSettingName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AutoscaleSettingResource.DeserializeAutoscaleSettingResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/autoscalesettings/", false); + uri.AppendPath(autoscaleSettingName, true); + uri.AppendQuery("api-version", "2015-04-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(autoscaleSettingResource); + request.Content = content; + return message; + } + + /// Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The autoscale setting name. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public async Task> UpdateAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (autoscaleSettingName == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingName)); + } + if (autoscaleSettingResource == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingResource)); + } + + using var message = CreateUpdateRequest(resourceGroupName, autoscaleSettingName, autoscaleSettingResource); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AutoscaleSettingResource.DeserializeAutoscaleSettingResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. + /// The name of the resource group. + /// The autoscale setting name. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public Response Update(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (autoscaleSettingName == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingName)); + } + if (autoscaleSettingResource == null) + { + throw new ArgumentNullException(nameof(autoscaleSettingResource)); + } + + using var message = CreateUpdateRequest(resourceGroupName, autoscaleSettingName, autoscaleSettingResource); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AutoscaleSettingResource.DeserializeAutoscaleSettingResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/autoscalesettings", false); + uri.AppendQuery("api-version", "2015-04-01", true); + request.Uri = uri; + return message; + } + + /// Lists the autoscale settings for a subscription. + /// The cancellation token to use. + public async Task> ListBySubscriptionAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AutoscaleSettingResourceCollection.DeserializeAutoscaleSettingResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Lists the autoscale settings for a subscription. + /// The cancellation token to use. + public Response ListBySubscription(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AutoscaleSettingResourceCollection.DeserializeAutoscaleSettingResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + return message; + } + + /// Lists the autoscale settings for a resource group. + /// The URL to the next page of results. + /// The name of the resource group. + /// The cancellation token to use. + /// or is null. + public async Task> ListByResourceGroupNextPageAsync(string nextLink, string resourceGroupName, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AutoscaleSettingResourceCollection.DeserializeAutoscaleSettingResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Lists the autoscale settings for a resource group. + /// The URL to the next page of results. + /// The name of the resource group. + /// The cancellation token to use. + /// or is null. + public Response ListByResourceGroupNextPage(string nextLink, string resourceGroupName, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AutoscaleSettingResourceCollection.DeserializeAutoscaleSettingResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + return message; + } + + /// Lists the autoscale settings for a subscription. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListBySubscriptionNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AutoscaleSettingResourceCollection.DeserializeAutoscaleSettingResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Lists the autoscale settings for a subscription. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public Response ListBySubscriptionNextPage(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListBySubscriptionNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AutoscaleSettingResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AutoscaleSettingResourceCollection.DeserializeAutoscaleSettingResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/BaselinesOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/BaselinesOperations.cs new file mode 100644 index 000000000000..80f3630f4184 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/BaselinesOperations.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The Baselines service client. + public partial class BaselinesOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal BaselinesRestOperations RestClient { get; } + /// Initializes a new instance of BaselinesOperations for mocking. + protected BaselinesOperations() + { + } + /// Initializes a new instance of BaselinesOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal BaselinesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new BaselinesRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// **Lists the metric baseline values for a resource**. + /// The identifier of the resource. + /// The names of the metrics (comma separated) to retrieve. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The list of aggregation types (comma separated) to retrieve. + /// The list of sensitivities (comma separated) to retrieve. + /// The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// Allows retrieving only metadata of the baseline. On data request all information is retrieved. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListAsync(string resourceUri, string metricnames = null, string metricnamespace = null, string timespan = null, TimeSpan? interval = null, string aggregation = null, string sensitivities = null, string filter = null, ResultType? resultType = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("BaselinesOperations.List"); + scope.Start(); + try + { + var response = await RestClient.ListAsync(resourceUri, metricnames, metricnamespace, timespan, interval, aggregation, sensitivities, filter, resultType, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// **Lists the metric baseline values for a resource**. + /// The identifier of the resource. + /// The names of the metrics (comma separated) to retrieve. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The list of aggregation types (comma separated) to retrieve. + /// The list of sensitivities (comma separated) to retrieve. + /// The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// Allows retrieving only metadata of the baseline. On data request all information is retrieved. + /// The cancellation token to use. + /// is null. + public virtual Pageable List(string resourceUri, string metricnames = null, string metricnamespace = null, string timespan = null, TimeSpan? interval = null, string aggregation = null, string sensitivities = null, string filter = null, ResultType? resultType = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("BaselinesOperations.List"); + scope.Start(); + try + { + var response = RestClient.List(resourceUri, metricnames, metricnamespace, timespan, interval, aggregation, sensitivities, filter, resultType, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/BaselinesRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/BaselinesRestOperations.cs new file mode 100644 index 000000000000..12999d5beed4 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/BaselinesRestOperations.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class BaselinesRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of BaselinesRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public BaselinesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListRequest(string resourceUri, string metricnames, string metricnamespace, string timespan, TimeSpan? interval, string aggregation, string sensitivities, string filter, ResultType? resultType) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/metricBaselines", false); + if (metricnames != null) + { + uri.AppendQuery("metricnames", metricnames, true); + } + if (metricnamespace != null) + { + uri.AppendQuery("metricnamespace", metricnamespace, true); + } + if (timespan != null) + { + uri.AppendQuery("timespan", timespan, true); + } + if (interval != null) + { + uri.AppendQuery("interval", interval.Value, "P", true); + } + if (aggregation != null) + { + uri.AppendQuery("aggregation", aggregation, true); + } + if (sensitivities != null) + { + uri.AppendQuery("sensitivities", sensitivities, true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (resultType != null) + { + uri.AppendQuery("resultType", resultType.Value.ToSerialString(), true); + } + uri.AppendQuery("api-version", "2019-03-01", true); + request.Uri = uri; + return message; + } + + /// **Lists the metric baseline values for a resource**. + /// The identifier of the resource. + /// The names of the metrics (comma separated) to retrieve. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The list of aggregation types (comma separated) to retrieve. + /// The list of sensitivities (comma separated) to retrieve. + /// The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// Allows retrieving only metadata of the baseline. On data request all information is retrieved. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, string metricnames = null, string metricnamespace = null, string timespan = null, TimeSpan? interval = null, string aggregation = null, string sensitivities = null, string filter = null, ResultType? resultType = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri, metricnames, metricnamespace, timespan, interval, aggregation, sensitivities, filter, resultType); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricBaselinesResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricBaselinesResponse.DeserializeMetricBaselinesResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// **Lists the metric baseline values for a resource**. + /// The identifier of the resource. + /// The names of the metrics (comma separated) to retrieve. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The list of aggregation types (comma separated) to retrieve. + /// The list of sensitivities (comma separated) to retrieve. + /// The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// Allows retrieving only metadata of the baseline. On data request all information is retrieved. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, string metricnames = null, string metricnamespace = null, string timespan = null, TimeSpan? interval = null, string aggregation = null, string sensitivities = null, string filter = null, ResultType? resultType = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri, metricnames, metricnamespace, timespan, interval, aggregation, sensitivities, filter, resultType); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricBaselinesResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricBaselinesResponse.DeserializeMetricBaselinesResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsCategoryOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsCategoryOperations.cs new file mode 100644 index 000000000000..95eb2a800c7e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsCategoryOperations.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The DiagnosticSettingsCategory service client. + public partial class DiagnosticSettingsCategoryOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal DiagnosticSettingsCategoryRestOperations RestClient { get; } + /// Initializes a new instance of DiagnosticSettingsCategoryOperations for mocking. + protected DiagnosticSettingsCategoryOperations() + { + } + /// Initializes a new instance of DiagnosticSettingsCategoryOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal DiagnosticSettingsCategoryOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new DiagnosticSettingsCategoryRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Gets the diagnostic settings category for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceUri, string name, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsCategoryOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceUri, name, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the diagnostic settings category for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + public virtual Response Get(string resourceUri, string name, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsCategoryOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceUri, name, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists the diagnostic settings categories for the specified resource. + /// The identifier of the resource. + /// The cancellation token to use. + public virtual async Task> ListAsync(string resourceUri, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsCategoryOperations.List"); + scope.Start(); + try + { + return await RestClient.ListAsync(resourceUri, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists the diagnostic settings categories for the specified resource. + /// The identifier of the resource. + /// The cancellation token to use. + public virtual Response List(string resourceUri, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsCategoryOperations.List"); + scope.Start(); + try + { + return RestClient.List(resourceUri, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsCategoryRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsCategoryRestOperations.cs new file mode 100644 index 000000000000..1dfa3e62038f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsCategoryRestOperations.cs @@ -0,0 +1,187 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class DiagnosticSettingsCategoryRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of DiagnosticSettingsCategoryRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public DiagnosticSettingsCategoryRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateGetRequest(string resourceUri, string name) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/diagnosticSettingsCategories/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", "2017-05-01-preview", true); + request.Uri = uri; + return message; + } + + /// Gets the diagnostic settings category for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + /// or is null. + public async Task> GetAsync(string resourceUri, string name, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + using var message = CreateGetRequest(resourceUri, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsCategoryResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DiagnosticSettingsCategoryResource.DeserializeDiagnosticSettingsCategoryResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the diagnostic settings category for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + /// or is null. + public Response Get(string resourceUri, string name, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + using var message = CreateGetRequest(resourceUri, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsCategoryResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DiagnosticSettingsCategoryResource.DeserializeDiagnosticSettingsCategoryResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListRequest(string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/diagnosticSettingsCategories", false); + uri.AppendQuery("api-version", "2017-05-01-preview", true); + request.Uri = uri; + return message; + } + + /// Lists the diagnostic settings categories for the specified resource. + /// The identifier of the resource. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsCategoryResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DiagnosticSettingsCategoryResourceCollection.DeserializeDiagnosticSettingsCategoryResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Lists the diagnostic settings categories for the specified resource. + /// The identifier of the resource. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsCategoryResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DiagnosticSettingsCategoryResourceCollection.DeserializeDiagnosticSettingsCategoryResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsOperations.cs new file mode 100644 index 000000000000..0eb1ae10f0df --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsOperations.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The DiagnosticSettings service client. + public partial class DiagnosticSettingsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal DiagnosticSettingsRestOperations RestClient { get; } + /// Initializes a new instance of DiagnosticSettingsOperations for mocking. + protected DiagnosticSettingsOperations() + { + } + /// Initializes a new instance of DiagnosticSettingsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal DiagnosticSettingsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new DiagnosticSettingsRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Gets the active diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceUri, string name, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceUri, name, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the active diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + public virtual Response Get(string resourceUri, string name, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceUri, name, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates or updates diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateAsync(string resourceUri, string name, DiagnosticSettingsResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateAsync(resourceUri, name, parameters, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates or updates diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual Response CreateOrUpdate(string resourceUri, string name, DiagnosticSettingsResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return RestClient.CreateOrUpdate(resourceUri, name, parameters, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes existing diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + public virtual async Task DeleteAsync(string resourceUri, string name, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsOperations.Delete"); + scope.Start(); + try + { + return await RestClient.DeleteAsync(resourceUri, name, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes existing diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + public virtual Response Delete(string resourceUri, string name, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsOperations.Delete"); + scope.Start(); + try + { + return RestClient.Delete(resourceUri, name, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the active diagnostic settings list for the specified resource. + /// The identifier of the resource. + /// The cancellation token to use. + public virtual async Task> ListAsync(string resourceUri, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsOperations.List"); + scope.Start(); + try + { + return await RestClient.ListAsync(resourceUri, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the active diagnostic settings list for the specified resource. + /// The identifier of the resource. + /// The cancellation token to use. + public virtual Response List(string resourceUri, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DiagnosticSettingsOperations.List"); + scope.Start(); + try + { + return RestClient.List(resourceUri, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsRestOperations.cs new file mode 100644 index 000000000000..dfc7563e6d91 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/DiagnosticSettingsRestOperations.cs @@ -0,0 +1,353 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class DiagnosticSettingsRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of DiagnosticSettingsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public DiagnosticSettingsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateGetRequest(string resourceUri, string name) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/diagnosticSettings/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", "2017-05-01-preview", true); + request.Uri = uri; + return message; + } + + /// Gets the active diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + /// or is null. + public async Task> GetAsync(string resourceUri, string name, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + using var message = CreateGetRequest(resourceUri, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DiagnosticSettingsResource.DeserializeDiagnosticSettingsResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the active diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + /// or is null. + public Response Get(string resourceUri, string name, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + using var message = CreateGetRequest(resourceUri, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DiagnosticSettingsResource.DeserializeDiagnosticSettingsResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceUri, string name, DiagnosticSettingsResource parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/diagnosticSettings/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", "2017-05-01-preview", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + return message; + } + + /// Creates or updates diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public async Task> CreateOrUpdateAsync(string resourceUri, string name, DiagnosticSettingsResource parameters, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceUri, name, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DiagnosticSettingsResource.DeserializeDiagnosticSettingsResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Creates or updates diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// , , or is null. + public Response CreateOrUpdate(string resourceUri, string name, DiagnosticSettingsResource parameters, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceUri, name, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DiagnosticSettingsResource.DeserializeDiagnosticSettingsResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string resourceUri, string name) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/diagnosticSettings/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", "2017-05-01-preview", true); + request.Uri = uri; + return message; + } + + /// Deletes existing diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + /// or is null. + public async Task DeleteAsync(string resourceUri, string name, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + using var message = CreateDeleteRequest(resourceUri, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Deletes existing diagnostic settings for the specified resource. + /// The identifier of the resource. + /// The name of the diagnostic setting. + /// The cancellation token to use. + /// or is null. + public Response Delete(string resourceUri, string name, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + using var message = CreateDeleteRequest(resourceUri, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListRequest(string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/diagnosticSettings", false); + uri.AppendQuery("api-version", "2017-05-01-preview", true); + request.Uri = uri; + return message; + } + + /// Gets the active diagnostic settings list for the specified resource. + /// The identifier of the resource. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DiagnosticSettingsResourceCollection.DeserializeDiagnosticSettingsResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the active diagnostic settings list for the specified resource. + /// The identifier of the resource. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DiagnosticSettingsResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DiagnosticSettingsResourceCollection.DeserializeDiagnosticSettingsResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/EventCategoriesOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/EventCategoriesOperations.cs new file mode 100644 index 000000000000..854b87b1dee2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/EventCategoriesOperations.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The EventCategories service client. + public partial class EventCategoriesOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal EventCategoriesRestOperations RestClient { get; } + /// Initializes a new instance of EventCategoriesOperations for mocking. + protected EventCategoriesOperations() + { + } + /// Initializes a new instance of EventCategoriesOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal EventCategoriesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new EventCategoriesRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Get the list of available event categories supported in the Activity Logs Service.<br>The current list includes the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. + /// The cancellation token to use. + public virtual AsyncPageable ListAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("EventCategoriesOperations.List"); + scope.Start(); + try + { + var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Get the list of available event categories supported in the Activity Logs Service.<br>The current list includes the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. + /// The cancellation token to use. + public virtual Pageable List(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("EventCategoriesOperations.List"); + scope.Start(); + try + { + var response = RestClient.List(cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/EventCategoriesRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/EventCategoriesRestOperations.cs new file mode 100644 index 000000000000..e42c74543871 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/EventCategoriesRestOperations.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class EventCategoriesRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of EventCategoriesRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public EventCategoriesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/providers/microsoft.insights/eventcategories", false); + uri.AppendQuery("api-version", "2015-04-01", true); + request.Uri = uri; + return message; + } + + /// Get the list of available event categories supported in the Activity Logs Service.<br>The current list includes the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. + /// The cancellation token to use. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EventCategoryCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EventCategoryCollection.DeserializeEventCategoryCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get the list of available event categories supported in the Activity Logs Service.<br>The current list includes the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. + /// The cancellation token to use. + public Response List(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EventCategoryCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EventCategoryCollection.DeserializeEventCategoryCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/InsightsManagementClient.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/InsightsManagementClient.cs new file mode 100644 index 000000000000..2f580feeef47 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/InsightsManagementClient.cs @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights; + +namespace Azure.ResourceManager.Insights +{ + /// Insights service management client. + public class InsightsManagementClient + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + private readonly string _subscriptionId; + private readonly Uri _endpoint; + + /// Initializes a new instance of InsightsManagementClient for mocking. + protected InsightsManagementClient() + { + } + + /// Initializes a new instance of InsightsManagementClient. + /// The Azure subscription Id. + /// The OAuth token for making client requests. + /// The options for configuring the client. + public InsightsManagementClient(string subscriptionId, TokenCredential tokenCredential, InsightsManagementClientOptions options = null) : this(subscriptionId, null, tokenCredential, options) + { + } + /// Initializes a new instance of InsightsManagementClient. + /// The Azure subscription Id. + /// server parameter. + /// The OAuth token for making client requests. + /// The options for configuring the client. + /// is null. + public InsightsManagementClient(string subscriptionId, Uri endpoint, TokenCredential tokenCredential, InsightsManagementClientOptions options = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + options ??= new InsightsManagementClientOptions(); + _clientDiagnostics = new ClientDiagnostics(options); + _pipeline = ManagementPipelineBuilder.Build(tokenCredential, endpoint, options); + _subscriptionId = subscriptionId; + _endpoint = endpoint; + } + + /// Returns an instance of AutoscaleSettingsOperations. + public virtual AutoscaleSettingsOperations AutoscaleSettings => new AutoscaleSettingsOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of Operations. + public virtual Operations Operations => new Operations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of AlertRuleIncidentsOperations. + public virtual AlertRuleIncidentsOperations AlertRuleIncidents => new AlertRuleIncidentsOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of AlertRulesOperations. + public virtual AlertRulesOperations AlertRules => new AlertRulesOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of LogProfilesOperations. + public virtual LogProfilesOperations LogProfiles => new LogProfilesOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of DiagnosticSettingsOperations. + public virtual DiagnosticSettingsOperations DiagnosticSettings => new DiagnosticSettingsOperations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of DiagnosticSettingsCategoryOperations. + public virtual DiagnosticSettingsCategoryOperations DiagnosticSettingsCategory => new DiagnosticSettingsCategoryOperations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of ActionGroupsOperations. + public virtual ActionGroupsOperations ActionGroups => new ActionGroupsOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of ActivityLogAlertsOperations. + public virtual ActivityLogAlertsOperations ActivityLogAlerts => new ActivityLogAlertsOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of ActivityLogsOperations. + public virtual ActivityLogsOperations ActivityLogs => new ActivityLogsOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of EventCategoriesOperations. + public virtual EventCategoriesOperations EventCategories => new EventCategoriesOperations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of TenantActivityLogsOperations. + public virtual TenantActivityLogsOperations TenantActivityLogs => new TenantActivityLogsOperations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of MetricDefinitionsOperations. + public virtual MetricDefinitionsOperations MetricDefinitions => new MetricDefinitionsOperations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of MetricsOperations. + public virtual MetricsOperations Metrics => new MetricsOperations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of MetricBaselineOperations. + public virtual MetricBaselineOperations MetricBaseline => new MetricBaselineOperations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of BaselinesOperations. + public virtual BaselinesOperations Baselines => new BaselinesOperations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of MetricAlertsOperations. + public virtual MetricAlertsOperations MetricAlerts => new MetricAlertsOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of MetricAlertsStatusOperations. + public virtual MetricAlertsStatusOperations MetricAlertsStatus => new MetricAlertsStatusOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of ScheduledQueryRulesOperations. + public virtual ScheduledQueryRulesOperations ScheduledQueryRules => new ScheduledQueryRulesOperations(_clientDiagnostics, _pipeline, _subscriptionId, _endpoint); + + /// Returns an instance of MetricNamespacesOperations. + public virtual MetricNamespacesOperations MetricNamespaces => new MetricNamespacesOperations(_clientDiagnostics, _pipeline, _endpoint); + + /// Returns an instance of VMInsightsOperations. + public virtual VMInsightsOperations VMInsights => new VMInsightsOperations(_clientDiagnostics, _pipeline, _endpoint); + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/InsightsManagementClientOptions.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/InsightsManagementClientOptions.cs new file mode 100644 index 000000000000..e48f6dc32589 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/InsightsManagementClientOptions.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.Insights +{ + /// Client options for Insights. + public class InsightsManagementClientOptions : ClientOptions + { + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/LogProfilesOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/LogProfilesOperations.cs new file mode 100644 index 000000000000..cf9468efb5b6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/LogProfilesOperations.cs @@ -0,0 +1,232 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The LogProfiles service client. + public partial class LogProfilesOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal LogProfilesRestOperations RestClient { get; } + /// Initializes a new instance of LogProfilesOperations for mocking. + protected LogProfilesOperations() + { + } + /// Initializes a new instance of LogProfilesOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal LogProfilesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new LogProfilesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Deletes the log profile. + /// The name of the log profile. + /// The cancellation token to use. + public virtual async Task DeleteAsync(string logProfileName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.Delete"); + scope.Start(); + try + { + return await RestClient.DeleteAsync(logProfileName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes the log profile. + /// The name of the log profile. + /// The cancellation token to use. + public virtual Response Delete(string logProfileName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.Delete"); + scope.Start(); + try + { + return RestClient.Delete(logProfileName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the log profile. + /// The name of the log profile. + /// The cancellation token to use. + public virtual async Task> GetAsync(string logProfileName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(logProfileName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the log profile. + /// The name of the log profile. + /// The cancellation token to use. + public virtual Response Get(string logProfileName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(logProfileName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create or update a log profile in Azure Monitoring REST API. + /// The name of the log profile. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateAsync(string logProfileName, LogProfileResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.CreateOrUpdate"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateAsync(logProfileName, parameters, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create or update a log profile in Azure Monitoring REST API. + /// The name of the log profile. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual Response CreateOrUpdate(string logProfileName, LogProfileResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.CreateOrUpdate"); + scope.Start(); + try + { + return RestClient.CreateOrUpdate(logProfileName, parameters, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + /// The name of the log profile. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(string logProfileName, LogProfileResourcePatch logProfilesResource, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.Update"); + scope.Start(); + try + { + return await RestClient.UpdateAsync(logProfileName, logProfilesResource, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + /// The name of the log profile. + /// Parameters supplied to the operation. + /// The cancellation token to use. + public virtual Response Update(string logProfileName, LogProfileResourcePatch logProfilesResource, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.Update"); + scope.Start(); + try + { + return RestClient.Update(logProfileName, logProfilesResource, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the log profiles. + /// The cancellation token to use. + public virtual AsyncPageable ListAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.List"); + scope.Start(); + try + { + var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// List the log profiles. + /// The cancellation token to use. + public virtual Pageable List(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("LogProfilesOperations.List"); + scope.Start(); + try + { + var response = RestClient.List(cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/LogProfilesRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/LogProfilesRestOperations.cs new file mode 100644 index 000000000000..6ae1dc83d17f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/LogProfilesRestOperations.cs @@ -0,0 +1,399 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class LogProfilesRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of LogProfilesRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public LogProfilesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateDeleteRequest(string logProfileName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/logprofiles/", false); + uri.AppendPath(logProfileName, true); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + return message; + } + + /// Deletes the log profile. + /// The name of the log profile. + /// The cancellation token to use. + /// is null. + public async Task DeleteAsync(string logProfileName, CancellationToken cancellationToken = default) + { + if (logProfileName == null) + { + throw new ArgumentNullException(nameof(logProfileName)); + } + + using var message = CreateDeleteRequest(logProfileName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Deletes the log profile. + /// The name of the log profile. + /// The cancellation token to use. + /// is null. + public Response Delete(string logProfileName, CancellationToken cancellationToken = default) + { + if (logProfileName == null) + { + throw new ArgumentNullException(nameof(logProfileName)); + } + + using var message = CreateDeleteRequest(logProfileName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string logProfileName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/logprofiles/", false); + uri.AppendPath(logProfileName, true); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + return message; + } + + /// Gets the log profile. + /// The name of the log profile. + /// The cancellation token to use. + /// is null. + public async Task> GetAsync(string logProfileName, CancellationToken cancellationToken = default) + { + if (logProfileName == null) + { + throw new ArgumentNullException(nameof(logProfileName)); + } + + using var message = CreateGetRequest(logProfileName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogProfileResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogProfileResource.DeserializeLogProfileResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the log profile. + /// The name of the log profile. + /// The cancellation token to use. + /// is null. + public Response Get(string logProfileName, CancellationToken cancellationToken = default) + { + if (logProfileName == null) + { + throw new ArgumentNullException(nameof(logProfileName)); + } + + using var message = CreateGetRequest(logProfileName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogProfileResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogProfileResource.DeserializeLogProfileResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string logProfileName, LogProfileResource parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/logprofiles/", false); + uri.AppendPath(logProfileName, true); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + return message; + } + + /// Create or update a log profile in Azure Monitoring REST API. + /// The name of the log profile. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// or is null. + public async Task> CreateOrUpdateAsync(string logProfileName, LogProfileResource parameters, CancellationToken cancellationToken = default) + { + if (logProfileName == null) + { + throw new ArgumentNullException(nameof(logProfileName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(logProfileName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogProfileResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogProfileResource.DeserializeLogProfileResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Create or update a log profile in Azure Monitoring REST API. + /// The name of the log profile. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// or is null. + public Response CreateOrUpdate(string logProfileName, LogProfileResource parameters, CancellationToken cancellationToken = default) + { + if (logProfileName == null) + { + throw new ArgumentNullException(nameof(logProfileName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(logProfileName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogProfileResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogProfileResource.DeserializeLogProfileResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string logProfileName, LogProfileResourcePatch logProfilesResource) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/logprofiles/", false); + uri.AppendPath(logProfileName, true); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(logProfilesResource); + request.Content = content; + return message; + } + + /// Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + /// The name of the log profile. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// or is null. + public async Task> UpdateAsync(string logProfileName, LogProfileResourcePatch logProfilesResource, CancellationToken cancellationToken = default) + { + if (logProfileName == null) + { + throw new ArgumentNullException(nameof(logProfileName)); + } + if (logProfilesResource == null) + { + throw new ArgumentNullException(nameof(logProfilesResource)); + } + + using var message = CreateUpdateRequest(logProfileName, logProfilesResource); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogProfileResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogProfileResource.DeserializeLogProfileResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + /// The name of the log profile. + /// Parameters supplied to the operation. + /// The cancellation token to use. + /// or is null. + public Response Update(string logProfileName, LogProfileResourcePatch logProfilesResource, CancellationToken cancellationToken = default) + { + if (logProfileName == null) + { + throw new ArgumentNullException(nameof(logProfileName)); + } + if (logProfilesResource == null) + { + throw new ArgumentNullException(nameof(logProfilesResource)); + } + + using var message = CreateUpdateRequest(logProfileName, logProfilesResource); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogProfileResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogProfileResource.DeserializeLogProfileResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/logprofiles", false); + uri.AppendQuery("api-version", "2016-03-01", true); + request.Uri = uri; + return message; + } + + /// List the log profiles. + /// The cancellation token to use. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogProfileCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogProfileCollection.DeserializeLogProfileCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// List the log profiles. + /// The cancellation token to use. + public Response List(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogProfileCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogProfileCollection.DeserializeLogProfileCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsOperations.cs new file mode 100644 index 000000000000..ae3ffd67aaf6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsOperations.cs @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The MetricAlerts service client. + public partial class MetricAlertsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal MetricAlertsRestOperations RestClient { get; } + /// Initializes a new instance of MetricAlertsOperations for mocking. + protected MetricAlertsOperations() + { + } + /// Initializes a new instance of MetricAlertsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal MetricAlertsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new MetricAlertsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Retrieve an alert rule definition. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceGroupName, ruleName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieve an alert rule definition. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual Response Get(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceGroupName, ruleName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create or update an metric alert definition. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateAsync(string resourceGroupName, string ruleName, MetricAlertResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateAsync(resourceGroupName, ruleName, parameters, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create or update an metric alert definition. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + public virtual Response CreateOrUpdate(string resourceGroupName, string ruleName, MetricAlertResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.CreateOrUpdate"); + scope.Start(); + try + { + return RestClient.CreateOrUpdate(resourceGroupName, ruleName, parameters, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Update an metric alert definition. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to update. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.Update"); + scope.Start(); + try + { + return await RestClient.UpdateAsync(resourceGroupName, ruleName, parameters, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Update an metric alert definition. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to update. + /// The cancellation token to use. + public virtual Response Update(string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.Update"); + scope.Start(); + try + { + return RestClient.Update(resourceGroupName, ruleName, parameters, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete an alert rule definition. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual async Task DeleteAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.Delete"); + scope.Start(); + try + { + return await RestClient.DeleteAsync(resourceGroupName, ruleName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete an alert rule definition. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual Response Delete(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.Delete"); + scope.Start(); + try + { + return RestClient.Delete(resourceGroupName, ruleName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieve alert rule definitions in a subscription. + /// The cancellation token to use. + public virtual AsyncPageable ListBySubscriptionAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.ListBySubscription"); + scope.Start(); + try + { + var response = await RestClient.ListBySubscriptionAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Retrieve alert rule definitions in a subscription. + /// The cancellation token to use. + public virtual Pageable ListBySubscription(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.ListBySubscription"); + scope.Start(); + try + { + var response = RestClient.ListBySubscription(cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + + /// Retrieve alert rule definitions in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Retrieve alert rule definitions in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public virtual Pageable ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsRestOperations.cs new file mode 100644 index 000000000000..9c9b619de552 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsRestOperations.cs @@ -0,0 +1,520 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class MetricAlertsRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of MetricAlertsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public MetricAlertsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListBySubscriptionRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Insights/metricAlerts", false); + uri.AppendQuery("api-version", "2018-03-01", true); + request.Uri = uri; + return message; + } + + /// Retrieve alert rule definitions in a subscription. + /// The cancellation token to use. + public async Task> ListBySubscriptionAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricAlertResourceCollection.DeserializeMetricAlertResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Retrieve alert rule definitions in a subscription. + /// The cancellation token to use. + public Response ListBySubscription(CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricAlertResourceCollection.DeserializeMetricAlertResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Insights/metricAlerts", false); + uri.AppendQuery("api-version", "2018-03-01", true); + request.Uri = uri; + return message; + } + + /// Retrieve alert rule definitions in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public async Task> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricAlertResourceCollection.DeserializeMetricAlertResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Retrieve alert rule definitions in a resource group. + /// The name of the resource group. + /// The cancellation token to use. + /// is null. + public Response ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricAlertResourceCollection.DeserializeMetricAlertResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string resourceGroupName, string ruleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Insights/metricAlerts/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2018-03-01", true); + request.Uri = uri; + return message; + } + + /// Retrieve an alert rule definition. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public async Task> GetAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateGetRequest(resourceGroupName, ruleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricAlertResource.DeserializeMetricAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Retrieve an alert rule definition. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public Response Get(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateGetRequest(resourceGroupName, ruleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricAlertResource.DeserializeMetricAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string ruleName, MetricAlertResource parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Insights/metricAlerts/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2018-03-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + return message; + } + + /// Create or update an metric alert definition. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + /// , , or is null. + public async Task> CreateOrUpdateAsync(string resourceGroupName, string ruleName, MetricAlertResource parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, ruleName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricAlertResource.DeserializeMetricAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Create or update an metric alert definition. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + /// , , or is null. + public Response CreateOrUpdate(string resourceGroupName, string ruleName, MetricAlertResource parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, ruleName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricAlertResource.DeserializeMetricAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Insights/metricAlerts/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2018-03-01", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + return message; + } + + /// Update an metric alert definition. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to update. + /// The cancellation token to use. + /// , , or is null. + public async Task> UpdateAsync(string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateUpdateRequest(resourceGroupName, ruleName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricAlertResource.DeserializeMetricAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Update an metric alert definition. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to update. + /// The cancellation token to use. + /// , , or is null. + public Response Update(string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateUpdateRequest(resourceGroupName, ruleName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricAlertResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricAlertResource.DeserializeMetricAlertResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string resourceGroupName, string ruleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Insights/metricAlerts/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2018-03-01", true); + request.Uri = uri; + return message; + } + + /// Delete an alert rule definition. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public async Task DeleteAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, ruleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Delete an alert rule definition. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public Response Delete(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, ruleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsStatusOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsStatusOperations.cs new file mode 100644 index 000000000000..ec68874879be --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsStatusOperations.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The MetricAlertsStatus service client. + public partial class MetricAlertsStatusOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal MetricAlertsStatusRestOperations RestClient { get; } + /// Initializes a new instance of MetricAlertsStatusOperations for mocking. + protected MetricAlertsStatusOperations() + { + } + /// Initializes a new instance of MetricAlertsStatusOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal MetricAlertsStatusOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new MetricAlertsStatusRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Retrieve an alert rule status. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual async Task> ListAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsStatusOperations.List"); + scope.Start(); + try + { + return await RestClient.ListAsync(resourceGroupName, ruleName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieve an alert rule status. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual Response List(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsStatusOperations.List"); + scope.Start(); + try + { + return RestClient.List(resourceGroupName, ruleName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieve an alert rule status. + /// The name of the resource group. + /// The name of the rule. + /// The name of the status. + /// The cancellation token to use. + public virtual async Task> ListByNameAsync(string resourceGroupName, string ruleName, string statusName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsStatusOperations.ListByName"); + scope.Start(); + try + { + return await RestClient.ListByNameAsync(resourceGroupName, ruleName, statusName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieve an alert rule status. + /// The name of the resource group. + /// The name of the rule. + /// The name of the status. + /// The cancellation token to use. + public virtual Response ListByName(string resourceGroupName, string ruleName, string statusName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricAlertsStatusOperations.ListByName"); + scope.Start(); + try + { + return RestClient.ListByName(resourceGroupName, ruleName, statusName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsStatusRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsStatusRestOperations.cs new file mode 100644 index 000000000000..1c79a9da19f9 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricAlertsStatusRestOperations.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class MetricAlertsStatusRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of MetricAlertsStatusRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public MetricAlertsStatusRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListRequest(string resourceGroupName, string ruleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Insights/metricAlerts/", false); + uri.AppendPath(ruleName, true); + uri.AppendPath("/status", false); + uri.AppendQuery("api-version", "2018-03-01", true); + request.Uri = uri; + return message; + } + + /// Retrieve an alert rule status. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public async Task> ListAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateListRequest(resourceGroupName, ruleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricAlertStatusCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricAlertStatusCollection.DeserializeMetricAlertStatusCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Retrieve an alert rule status. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public Response List(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateListRequest(resourceGroupName, ruleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricAlertStatusCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricAlertStatusCollection.DeserializeMetricAlertStatusCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByNameRequest(string resourceGroupName, string ruleName, string statusName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Insights/metricAlerts/", false); + uri.AppendPath(ruleName, true); + uri.AppendPath("/status/", false); + uri.AppendPath(statusName, true); + uri.AppendQuery("api-version", "2018-03-01", true); + request.Uri = uri; + return message; + } + + /// Retrieve an alert rule status. + /// The name of the resource group. + /// The name of the rule. + /// The name of the status. + /// The cancellation token to use. + /// , , or is null. + public async Task> ListByNameAsync(string resourceGroupName, string ruleName, string statusName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (statusName == null) + { + throw new ArgumentNullException(nameof(statusName)); + } + + using var message = CreateListByNameRequest(resourceGroupName, ruleName, statusName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricAlertStatusCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricAlertStatusCollection.DeserializeMetricAlertStatusCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Retrieve an alert rule status. + /// The name of the resource group. + /// The name of the rule. + /// The name of the status. + /// The cancellation token to use. + /// , , or is null. + public Response ListByName(string resourceGroupName, string ruleName, string statusName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (statusName == null) + { + throw new ArgumentNullException(nameof(statusName)); + } + + using var message = CreateListByNameRequest(resourceGroupName, ruleName, statusName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricAlertStatusCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricAlertStatusCollection.DeserializeMetricAlertStatusCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricBaselineOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricBaselineOperations.cs new file mode 100644 index 000000000000..73d6c538c333 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricBaselineOperations.cs @@ -0,0 +1,124 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The MetricBaseline service client. + public partial class MetricBaselineOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal MetricBaselineRestOperations RestClient { get; } + /// Initializes a new instance of MetricBaselineOperations for mocking. + protected MetricBaselineOperations() + { + } + /// Initializes a new instance of MetricBaselineOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal MetricBaselineOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new MetricBaselineRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// **Gets the baseline values for a specific metric**. + /// The identifier of the resource. It has the following structure: subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. + /// The name of the metric to retrieve the baseline for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The aggregation type of the metric to retrieve the baseline for. + /// The list of sensitivities (comma separated) to retrieve. + /// Allows retrieving only metadata of the baseline. On data request all information is retrieved. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceUri, string metricName, string timespan = null, TimeSpan? interval = null, string aggregation = null, string sensitivities = null, ResultType? resultType = null, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricBaselineOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceUri, metricName, timespan, interval, aggregation, sensitivities, resultType, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// **Gets the baseline values for a specific metric**. + /// The identifier of the resource. It has the following structure: subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. + /// The name of the metric to retrieve the baseline for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The aggregation type of the metric to retrieve the baseline for. + /// The list of sensitivities (comma separated) to retrieve. + /// Allows retrieving only metadata of the baseline. On data request all information is retrieved. + /// The cancellation token to use. + public virtual Response Get(string resourceUri, string metricName, string timespan = null, TimeSpan? interval = null, string aggregation = null, string sensitivities = null, ResultType? resultType = null, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricBaselineOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceUri, metricName, timespan, interval, aggregation, sensitivities, resultType, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// **Lists the baseline values for a resource**. + /// The identifier of the resource. It has the following structure: subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. + /// Information that need to be specified to calculate a baseline on a time series. + /// The cancellation token to use. + public virtual async Task> CalculateBaselineAsync(string resourceUri, TimeSeriesInformation timeSeriesInformation, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricBaselineOperations.CalculateBaseline"); + scope.Start(); + try + { + return await RestClient.CalculateBaselineAsync(resourceUri, timeSeriesInformation, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// **Lists the baseline values for a resource**. + /// The identifier of the resource. It has the following structure: subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. + /// Information that need to be specified to calculate a baseline on a time series. + /// The cancellation token to use. + public virtual Response CalculateBaseline(string resourceUri, TimeSeriesInformation timeSeriesInformation, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricBaselineOperations.CalculateBaseline"); + scope.Start(); + try + { + return RestClient.CalculateBaseline(resourceUri, timeSeriesInformation, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricBaselineRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricBaselineRestOperations.cs new file mode 100644 index 000000000000..75c59b9ab82a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricBaselineRestOperations.cs @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class MetricBaselineRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of MetricBaselineRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public MetricBaselineRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateGetRequest(string resourceUri, string metricName, string timespan, TimeSpan? interval, string aggregation, string sensitivities, ResultType? resultType) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/baseline/", false); + uri.AppendPath(metricName, true); + if (timespan != null) + { + uri.AppendQuery("timespan", timespan, true); + } + if (interval != null) + { + uri.AppendQuery("interval", interval.Value, "P", true); + } + if (aggregation != null) + { + uri.AppendQuery("aggregation", aggregation, true); + } + if (sensitivities != null) + { + uri.AppendQuery("sensitivities", sensitivities, true); + } + if (resultType != null) + { + uri.AppendQuery("resultType", resultType.Value.ToSerialString(), true); + } + uri.AppendQuery("api-version", "2017-11-01-preview", true); + request.Uri = uri; + return message; + } + + /// **Gets the baseline values for a specific metric**. + /// The identifier of the resource. It has the following structure: subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. + /// The name of the metric to retrieve the baseline for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The aggregation type of the metric to retrieve the baseline for. + /// The list of sensitivities (comma separated) to retrieve. + /// Allows retrieving only metadata of the baseline. On data request all information is retrieved. + /// The cancellation token to use. + /// or is null. + public async Task> GetAsync(string resourceUri, string metricName, string timespan = null, TimeSpan? interval = null, string aggregation = null, string sensitivities = null, ResultType? resultType = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (metricName == null) + { + throw new ArgumentNullException(nameof(metricName)); + } + + using var message = CreateGetRequest(resourceUri, metricName, timespan, interval, aggregation, sensitivities, resultType); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BaselineResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BaselineResponse.DeserializeBaselineResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// **Gets the baseline values for a specific metric**. + /// The identifier of the resource. It has the following structure: subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. + /// The name of the metric to retrieve the baseline for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The aggregation type of the metric to retrieve the baseline for. + /// The list of sensitivities (comma separated) to retrieve. + /// Allows retrieving only metadata of the baseline. On data request all information is retrieved. + /// The cancellation token to use. + /// or is null. + public Response Get(string resourceUri, string metricName, string timespan = null, TimeSpan? interval = null, string aggregation = null, string sensitivities = null, ResultType? resultType = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (metricName == null) + { + throw new ArgumentNullException(nameof(metricName)); + } + + using var message = CreateGetRequest(resourceUri, metricName, timespan, interval, aggregation, sensitivities, resultType); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BaselineResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BaselineResponse.DeserializeBaselineResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCalculateBaselineRequest(string resourceUri, TimeSeriesInformation timeSeriesInformation) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/calculatebaseline", false); + uri.AppendQuery("api-version", "2017-11-01-preview", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(timeSeriesInformation); + request.Content = content; + return message; + } + + /// **Lists the baseline values for a resource**. + /// The identifier of the resource. It has the following structure: subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. + /// Information that need to be specified to calculate a baseline on a time series. + /// The cancellation token to use. + /// or is null. + public async Task> CalculateBaselineAsync(string resourceUri, TimeSeriesInformation timeSeriesInformation, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (timeSeriesInformation == null) + { + throw new ArgumentNullException(nameof(timeSeriesInformation)); + } + + using var message = CreateCalculateBaselineRequest(resourceUri, timeSeriesInformation); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CalculateBaselineResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CalculateBaselineResponse.DeserializeCalculateBaselineResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// **Lists the baseline values for a resource**. + /// The identifier of the resource. It has the following structure: subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. + /// Information that need to be specified to calculate a baseline on a time series. + /// The cancellation token to use. + /// or is null. + public Response CalculateBaseline(string resourceUri, TimeSeriesInformation timeSeriesInformation, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + if (timeSeriesInformation == null) + { + throw new ArgumentNullException(nameof(timeSeriesInformation)); + } + + using var message = CreateCalculateBaselineRequest(resourceUri, timeSeriesInformation); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CalculateBaselineResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CalculateBaselineResponse.DeserializeCalculateBaselineResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricDefinitionsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricDefinitionsOperations.cs new file mode 100644 index 000000000000..a9990c252c35 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricDefinitionsOperations.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The MetricDefinitions service client. + public partial class MetricDefinitionsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal MetricDefinitionsRestOperations RestClient { get; } + /// Initializes a new instance of MetricDefinitionsOperations for mocking. + protected MetricDefinitionsOperations() + { + } + /// Initializes a new instance of MetricDefinitionsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal MetricDefinitionsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new MetricDefinitionsRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Lists the metric definitions for the resource. + /// The identifier of the resource. + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListAsync(string resourceUri, string metricnamespace = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("MetricDefinitionsOperations.List"); + scope.Start(); + try + { + var response = await RestClient.ListAsync(resourceUri, metricnamespace, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Lists the metric definitions for the resource. + /// The identifier of the resource. + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// is null. + public virtual Pageable List(string resourceUri, string metricnamespace = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("MetricDefinitionsOperations.List"); + scope.Start(); + try + { + var response = RestClient.List(resourceUri, metricnamespace, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricDefinitionsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricDefinitionsRestOperations.cs new file mode 100644 index 000000000000..d3e36d026d91 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricDefinitionsRestOperations.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class MetricDefinitionsRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of MetricDefinitionsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public MetricDefinitionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListRequest(string resourceUri, string metricnamespace) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/metricDefinitions", false); + uri.AppendQuery("api-version", "2018-01-01", true); + if (metricnamespace != null) + { + uri.AppendQuery("metricnamespace", metricnamespace, true); + } + request.Uri = uri; + return message; + } + + /// Lists the metric definitions for the resource. + /// The identifier of the resource. + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, string metricnamespace = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri, metricnamespace); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricDefinitionCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricDefinitionCollection.DeserializeMetricDefinitionCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Lists the metric definitions for the resource. + /// The identifier of the resource. + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, string metricnamespace = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri, metricnamespace); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricDefinitionCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricDefinitionCollection.DeserializeMetricDefinitionCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricNamespacesOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricNamespacesOperations.cs new file mode 100644 index 000000000000..9814500c513e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricNamespacesOperations.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The MetricNamespaces service client. + public partial class MetricNamespacesOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal MetricNamespacesRestOperations RestClient { get; } + /// Initializes a new instance of MetricNamespacesOperations for mocking. + protected MetricNamespacesOperations() + { + } + /// Initializes a new instance of MetricNamespacesOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal MetricNamespacesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new MetricNamespacesRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Lists the metric namespaces for the resource. + /// The identifier of the resource. + /// The ISO 8601 conform Date start time from which to query for metric namespaces. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListAsync(string resourceUri, string startTime = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("MetricNamespacesOperations.List"); + scope.Start(); + try + { + var response = await RestClient.ListAsync(resourceUri, startTime, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// Lists the metric namespaces for the resource. + /// The identifier of the resource. + /// The ISO 8601 conform Date start time from which to query for metric namespaces. + /// The cancellation token to use. + /// is null. + public virtual Pageable List(string resourceUri, string startTime = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("MetricNamespacesOperations.List"); + scope.Start(); + try + { + var response = RestClient.List(resourceUri, startTime, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricNamespacesRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricNamespacesRestOperations.cs new file mode 100644 index 000000000000..8fd7a8425dbb --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricNamespacesRestOperations.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class MetricNamespacesRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of MetricNamespacesRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public MetricNamespacesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListRequest(string resourceUri, string startTime) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/metricNamespaces", false); + uri.AppendQuery("api-version", "2017-12-01-preview", true); + if (startTime != null) + { + uri.AppendQuery("startTime", startTime, true); + } + request.Uri = uri; + return message; + } + + /// Lists the metric namespaces for the resource. + /// The identifier of the resource. + /// The ISO 8601 conform Date start time from which to query for metric namespaces. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, string startTime = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri, startTime); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricNamespaceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricNamespaceCollection.DeserializeMetricNamespaceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Lists the metric namespaces for the resource. + /// The identifier of the resource. + /// The ISO 8601 conform Date start time from which to query for metric namespaces. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, string startTime = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri, startTime); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricNamespaceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricNamespaceCollection.DeserializeMetricNamespaceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricsOperations.cs new file mode 100644 index 000000000000..02d7ff23180b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricsOperations.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The Metrics service client. + public partial class MetricsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal MetricsRestOperations RestClient { get; } + /// Initializes a new instance of MetricsOperations for mocking. + protected MetricsOperations() + { + } + /// Initializes a new instance of MetricsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal MetricsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new MetricsRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// **Lists the metric values for a resource**. + /// The identifier of the resource. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The names of the metrics (comma separated) to retrieve. + /// The list of aggregation types (comma separated) to retrieve. + /// + /// The maximum number of records to retrieve. + /// Valid only if $filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// Examples: sum asc. + /// + /// The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + public virtual async Task> ListAsync(string resourceUri, string timespan = null, TimeSpan? interval = null, string metricnames = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, ResultType? resultType = null, string metricnamespace = null, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricsOperations.List"); + scope.Start(); + try + { + return await RestClient.ListAsync(resourceUri, timespan, interval, metricnames, aggregation, top, orderby, filter, resultType, metricnamespace, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// **Lists the metric values for a resource**. + /// The identifier of the resource. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The names of the metrics (comma separated) to retrieve. + /// The list of aggregation types (comma separated) to retrieve. + /// + /// The maximum number of records to retrieve. + /// Valid only if $filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// Examples: sum asc. + /// + /// The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + public virtual Response List(string resourceUri, string timespan = null, TimeSpan? interval = null, string metricnames = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, ResultType? resultType = null, string metricnamespace = null, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("MetricsOperations.List"); + scope.Start(); + try + { + return RestClient.List(resourceUri, timespan, interval, metricnames, aggregation, top, orderby, filter, resultType, metricnamespace, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricsRestOperations.cs new file mode 100644 index 000000000000..8cab4801d88f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/MetricsRestOperations.cs @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class MetricsRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of MetricsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public MetricsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListRequest(string resourceUri, string timespan, TimeSpan? interval, string metricnames, string aggregation, int? top, string orderby, string filter, ResultType? resultType, string metricnamespace) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/microsoft.insights/metrics", false); + if (timespan != null) + { + uri.AppendQuery("timespan", timespan, true); + } + if (interval != null) + { + uri.AppendQuery("interval", interval.Value, "P", true); + } + if (metricnames != null) + { + uri.AppendQuery("metricnames", metricnames, true); + } + if (aggregation != null) + { + uri.AppendQuery("aggregation", aggregation, true); + } + if (top != null) + { + uri.AppendQuery("top", top.Value, true); + } + if (orderby != null) + { + uri.AppendQuery("orderby", orderby, true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (resultType != null) + { + uri.AppendQuery("resultType", resultType.Value.ToSerialString(), true); + } + uri.AppendQuery("api-version", "2018-01-01", true); + if (metricnamespace != null) + { + uri.AppendQuery("metricnamespace", metricnamespace, true); + } + request.Uri = uri; + return message; + } + + /// **Lists the metric values for a resource**. + /// The identifier of the resource. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The names of the metrics (comma separated) to retrieve. + /// The list of aggregation types (comma separated) to retrieve. + /// + /// The maximum number of records to retrieve. + /// Valid only if $filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// Examples: sum asc. + /// + /// The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, string timespan = null, TimeSpan? interval = null, string metricnames = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, ResultType? resultType = null, string metricnamespace = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri, timespan, interval, metricnames, aggregation, top, orderby, filter, resultType, metricnamespace); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Models.Response value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Models.Response.DeserializeResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// **Lists the metric values for a resource**. + /// The identifier of the resource. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The names of the metrics (comma separated) to retrieve. + /// The list of aggregation types (comma separated) to retrieve. + /// + /// The maximum number of records to retrieve. + /// Valid only if $filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// Examples: sum asc. + /// + /// The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, string timespan = null, TimeSpan? interval = null, string metricnames = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, ResultType? resultType = null, string metricnamespace = null, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateListRequest(resourceUri, timespan, interval, metricnames, aggregation, top, orderby, filter, resultType, metricnamespace); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Models.Response value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Models.Response.DeserializeResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Action.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Action.Serialization.cs new file mode 100644 index 000000000000..6bfbec477cd1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Action.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Action : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + writer.WriteEndObject(); + } + + internal static Action DeserializeAction(JsonElement element) + { + if (element.TryGetProperty("odata.type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction": return AlertingAction.DeserializeAlertingAction(element); + case "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction": return LogToMetricAction.DeserializeLogToMetricAction(element); + } + } + string odataType = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + } + return new Action(odataType); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Action.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Action.cs new file mode 100644 index 000000000000..4a67d85a13fe --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Action.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Action descriptor. + public partial class Action + { + /// Initializes a new instance of Action. + public Action() + { + } + + /// Initializes a new instance of Action. + /// Specifies the action. Supported values - AlertingAction, LogToMetricAction. + internal Action(string odataType) + { + OdataType = odataType; + } + + /// Specifies the action. Supported values - AlertingAction, LogToMetricAction. + internal string OdataType { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupList.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupList.Serialization.cs new file mode 100644 index 000000000000..d83337d54fc7 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupList.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActionGroupList + { + internal static ActionGroupList DeserializeActionGroupList(JsonElement element) + { + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ActionGroupResource.DeserializeActionGroupResource(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new ActionGroupList(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupList.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupList.cs new file mode 100644 index 000000000000..3f8fd2063399 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupList.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A list of action groups. + public partial class ActionGroupList + { + /// Initializes a new instance of ActionGroupList. + internal ActionGroupList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of ActionGroupList. + /// The list of action groups. + /// Provides the link to retrieve the next set of elements. + internal ActionGroupList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The list of action groups. + public IReadOnlyList Value { get; } + /// Provides the link to retrieve the next set of elements. + public string NextLink { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupPatchBody.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupPatchBody.Serialization.cs new file mode 100644 index 000000000000..2e4c2a217eaf --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupPatchBody.Serialization.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActionGroupPatchBody : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled.Value); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupPatchBody.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupPatchBody.cs new file mode 100644 index 000000000000..05021d4ebfa4 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupPatchBody.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An action group object for the body of patch operations. + public partial class ActionGroupPatchBody + { + /// Initializes a new instance of ActionGroupPatchBody. + public ActionGroupPatchBody() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Resource tags. + public IDictionary Tags { get; } + /// Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. + public bool? Enabled { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupResource.Serialization.cs new file mode 100644 index 000000000000..3533720db6a2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupResource.Serialization.cs @@ -0,0 +1,320 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActionGroupResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("location"); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(GroupShortName)) + { + writer.WritePropertyName("groupShortName"); + writer.WriteStringValue(GroupShortName); + } + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsCollectionDefined(EmailReceivers)) + { + writer.WritePropertyName("emailReceivers"); + writer.WriteStartArray(); + foreach (var item in EmailReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(SmsReceivers)) + { + writer.WritePropertyName("smsReceivers"); + writer.WriteStartArray(); + foreach (var item in SmsReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(WebhookReceivers)) + { + writer.WritePropertyName("webhookReceivers"); + writer.WriteStartArray(); + foreach (var item in WebhookReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ItsmReceivers)) + { + writer.WritePropertyName("itsmReceivers"); + writer.WriteStartArray(); + foreach (var item in ItsmReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AzureAppPushReceivers)) + { + writer.WritePropertyName("azureAppPushReceivers"); + writer.WriteStartArray(); + foreach (var item in AzureAppPushReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AutomationRunbookReceivers)) + { + writer.WritePropertyName("automationRunbookReceivers"); + writer.WriteStartArray(); + foreach (var item in AutomationRunbookReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(VoiceReceivers)) + { + writer.WritePropertyName("voiceReceivers"); + writer.WriteStartArray(); + foreach (var item in VoiceReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(LogicAppReceivers)) + { + writer.WritePropertyName("logicAppReceivers"); + writer.WriteStartArray(); + foreach (var item in LogicAppReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AzureFunctionReceivers)) + { + writer.WritePropertyName("azureFunctionReceivers"); + writer.WriteStartArray(); + foreach (var item in AzureFunctionReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ArmRoleReceivers)) + { + writer.WritePropertyName("armRoleReceivers"); + writer.WriteStartArray(); + foreach (var item in ArmRoleReceivers) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static ActionGroupResource DeserializeActionGroupResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + string location = default; + Optional> tags = default; + Optional groupShortName = default; + Optional enabled = default; + Optional> emailReceivers = default; + Optional> smsReceivers = default; + Optional> webhookReceivers = default; + Optional> itsmReceivers = default; + Optional> azureAppPushReceivers = default; + Optional> automationRunbookReceivers = default; + Optional> voiceReceivers = default; + Optional> logicAppReceivers = default; + Optional> azureFunctionReceivers = default; + Optional> armRoleReceivers = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location")) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("groupShortName")) + { + groupShortName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("enabled")) + { + enabled = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("emailReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(EmailReceiver.DeserializeEmailReceiver(item)); + } + emailReceivers = array; + continue; + } + if (property0.NameEquals("smsReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(SmsReceiver.DeserializeSmsReceiver(item)); + } + smsReceivers = array; + continue; + } + if (property0.NameEquals("webhookReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(WebhookReceiver.DeserializeWebhookReceiver(item)); + } + webhookReceivers = array; + continue; + } + if (property0.NameEquals("itsmReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(ItsmReceiver.DeserializeItsmReceiver(item)); + } + itsmReceivers = array; + continue; + } + if (property0.NameEquals("azureAppPushReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(AzureAppPushReceiver.DeserializeAzureAppPushReceiver(item)); + } + azureAppPushReceivers = array; + continue; + } + if (property0.NameEquals("automationRunbookReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(AutomationRunbookReceiver.DeserializeAutomationRunbookReceiver(item)); + } + automationRunbookReceivers = array; + continue; + } + if (property0.NameEquals("voiceReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(VoiceReceiver.DeserializeVoiceReceiver(item)); + } + voiceReceivers = array; + continue; + } + if (property0.NameEquals("logicAppReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(LogicAppReceiver.DeserializeLogicAppReceiver(item)); + } + logicAppReceivers = array; + continue; + } + if (property0.NameEquals("azureFunctionReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(AzureFunctionReceiver.DeserializeAzureFunctionReceiver(item)); + } + azureFunctionReceivers = array; + continue; + } + if (property0.NameEquals("armRoleReceivers")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(ArmRoleReceiver.DeserializeArmRoleReceiver(item)); + } + armRoleReceivers = array; + continue; + } + } + continue; + } + } + return new ActionGroupResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), groupShortName.Value, Optional.ToNullable(enabled), Optional.ToList(emailReceivers), Optional.ToList(smsReceivers), Optional.ToList(webhookReceivers), Optional.ToList(itsmReceivers), Optional.ToList(azureAppPushReceivers), Optional.ToList(automationRunbookReceivers), Optional.ToList(voiceReceivers), Optional.ToList(logicAppReceivers), Optional.ToList(azureFunctionReceivers), Optional.ToList(armRoleReceivers)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupResource.cs new file mode 100644 index 000000000000..ea3f454c8ad3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActionGroupResource.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An action group resource. + public partial class ActionGroupResource : Resource + { + /// Initializes a new instance of ActionGroupResource. + /// Resource location. + /// is null. + public ActionGroupResource(string location) : base(location) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + + EmailReceivers = new ChangeTrackingList(); + SmsReceivers = new ChangeTrackingList(); + WebhookReceivers = new ChangeTrackingList(); + ItsmReceivers = new ChangeTrackingList(); + AzureAppPushReceivers = new ChangeTrackingList(); + AutomationRunbookReceivers = new ChangeTrackingList(); + VoiceReceivers = new ChangeTrackingList(); + LogicAppReceivers = new ChangeTrackingList(); + AzureFunctionReceivers = new ChangeTrackingList(); + ArmRoleReceivers = new ChangeTrackingList(); + } + + /// Initializes a new instance of ActionGroupResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// Resource location. + /// Resource tags. + /// The short name of the action group. This will be used in SMS messages. + /// Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. + /// The list of email receivers that are part of this action group. + /// The list of SMS receivers that are part of this action group. + /// The list of webhook receivers that are part of this action group. + /// The list of ITSM receivers that are part of this action group. + /// The list of AzureAppPush receivers that are part of this action group. + /// The list of AutomationRunbook receivers that are part of this action group. + /// The list of voice receivers that are part of this action group. + /// The list of logic app receivers that are part of this action group. + /// The list of azure function receivers that are part of this action group. + /// The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. + internal ActionGroupResource(string id, string name, string type, string location, IDictionary tags, string groupShortName, bool? enabled, IList emailReceivers, IList smsReceivers, IList webhookReceivers, IList itsmReceivers, IList azureAppPushReceivers, IList automationRunbookReceivers, IList voiceReceivers, IList logicAppReceivers, IList azureFunctionReceivers, IList armRoleReceivers) : base(id, name, type, location, tags) + { + GroupShortName = groupShortName; + Enabled = enabled; + EmailReceivers = emailReceivers; + SmsReceivers = smsReceivers; + WebhookReceivers = webhookReceivers; + ItsmReceivers = itsmReceivers; + AzureAppPushReceivers = azureAppPushReceivers; + AutomationRunbookReceivers = automationRunbookReceivers; + VoiceReceivers = voiceReceivers; + LogicAppReceivers = logicAppReceivers; + AzureFunctionReceivers = azureFunctionReceivers; + ArmRoleReceivers = armRoleReceivers; + } + + /// The short name of the action group. This will be used in SMS messages. + public string GroupShortName { get; set; } + /// Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. + public bool? Enabled { get; set; } + /// The list of email receivers that are part of this action group. + public IList EmailReceivers { get; } + /// The list of SMS receivers that are part of this action group. + public IList SmsReceivers { get; } + /// The list of webhook receivers that are part of this action group. + public IList WebhookReceivers { get; } + /// The list of ITSM receivers that are part of this action group. + public IList ItsmReceivers { get; } + /// The list of AzureAppPush receivers that are part of this action group. + public IList AzureAppPushReceivers { get; } + /// The list of AutomationRunbook receivers that are part of this action group. + public IList AutomationRunbookReceivers { get; } + /// The list of voice receivers that are part of this action group. + public IList VoiceReceivers { get; } + /// The list of logic app receivers that are part of this action group. + public IList LogicAppReceivers { get; } + /// The list of azure function receivers that are part of this action group. + public IList AzureFunctionReceivers { get; } + /// The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. + public IList ArmRoleReceivers { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionGroup.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionGroup.Serialization.cs new file mode 100644 index 000000000000..bdbb5c8b1f9a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionGroup.Serialization.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActivityLogAlertActionGroup : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("actionGroupId"); + writer.WriteStringValue(ActionGroupId); + if (Optional.IsCollectionDefined(WebhookProperties)) + { + writer.WritePropertyName("webhookProperties"); + writer.WriteStartObject(); + foreach (var item in WebhookProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WriteEndObject(); + } + + internal static ActivityLogAlertActionGroup DeserializeActivityLogAlertActionGroup(JsonElement element) + { + string actionGroupId = default; + Optional> webhookProperties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("actionGroupId")) + { + actionGroupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("webhookProperties")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + webhookProperties = dictionary; + continue; + } + } + return new ActivityLogAlertActionGroup(actionGroupId, Optional.ToDictionary(webhookProperties)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionGroup.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionGroup.cs new file mode 100644 index 000000000000..7ba667941a88 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionGroup.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A pointer to an Azure Action Group. + public partial class ActivityLogAlertActionGroup + { + /// Initializes a new instance of ActivityLogAlertActionGroup. + /// The resourceId of the action group. This cannot be null or empty. + /// is null. + public ActivityLogAlertActionGroup(string actionGroupId) + { + if (actionGroupId == null) + { + throw new ArgumentNullException(nameof(actionGroupId)); + } + + ActionGroupId = actionGroupId; + WebhookProperties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of ActivityLogAlertActionGroup. + /// The resourceId of the action group. This cannot be null or empty. + /// the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + internal ActivityLogAlertActionGroup(string actionGroupId, IDictionary webhookProperties) + { + ActionGroupId = actionGroupId; + WebhookProperties = webhookProperties; + } + + /// The resourceId of the action group. This cannot be null or empty. + public string ActionGroupId { get; set; } + /// the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + public IDictionary WebhookProperties { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionList.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionList.Serialization.cs new file mode 100644 index 000000000000..64b15811e3be --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionList.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActivityLogAlertActionList : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(ActionGroups)) + { + writer.WritePropertyName("actionGroups"); + writer.WriteStartArray(); + foreach (var item in ActionGroups) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + internal static ActivityLogAlertActionList DeserializeActivityLogAlertActionList(JsonElement element) + { + Optional> actionGroups = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("actionGroups")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ActivityLogAlertActionGroup.DeserializeActivityLogAlertActionGroup(item)); + } + actionGroups = array; + continue; + } + } + return new ActivityLogAlertActionList(Optional.ToList(actionGroups)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionList.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionList.cs new file mode 100644 index 000000000000..e3e9a99905a3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertActionList.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A list of activity log alert actions. + public partial class ActivityLogAlertActionList + { + /// Initializes a new instance of ActivityLogAlertActionList. + public ActivityLogAlertActionList() + { + ActionGroups = new ChangeTrackingList(); + } + + /// Initializes a new instance of ActivityLogAlertActionList. + /// The list of activity log alerts. + internal ActivityLogAlertActionList(IList actionGroups) + { + ActionGroups = actionGroups; + } + + /// The list of activity log alerts. + public IList ActionGroups { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertAllOfCondition.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertAllOfCondition.Serialization.cs new file mode 100644 index 000000000000..25373cbc9f72 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertAllOfCondition.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActivityLogAlertAllOfCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("allOf"); + writer.WriteStartArray(); + foreach (var item in AllOf) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } + + internal static ActivityLogAlertAllOfCondition DeserializeActivityLogAlertAllOfCondition(JsonElement element) + { + IList allOf = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("allOf")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ActivityLogAlertLeafCondition.DeserializeActivityLogAlertLeafCondition(item)); + } + allOf = array; + continue; + } + } + return new ActivityLogAlertAllOfCondition(allOf); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertAllOfCondition.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertAllOfCondition.cs new file mode 100644 index 000000000000..3d38cbcc1b49 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertAllOfCondition.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An Activity Log alert condition that is met when all its member conditions are met. + public partial class ActivityLogAlertAllOfCondition + { + /// Initializes a new instance of ActivityLogAlertAllOfCondition. + /// The list of activity log alert conditions. + /// is null. + public ActivityLogAlertAllOfCondition(IEnumerable allOf) + { + if (allOf == null) + { + throw new ArgumentNullException(nameof(allOf)); + } + + AllOf = allOf.ToList(); + } + + /// Initializes a new instance of ActivityLogAlertAllOfCondition. + /// The list of activity log alert conditions. + internal ActivityLogAlertAllOfCondition(IList allOf) + { + AllOf = allOf; + } + + /// The list of activity log alert conditions. + public IList AllOf { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertLeafCondition.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertLeafCondition.Serialization.cs new file mode 100644 index 000000000000..1a758ab51ce1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertLeafCondition.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActivityLogAlertLeafCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("field"); + writer.WriteStringValue(Field); + writer.WritePropertyName("equals"); + writer.WriteStringValue(EqualsValue); + writer.WriteEndObject(); + } + + internal static ActivityLogAlertLeafCondition DeserializeActivityLogAlertLeafCondition(JsonElement element) + { + string field = default; + string @equals = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("field")) + { + field = property.Value.GetString(); + continue; + } + if (property.NameEquals("equals")) + { + @equals = property.Value.GetString(); + continue; + } + } + return new ActivityLogAlertLeafCondition(field, @equals); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertLeafCondition.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertLeafCondition.cs new file mode 100644 index 000000000000..a47dfd3459e0 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertLeafCondition.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An Activity Log alert condition that is met by comparing an activity log field and value. + public partial class ActivityLogAlertLeafCondition + { + /// Initializes a new instance of ActivityLogAlertLeafCondition. + /// The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties.'. + /// The field value will be compared to this value (case-insensitive) to determine if the condition is met. + /// or is null. + public ActivityLogAlertLeafCondition(string field, string equalsValue) + { + if (field == null) + { + throw new ArgumentNullException(nameof(field)); + } + if (equalsValue == null) + { + throw new ArgumentNullException(nameof(equalsValue)); + } + + Field = field; + EqualsValue = equalsValue; + } + + /// The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties.'. + public string Field { get; set; } + /// The field value will be compared to this value (case-insensitive) to determine if the condition is met. + public string EqualsValue { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertList.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertList.Serialization.cs new file mode 100644 index 000000000000..d8ef269d8362 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertList.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActivityLogAlertList + { + internal static ActivityLogAlertList DeserializeActivityLogAlertList(JsonElement element) + { + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ActivityLogAlertResource.DeserializeActivityLogAlertResource(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new ActivityLogAlertList(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertList.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertList.cs new file mode 100644 index 000000000000..0fd3e015c4d8 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertList.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A list of activity log alerts. + public partial class ActivityLogAlertList + { + /// Initializes a new instance of ActivityLogAlertList. + internal ActivityLogAlertList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of ActivityLogAlertList. + /// The list of activity log alerts. + /// Provides the link to retrieve the next set of elements. + internal ActivityLogAlertList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The list of activity log alerts. + public IReadOnlyList Value { get; } + /// Provides the link to retrieve the next set of elements. + public string NextLink { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertPatchBody.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertPatchBody.Serialization.cs new file mode 100644 index 000000000000..3469a65c4e9e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertPatchBody.Serialization.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActivityLogAlertPatchBody : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled.Value); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertPatchBody.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertPatchBody.cs new file mode 100644 index 000000000000..66e663d78814 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertPatchBody.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An activity log alert object for the body of patch operations. + public partial class ActivityLogAlertPatchBody + { + /// Initializes a new instance of ActivityLogAlertPatchBody. + public ActivityLogAlertPatchBody() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Resource tags. + public IDictionary Tags { get; } + /// Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. + public bool? Enabled { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertResource.Serialization.cs new file mode 100644 index 000000000000..56801d9ac276 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertResource.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ActivityLogAlertResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("location"); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Scopes)) + { + writer.WritePropertyName("scopes"); + writer.WriteStartArray(); + foreach (var item in Scopes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(Condition)) + { + writer.WritePropertyName("condition"); + writer.WriteObjectValue(Condition); + } + if (Optional.IsDefined(Actions)) + { + writer.WritePropertyName("actions"); + writer.WriteObjectValue(Actions); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"); + writer.WriteStringValue(Description); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static ActivityLogAlertResource DeserializeActivityLogAlertResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + string location = default; + Optional> tags = default; + Optional> scopes = default; + Optional enabled = default; + Optional condition = default; + Optional actions = default; + Optional description = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location")) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("scopes")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + scopes = array; + continue; + } + if (property0.NameEquals("enabled")) + { + enabled = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("condition")) + { + condition = ActivityLogAlertAllOfCondition.DeserializeActivityLogAlertAllOfCondition(property0.Value); + continue; + } + if (property0.NameEquals("actions")) + { + actions = ActivityLogAlertActionList.DeserializeActivityLogAlertActionList(property0.Value); + continue; + } + if (property0.NameEquals("description")) + { + description = property0.Value.GetString(); + continue; + } + } + continue; + } + } + return new ActivityLogAlertResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), Optional.ToList(scopes), Optional.ToNullable(enabled), condition.Value, actions.Value, description.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertResource.cs new file mode 100644 index 000000000000..d83cc1604508 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ActivityLogAlertResource.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An activity log alert resource. + public partial class ActivityLogAlertResource : Resource + { + /// Initializes a new instance of ActivityLogAlertResource. + /// Resource location. + /// is null. + public ActivityLogAlertResource(string location) : base(location) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + + Scopes = new ChangeTrackingList(); + } + + /// Initializes a new instance of ActivityLogAlertResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// Resource location. + /// Resource tags. + /// A list of resourceIds that will be used as prefixes. The alert will only apply to activityLogs with resourceIds that fall under one of these prefixes. This list must include at least one item. + /// Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. + /// The condition that will cause this alert to activate. + /// The actions that will activate when the condition is met. + /// A description of this activity log alert. + internal ActivityLogAlertResource(string id, string name, string type, string location, IDictionary tags, IList scopes, bool? enabled, ActivityLogAlertAllOfCondition condition, ActivityLogAlertActionList actions, string description) : base(id, name, type, location, tags) + { + Scopes = scopes; + Enabled = enabled; + Condition = condition; + Actions = actions; + Description = description; + } + + /// A list of resourceIds that will be used as prefixes. The alert will only apply to activityLogs with resourceIds that fall under one of these prefixes. This list must include at least one item. + public IList Scopes { get; } + /// Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. + public bool? Enabled { get; set; } + /// The condition that will cause this alert to activate. + public ActivityLogAlertAllOfCondition Condition { get; set; } + /// The actions that will activate when the condition is met. + public ActivityLogAlertActionList Actions { get; set; } + /// A description of this activity log alert. + public string Description { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AggregationType.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AggregationType.Serialization.cs new file mode 100644 index 000000000000..f1715c25aaa8 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AggregationType.Serialization.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class AggregationTypeExtensions + { + public static string ToSerialString(this AggregationType value) => value switch + { + AggregationType.None => "None", + AggregationType.Average => "Average", + AggregationType.Count => "Count", + AggregationType.Minimum => "Minimum", + AggregationType.Maximum => "Maximum", + AggregationType.Total => "Total", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AggregationType value.") + }; + + public static AggregationType ToAggregationType(this string value) + { + if (string.Equals(value, "None", StringComparison.InvariantCultureIgnoreCase)) return AggregationType.None; + if (string.Equals(value, "Average", StringComparison.InvariantCultureIgnoreCase)) return AggregationType.Average; + if (string.Equals(value, "Count", StringComparison.InvariantCultureIgnoreCase)) return AggregationType.Count; + if (string.Equals(value, "Minimum", StringComparison.InvariantCultureIgnoreCase)) return AggregationType.Minimum; + if (string.Equals(value, "Maximum", StringComparison.InvariantCultureIgnoreCase)) return AggregationType.Maximum; + if (string.Equals(value, "Total", StringComparison.InvariantCultureIgnoreCase)) return AggregationType.Total; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AggregationType value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AggregationType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AggregationType.cs new file mode 100644 index 000000000000..30f69a59451f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AggregationType.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the aggregation type of the metric. + public enum AggregationType + { + /// None. + None, + /// Average. + Average, + /// Count. + Count, + /// Minimum. + Minimum, + /// Maximum. + Maximum, + /// Total. + Total + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResource.Serialization.cs new file mode 100644 index 000000000000..bb593a822d6f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResource.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AlertRuleResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("location"); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(NamePropertiesName); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("isEnabled"); + writer.WriteBooleanValue(IsEnabled); + writer.WritePropertyName("condition"); + writer.WriteObjectValue(Condition); + if (Optional.IsCollectionDefined(Actions)) + { + writer.WritePropertyName("actions"); + writer.WriteStartArray(); + foreach (var item in Actions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static AlertRuleResource DeserializeAlertRuleResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + string location = default; + Optional> tags = default; + string name0 = default; + Optional description = default; + bool isEnabled = default; + RuleCondition condition = default; + Optional> actions = default; + Optional lastUpdatedTime = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location")) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("name")) + { + name0 = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("description")) + { + description = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("isEnabled")) + { + isEnabled = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("condition")) + { + condition = RuleCondition.DeserializeRuleCondition(property0.Value); + continue; + } + if (property0.NameEquals("actions")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(RuleAction.DeserializeRuleAction(item)); + } + actions = array; + continue; + } + if (property0.NameEquals("lastUpdatedTime")) + { + lastUpdatedTime = property0.Value.GetDateTimeOffset("O"); + continue; + } + } + continue; + } + } + return new AlertRuleResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), name0, description.Value, isEnabled, condition, Optional.ToList(actions), Optional.ToNullable(lastUpdatedTime)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResource.cs new file mode 100644 index 000000000000..5eb2def3a836 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResource.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The alert rule resource. + public partial class AlertRuleResource : Resource + { + /// Initializes a new instance of AlertRuleResource. + /// Resource location. + /// the name of the alert rule. + /// the flag that indicates whether the alert rule is enabled. + /// the condition that results in the alert rule being activated. + /// , , or is null. + public AlertRuleResource(string location, string namePropertiesName, bool isEnabled, RuleCondition condition) : base(location) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + if (namePropertiesName == null) + { + throw new ArgumentNullException(nameof(namePropertiesName)); + } + if (condition == null) + { + throw new ArgumentNullException(nameof(condition)); + } + + NamePropertiesName = namePropertiesName; + IsEnabled = isEnabled; + Condition = condition; + Actions = new ChangeTrackingList(); + } + + /// Initializes a new instance of AlertRuleResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// Resource location. + /// Resource tags. + /// the name of the alert rule. + /// the description of the alert rule that will be included in the alert email. + /// the flag that indicates whether the alert rule is enabled. + /// the condition that results in the alert rule being activated. + /// the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + /// Last time the rule was updated in ISO8601 format. + internal AlertRuleResource(string id, string name, string type, string location, IDictionary tags, string namePropertiesName, string description, bool isEnabled, RuleCondition condition, IList actions, DateTimeOffset? lastUpdatedTime) : base(id, name, type, location, tags) + { + NamePropertiesName = namePropertiesName; + Description = description; + IsEnabled = isEnabled; + Condition = condition; + Actions = actions; + LastUpdatedTime = lastUpdatedTime; + } + + /// the name of the alert rule. + public string NamePropertiesName { get; set; } + /// the description of the alert rule that will be included in the alert email. + public string Description { get; set; } + /// the flag that indicates whether the alert rule is enabled. + public bool IsEnabled { get; set; } + /// the condition that results in the alert rule being activated. + public RuleCondition Condition { get; set; } + /// the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + public IList Actions { get; } + /// Last time the rule was updated in ISO8601 format. + public DateTimeOffset? LastUpdatedTime { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourceCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourceCollection.Serialization.cs new file mode 100644 index 000000000000..36a5ffe3f643 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourceCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AlertRuleResourceCollection + { + internal static AlertRuleResourceCollection DeserializeAlertRuleResourceCollection(JsonElement element) + { + Optional> value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AlertRuleResource.DeserializeAlertRuleResource(item)); + } + value = array; + continue; + } + } + return new AlertRuleResourceCollection(Optional.ToList(value)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourceCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourceCollection.cs new file mode 100644 index 000000000000..11c440a07414 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourceCollection.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a collection of alert rule resources. + public partial class AlertRuleResourceCollection + { + /// Initializes a new instance of AlertRuleResourceCollection. + internal AlertRuleResourceCollection() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of AlertRuleResourceCollection. + /// the values for the alert rule resources. + internal AlertRuleResourceCollection(IReadOnlyList value) + { + Value = value; + } + + /// the values for the alert rule resources. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourcePatch.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourcePatch.Serialization.cs new file mode 100644 index 000000000000..c52e20cd7159 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourcePatch.Serialization.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AlertRuleResourcePatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(IsEnabled)) + { + writer.WritePropertyName("isEnabled"); + writer.WriteBooleanValue(IsEnabled.Value); + } + if (Optional.IsDefined(Condition)) + { + writer.WritePropertyName("condition"); + writer.WriteObjectValue(Condition); + } + if (Optional.IsCollectionDefined(Actions)) + { + writer.WritePropertyName("actions"); + writer.WriteStartArray(); + foreach (var item in Actions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourcePatch.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourcePatch.cs new file mode 100644 index 000000000000..4f6a7c49096b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertRuleResourcePatch.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The alert rule object for patch operations. + public partial class AlertRuleResourcePatch + { + /// Initializes a new instance of AlertRuleResourcePatch. + public AlertRuleResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + Actions = new ChangeTrackingList(); + } + + /// Resource tags. + public IDictionary Tags { get; } + /// the name of the alert rule. + public string Name { get; set; } + /// the description of the alert rule that will be included in the alert email. + public string Description { get; set; } + /// the flag that indicates whether the alert rule is enabled. + public bool? IsEnabled { get; set; } + /// the condition that results in the alert rule being activated. + public RuleCondition Condition { get; set; } + /// the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + public IList Actions { get; } + /// Last time the rule was updated in ISO8601 format. + public DateTimeOffset? LastUpdatedTime { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertSeverity.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertSeverity.cs new file mode 100644 index 000000000000..8daa209c4958 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertSeverity.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Severity Level of Alert. + public readonly partial struct AlertSeverity : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public AlertSeverity(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ZeroValue = "0"; + private const string OneValue = "1"; + private const string TwoValue = "2"; + private const string ThreeValue = "3"; + private const string FourValue = "4"; + + /// 0. + public static AlertSeverity Zero { get; } = new AlertSeverity(ZeroValue); + /// 1. + public static AlertSeverity One { get; } = new AlertSeverity(OneValue); + /// 2. + public static AlertSeverity Two { get; } = new AlertSeverity(TwoValue); + /// 3. + public static AlertSeverity Three { get; } = new AlertSeverity(ThreeValue); + /// 4. + public static AlertSeverity Four { get; } = new AlertSeverity(FourValue); + /// Determines if two values are the same. + public static bool operator ==(AlertSeverity left, AlertSeverity right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AlertSeverity left, AlertSeverity right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AlertSeverity(string value) => new AlertSeverity(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AlertSeverity other && Equals(other); + /// + public bool Equals(AlertSeverity other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertingAction.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertingAction.Serialization.cs new file mode 100644 index 000000000000..fe2208cb1362 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertingAction.Serialization.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AlertingAction : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("severity"); + writer.WriteStringValue(Severity.ToString()); + if (Optional.IsDefined(AznsAction)) + { + writer.WritePropertyName("aznsAction"); + writer.WriteObjectValue(AznsAction); + } + if (Optional.IsDefined(ThrottlingInMin)) + { + writer.WritePropertyName("throttlingInMin"); + writer.WriteNumberValue(ThrottlingInMin.Value); + } + writer.WritePropertyName("trigger"); + writer.WriteObjectValue(Trigger); + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + writer.WriteEndObject(); + } + + internal static AlertingAction DeserializeAlertingAction(JsonElement element) + { + AlertSeverity severity = default; + Optional aznsAction = default; + Optional throttlingInMin = default; + TriggerCondition trigger = default; + string odataType = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("severity")) + { + severity = new AlertSeverity(property.Value.GetString()); + continue; + } + if (property.NameEquals("aznsAction")) + { + aznsAction = AzNsActionGroup.DeserializeAzNsActionGroup(property.Value); + continue; + } + if (property.NameEquals("throttlingInMin")) + { + throttlingInMin = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("trigger")) + { + trigger = TriggerCondition.DeserializeTriggerCondition(property.Value); + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + } + return new AlertingAction(odataType, severity, aznsAction.Value, Optional.ToNullable(throttlingInMin), trigger); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertingAction.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertingAction.cs new file mode 100644 index 000000000000..f7bb60aaf5fc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AlertingAction.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specify action need to be taken when rule type is Alert. + public partial class AlertingAction : Action + { + /// Initializes a new instance of AlertingAction. + /// Severity of the alert. + /// The trigger condition that results in the alert rule being. + /// is null. + public AlertingAction(AlertSeverity severity, TriggerCondition trigger) + { + if (trigger == null) + { + throw new ArgumentNullException(nameof(trigger)); + } + + Severity = severity; + Trigger = trigger; + OdataType = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"; + } + + /// Initializes a new instance of AlertingAction. + /// Specifies the action. Supported values - AlertingAction, LogToMetricAction. + /// Severity of the alert. + /// Azure action group reference. + /// time (in minutes) for which Alerts should be throttled or suppressed. + /// The trigger condition that results in the alert rule being. + internal AlertingAction(string odataType, AlertSeverity severity, AzNsActionGroup aznsAction, int? throttlingInMin, TriggerCondition trigger) : base(odataType) + { + Severity = severity; + AznsAction = aznsAction; + ThrottlingInMin = throttlingInMin; + Trigger = trigger; + OdataType = odataType ?? "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"; + } + + /// Severity of the alert. + public AlertSeverity Severity { get; set; } + /// Azure action group reference. + public AzNsActionGroup AznsAction { get; set; } + /// time (in minutes) for which Alerts should be throttled or suppressed. + public int? ThrottlingInMin { get; set; } + /// The trigger condition that results in the alert rule being. + public TriggerCondition Trigger { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ArmRoleReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ArmRoleReceiver.Serialization.cs new file mode 100644 index 000000000000..cbd58c01dada --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ArmRoleReceiver.Serialization.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ArmRoleReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("roleId"); + writer.WriteStringValue(RoleId); + writer.WritePropertyName("useCommonAlertSchema"); + writer.WriteBooleanValue(UseCommonAlertSchema); + writer.WriteEndObject(); + } + + internal static ArmRoleReceiver DeserializeArmRoleReceiver(JsonElement element) + { + string name = default; + string roleId = default; + bool useCommonAlertSchema = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("roleId")) + { + roleId = property.Value.GetString(); + continue; + } + if (property.NameEquals("useCommonAlertSchema")) + { + useCommonAlertSchema = property.Value.GetBoolean(); + continue; + } + } + return new ArmRoleReceiver(name, roleId, useCommonAlertSchema); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ArmRoleReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ArmRoleReceiver.cs new file mode 100644 index 000000000000..bde98c7d9a9e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ArmRoleReceiver.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An arm role receiver. + public partial class ArmRoleReceiver + { + /// Initializes a new instance of ArmRoleReceiver. + /// The name of the arm role receiver. Names must be unique across all receivers within an action group. + /// The arm role id. + /// Indicates whether to use common alert schema. + /// or is null. + public ArmRoleReceiver(string name, string roleId, bool useCommonAlertSchema) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (roleId == null) + { + throw new ArgumentNullException(nameof(roleId)); + } + + Name = name; + RoleId = roleId; + UseCommonAlertSchema = useCommonAlertSchema; + } + + /// The name of the arm role receiver. Names must be unique across all receivers within an action group. + public string Name { get; set; } + /// The arm role id. + public string RoleId { get; set; } + /// Indicates whether to use common alert schema. + public bool UseCommonAlertSchema { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutomationRunbookReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutomationRunbookReceiver.Serialization.cs new file mode 100644 index 000000000000..d1ce2e29da83 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutomationRunbookReceiver.Serialization.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AutomationRunbookReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("automationAccountId"); + writer.WriteStringValue(AutomationAccountId); + writer.WritePropertyName("runbookName"); + writer.WriteStringValue(RunbookName); + writer.WritePropertyName("webhookResourceId"); + writer.WriteStringValue(WebhookResourceId); + writer.WritePropertyName("isGlobalRunbook"); + writer.WriteBooleanValue(IsGlobalRunbook); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(ServiceUri)) + { + writer.WritePropertyName("serviceUri"); + writer.WriteStringValue(ServiceUri); + } + writer.WritePropertyName("useCommonAlertSchema"); + writer.WriteBooleanValue(UseCommonAlertSchema); + writer.WriteEndObject(); + } + + internal static AutomationRunbookReceiver DeserializeAutomationRunbookReceiver(JsonElement element) + { + string automationAccountId = default; + string runbookName = default; + string webhookResourceId = default; + bool isGlobalRunbook = default; + Optional name = default; + Optional serviceUri = default; + bool useCommonAlertSchema = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("automationAccountId")) + { + automationAccountId = property.Value.GetString(); + continue; + } + if (property.NameEquals("runbookName")) + { + runbookName = property.Value.GetString(); + continue; + } + if (property.NameEquals("webhookResourceId")) + { + webhookResourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("isGlobalRunbook")) + { + isGlobalRunbook = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("serviceUri")) + { + serviceUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("useCommonAlertSchema")) + { + useCommonAlertSchema = property.Value.GetBoolean(); + continue; + } + } + return new AutomationRunbookReceiver(automationAccountId, runbookName, webhookResourceId, isGlobalRunbook, name.Value, serviceUri.Value, useCommonAlertSchema); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutomationRunbookReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutomationRunbookReceiver.cs new file mode 100644 index 000000000000..5252694ff647 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutomationRunbookReceiver.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The Azure Automation Runbook notification receiver. + public partial class AutomationRunbookReceiver + { + /// Initializes a new instance of AutomationRunbookReceiver. + /// The Azure automation account Id which holds this runbook and authenticate to Azure resource. + /// The name for this runbook. + /// The resource id for webhook linked to this runbook. + /// Indicates whether this instance is global runbook. + /// Indicates whether to use common alert schema. + /// , , or is null. + public AutomationRunbookReceiver(string automationAccountId, string runbookName, string webhookResourceId, bool isGlobalRunbook, bool useCommonAlertSchema) + { + if (automationAccountId == null) + { + throw new ArgumentNullException(nameof(automationAccountId)); + } + if (runbookName == null) + { + throw new ArgumentNullException(nameof(runbookName)); + } + if (webhookResourceId == null) + { + throw new ArgumentNullException(nameof(webhookResourceId)); + } + + AutomationAccountId = automationAccountId; + RunbookName = runbookName; + WebhookResourceId = webhookResourceId; + IsGlobalRunbook = isGlobalRunbook; + UseCommonAlertSchema = useCommonAlertSchema; + } + + /// Initializes a new instance of AutomationRunbookReceiver. + /// The Azure automation account Id which holds this runbook and authenticate to Azure resource. + /// The name for this runbook. + /// The resource id for webhook linked to this runbook. + /// Indicates whether this instance is global runbook. + /// Indicates name of the webhook. + /// The URI where webhooks should be sent. + /// Indicates whether to use common alert schema. + internal AutomationRunbookReceiver(string automationAccountId, string runbookName, string webhookResourceId, bool isGlobalRunbook, string name, string serviceUri, bool useCommonAlertSchema) + { + AutomationAccountId = automationAccountId; + RunbookName = runbookName; + WebhookResourceId = webhookResourceId; + IsGlobalRunbook = isGlobalRunbook; + Name = name; + ServiceUri = serviceUri; + UseCommonAlertSchema = useCommonAlertSchema; + } + + /// The Azure automation account Id which holds this runbook and authenticate to Azure resource. + public string AutomationAccountId { get; set; } + /// The name for this runbook. + public string RunbookName { get; set; } + /// The resource id for webhook linked to this runbook. + public string WebhookResourceId { get; set; } + /// Indicates whether this instance is global runbook. + public bool IsGlobalRunbook { get; set; } + /// Indicates name of the webhook. + public string Name { get; set; } + /// The URI where webhooks should be sent. + public string ServiceUri { get; set; } + /// Indicates whether to use common alert schema. + public bool UseCommonAlertSchema { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleNotification.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleNotification.Serialization.cs new file mode 100644 index 000000000000..80f4a60259ab --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleNotification.Serialization.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AutoscaleNotification : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("operation"); + writer.WriteStringValue(Operation); + if (Optional.IsDefined(Email)) + { + writer.WritePropertyName("email"); + writer.WriteObjectValue(Email); + } + if (Optional.IsCollectionDefined(Webhooks)) + { + writer.WritePropertyName("webhooks"); + writer.WriteStartArray(); + foreach (var item in Webhooks) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + internal static AutoscaleNotification DeserializeAutoscaleNotification(JsonElement element) + { + string operation = default; + Optional email = default; + Optional> webhooks = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operation")) + { + operation = property.Value.GetString(); + continue; + } + if (property.NameEquals("email")) + { + email = EmailNotification.DeserializeEmailNotification(property.Value); + continue; + } + if (property.NameEquals("webhooks")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(WebhookNotification.DeserializeWebhookNotification(item)); + } + webhooks = array; + continue; + } + } + return new AutoscaleNotification(operation, email.Value, Optional.ToList(webhooks)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleNotification.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleNotification.cs new file mode 100644 index 000000000000..fd6886834257 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleNotification.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Autoscale notification. + public partial class AutoscaleNotification + { + /// Initializes a new instance of AutoscaleNotification. + public AutoscaleNotification() + { + Operation = "Scale"; + Webhooks = new ChangeTrackingList(); + } + + /// Initializes a new instance of AutoscaleNotification. + /// the operation associated with the notification and its value must be "scale". + /// the email notification. + /// the collection of webhook notifications. + internal AutoscaleNotification(string operation, EmailNotification email, IList webhooks) + { + Operation = operation; + Email = email; + Webhooks = webhooks; + } + + /// the operation associated with the notification and its value must be "scale". + public string Operation { get; set; } + /// the email notification. + public EmailNotification Email { get; set; } + /// the collection of webhook notifications. + public IList Webhooks { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleProfile.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleProfile.Serialization.cs new file mode 100644 index 000000000000..2c00be1d974a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleProfile.Serialization.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AutoscaleProfile : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("capacity"); + writer.WriteObjectValue(Capacity); + writer.WritePropertyName("rules"); + writer.WriteStartArray(); + foreach (var item in Rules) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(FixedDate)) + { + writer.WritePropertyName("fixedDate"); + writer.WriteObjectValue(FixedDate); + } + if (Optional.IsDefined(Recurrence)) + { + writer.WritePropertyName("recurrence"); + writer.WriteObjectValue(Recurrence); + } + writer.WriteEndObject(); + } + + internal static AutoscaleProfile DeserializeAutoscaleProfile(JsonElement element) + { + string name = default; + ScaleCapacity capacity = default; + IList rules = default; + Optional fixedDate = default; + Optional recurrence = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("capacity")) + { + capacity = ScaleCapacity.DeserializeScaleCapacity(property.Value); + continue; + } + if (property.NameEquals("rules")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ScaleRule.DeserializeScaleRule(item)); + } + rules = array; + continue; + } + if (property.NameEquals("fixedDate")) + { + fixedDate = TimeWindow.DeserializeTimeWindow(property.Value); + continue; + } + if (property.NameEquals("recurrence")) + { + recurrence = Recurrence.DeserializeRecurrence(property.Value); + continue; + } + } + return new AutoscaleProfile(name, capacity, rules, fixedDate.Value, recurrence.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleProfile.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleProfile.cs new file mode 100644 index 000000000000..05cfc907ee6a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleProfile.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Autoscale profile. + public partial class AutoscaleProfile + { + /// Initializes a new instance of AutoscaleProfile. + /// the name of the profile. + /// the number of instances that can be used during this profile. + /// the collection of rules that provide the triggers and parameters for the scaling action. A maximum of 10 rules can be specified. + /// , , or is null. + public AutoscaleProfile(string name, ScaleCapacity capacity, IEnumerable rules) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (capacity == null) + { + throw new ArgumentNullException(nameof(capacity)); + } + if (rules == null) + { + throw new ArgumentNullException(nameof(rules)); + } + + Name = name; + Capacity = capacity; + Rules = rules.ToList(); + } + + /// Initializes a new instance of AutoscaleProfile. + /// the name of the profile. + /// the number of instances that can be used during this profile. + /// the collection of rules that provide the triggers and parameters for the scaling action. A maximum of 10 rules can be specified. + /// the specific date-time for the profile. This element is not used if the Recurrence element is used. + /// the repeating times at which this profile begins. This element is not used if the FixedDate element is used. + internal AutoscaleProfile(string name, ScaleCapacity capacity, IList rules, TimeWindow fixedDate, Recurrence recurrence) + { + Name = name; + Capacity = capacity; + Rules = rules; + FixedDate = fixedDate; + Recurrence = recurrence; + } + + /// the name of the profile. + public string Name { get; set; } + /// the number of instances that can be used during this profile. + public ScaleCapacity Capacity { get; set; } + /// the collection of rules that provide the triggers and parameters for the scaling action. A maximum of 10 rules can be specified. + public IList Rules { get; } + /// the specific date-time for the profile. This element is not used if the Recurrence element is used. + public TimeWindow FixedDate { get; set; } + /// the repeating times at which this profile begins. This element is not used if the FixedDate element is used. + public Recurrence Recurrence { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResource.Serialization.cs new file mode 100644 index 000000000000..0a81dc936ac5 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResource.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AutoscaleSettingResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("location"); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + writer.WritePropertyName("profiles"); + writer.WriteStartArray(); + foreach (var item in Profiles) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(Notifications)) + { + writer.WritePropertyName("notifications"); + writer.WriteStartArray(); + foreach (var item in Notifications) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(NamePropertiesName)) + { + writer.WritePropertyName("name"); + writer.WriteStringValue(NamePropertiesName); + } + if (Optional.IsDefined(TargetResourceUri)) + { + writer.WritePropertyName("targetResourceUri"); + writer.WriteStringValue(TargetResourceUri); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static AutoscaleSettingResource DeserializeAutoscaleSettingResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + string location = default; + Optional> tags = default; + IList profiles = default; + Optional> notifications = default; + Optional enabled = default; + Optional name0 = default; + Optional targetResourceUri = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location")) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("profiles")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(AutoscaleProfile.DeserializeAutoscaleProfile(item)); + } + profiles = array; + continue; + } + if (property0.NameEquals("notifications")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(AutoscaleNotification.DeserializeAutoscaleNotification(item)); + } + notifications = array; + continue; + } + if (property0.NameEquals("enabled")) + { + enabled = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("name")) + { + name0 = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("targetResourceUri")) + { + targetResourceUri = property0.Value.GetString(); + continue; + } + } + continue; + } + } + return new AutoscaleSettingResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), profiles, Optional.ToList(notifications), Optional.ToNullable(enabled), name0.Value, targetResourceUri.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResource.cs new file mode 100644 index 000000000000..4f282d680e41 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResource.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The autoscale setting resource. + public partial class AutoscaleSettingResource : Resource + { + /// Initializes a new instance of AutoscaleSettingResource. + /// Resource location. + /// the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. + /// or is null. + public AutoscaleSettingResource(string location, IEnumerable profiles) : base(location) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + if (profiles == null) + { + throw new ArgumentNullException(nameof(profiles)); + } + + Profiles = profiles.ToList(); + Notifications = new ChangeTrackingList(); + } + + /// Initializes a new instance of AutoscaleSettingResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// Resource location. + /// Resource tags. + /// the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. + /// the collection of notifications. + /// the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. + /// the name of the autoscale setting. + /// the resource identifier of the resource that the autoscale setting should be added to. + internal AutoscaleSettingResource(string id, string name, string type, string location, IDictionary tags, IList profiles, IList notifications, bool? enabled, string namePropertiesName, string targetResourceUri) : base(id, name, type, location, tags) + { + Profiles = profiles; + Notifications = notifications; + Enabled = enabled; + NamePropertiesName = namePropertiesName; + TargetResourceUri = targetResourceUri; + } + + /// the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. + public IList Profiles { get; } + /// the collection of notifications. + public IList Notifications { get; } + /// the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. + public bool? Enabled { get; set; } + /// the name of the autoscale setting. + public string NamePropertiesName { get; set; } + /// the resource identifier of the resource that the autoscale setting should be added to. + public string TargetResourceUri { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourceCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourceCollection.Serialization.cs new file mode 100644 index 000000000000..5b8be68c781e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourceCollection.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AutoscaleSettingResourceCollection + { + internal static AutoscaleSettingResourceCollection DeserializeAutoscaleSettingResourceCollection(JsonElement element) + { + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AutoscaleSettingResource.DeserializeAutoscaleSettingResource(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new AutoscaleSettingResourceCollection(value, nextLink.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourceCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourceCollection.cs new file mode 100644 index 000000000000..c1a15ade2626 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourceCollection.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a collection of autoscale setting resources. + public partial class AutoscaleSettingResourceCollection + { + /// Initializes a new instance of AutoscaleSettingResourceCollection. + /// the values for the autoscale setting resources. + /// is null. + internal AutoscaleSettingResourceCollection(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of AutoscaleSettingResourceCollection. + /// the values for the autoscale setting resources. + /// URL to get the next set of results. + internal AutoscaleSettingResourceCollection(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// the values for the autoscale setting resources. + public IReadOnlyList Value { get; } + /// URL to get the next set of results. + public string NextLink { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourcePatch.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourcePatch.Serialization.cs new file mode 100644 index 000000000000..fa9c76332031 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourcePatch.Serialization.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AutoscaleSettingResourcePatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Profiles)) + { + writer.WritePropertyName("profiles"); + writer.WriteStartArray(); + foreach (var item in Profiles) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Notifications)) + { + writer.WritePropertyName("notifications"); + writer.WriteStartArray(); + foreach (var item in Notifications) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(TargetResourceUri)) + { + writer.WritePropertyName("targetResourceUri"); + writer.WriteStringValue(TargetResourceUri); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourcePatch.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourcePatch.cs new file mode 100644 index 000000000000..1a71d61a63d0 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AutoscaleSettingResourcePatch.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The autoscale setting object for patch operations. + public partial class AutoscaleSettingResourcePatch + { + /// Initializes a new instance of AutoscaleSettingResourcePatch. + public AutoscaleSettingResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + Profiles = new ChangeTrackingList(); + Notifications = new ChangeTrackingList(); + } + + /// Resource tags. + public IDictionary Tags { get; } + /// the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. + public IList Profiles { get; } + /// the collection of notifications. + public IList Notifications { get; } + /// the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. + public bool? Enabled { get; set; } + /// the name of the autoscale setting. + public string Name { get; set; } + /// the resource identifier of the resource that the autoscale setting should be added to. + public string TargetResourceUri { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzNsActionGroup.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzNsActionGroup.Serialization.cs new file mode 100644 index 000000000000..fb24c2453e6c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzNsActionGroup.Serialization.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AzNsActionGroup : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(ActionGroup)) + { + writer.WritePropertyName("actionGroup"); + writer.WriteStartArray(); + foreach (var item in ActionGroup) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(EmailSubject)) + { + writer.WritePropertyName("emailSubject"); + writer.WriteStringValue(EmailSubject); + } + if (Optional.IsDefined(CustomWebhookPayload)) + { + writer.WritePropertyName("customWebhookPayload"); + writer.WriteStringValue(CustomWebhookPayload); + } + writer.WriteEndObject(); + } + + internal static AzNsActionGroup DeserializeAzNsActionGroup(JsonElement element) + { + Optional> actionGroup = default; + Optional emailSubject = default; + Optional customWebhookPayload = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("actionGroup")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + actionGroup = array; + continue; + } + if (property.NameEquals("emailSubject")) + { + emailSubject = property.Value.GetString(); + continue; + } + if (property.NameEquals("customWebhookPayload")) + { + customWebhookPayload = property.Value.GetString(); + continue; + } + } + return new AzNsActionGroup(Optional.ToList(actionGroup), emailSubject.Value, customWebhookPayload.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzNsActionGroup.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzNsActionGroup.cs new file mode 100644 index 000000000000..87d955801552 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzNsActionGroup.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Azure action group. + public partial class AzNsActionGroup + { + /// Initializes a new instance of AzNsActionGroup. + public AzNsActionGroup() + { + ActionGroup = new ChangeTrackingList(); + } + + /// Initializes a new instance of AzNsActionGroup. + /// Azure Action Group reference. + /// Custom subject override for all email ids in Azure action group. + /// Custom payload to be sent for all webhook URI in Azure action group. + internal AzNsActionGroup(IList actionGroup, string emailSubject, string customWebhookPayload) + { + ActionGroup = actionGroup; + EmailSubject = emailSubject; + CustomWebhookPayload = customWebhookPayload; + } + + /// Azure Action Group reference. + public IList ActionGroup { get; } + /// Custom subject override for all email ids in Azure action group. + public string EmailSubject { get; set; } + /// Custom payload to be sent for all webhook URI in Azure action group. + public string CustomWebhookPayload { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureAppPushReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureAppPushReceiver.Serialization.cs new file mode 100644 index 000000000000..ffd0d46ecc47 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureAppPushReceiver.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AzureAppPushReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("emailAddress"); + writer.WriteStringValue(EmailAddress); + writer.WriteEndObject(); + } + + internal static AzureAppPushReceiver DeserializeAzureAppPushReceiver(JsonElement element) + { + string name = default; + string emailAddress = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("emailAddress")) + { + emailAddress = property.Value.GetString(); + continue; + } + } + return new AzureAppPushReceiver(name, emailAddress); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureAppPushReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureAppPushReceiver.cs new file mode 100644 index 000000000000..dae79e9efbb8 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureAppPushReceiver.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The Azure mobile App push notification receiver. + public partial class AzureAppPushReceiver + { + /// Initializes a new instance of AzureAppPushReceiver. + /// The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. + /// The email address registered for the Azure mobile app. + /// or is null. + public AzureAppPushReceiver(string name, string emailAddress) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (emailAddress == null) + { + throw new ArgumentNullException(nameof(emailAddress)); + } + + Name = name; + EmailAddress = emailAddress; + } + + /// The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. + public string Name { get; set; } + /// The email address registered for the Azure mobile app. + public string EmailAddress { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureFunctionReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureFunctionReceiver.Serialization.cs new file mode 100644 index 000000000000..b841d3fa1167 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureFunctionReceiver.Serialization.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class AzureFunctionReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("functionAppResourceId"); + writer.WriteStringValue(FunctionAppResourceId); + writer.WritePropertyName("functionName"); + writer.WriteStringValue(FunctionName); + writer.WritePropertyName("httpTriggerUrl"); + writer.WriteStringValue(HttpTriggerUrl); + writer.WritePropertyName("useCommonAlertSchema"); + writer.WriteBooleanValue(UseCommonAlertSchema); + writer.WriteEndObject(); + } + + internal static AzureFunctionReceiver DeserializeAzureFunctionReceiver(JsonElement element) + { + string name = default; + string functionAppResourceId = default; + string functionName = default; + string httpTriggerUrl = default; + bool useCommonAlertSchema = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("functionAppResourceId")) + { + functionAppResourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("functionName")) + { + functionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("httpTriggerUrl")) + { + httpTriggerUrl = property.Value.GetString(); + continue; + } + if (property.NameEquals("useCommonAlertSchema")) + { + useCommonAlertSchema = property.Value.GetBoolean(); + continue; + } + } + return new AzureFunctionReceiver(name, functionAppResourceId, functionName, httpTriggerUrl, useCommonAlertSchema); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureFunctionReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureFunctionReceiver.cs new file mode 100644 index 000000000000..51c8f0d0ca00 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/AzureFunctionReceiver.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An azure function receiver. + public partial class AzureFunctionReceiver + { + /// Initializes a new instance of AzureFunctionReceiver. + /// The name of the azure function receiver. Names must be unique across all receivers within an action group. + /// The azure resource id of the function app. + /// The function name in the function app. + /// The http trigger url where http request sent to. + /// Indicates whether to use common alert schema. + /// , , , or is null. + public AzureFunctionReceiver(string name, string functionAppResourceId, string functionName, string httpTriggerUrl, bool useCommonAlertSchema) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (functionAppResourceId == null) + { + throw new ArgumentNullException(nameof(functionAppResourceId)); + } + if (functionName == null) + { + throw new ArgumentNullException(nameof(functionName)); + } + if (httpTriggerUrl == null) + { + throw new ArgumentNullException(nameof(httpTriggerUrl)); + } + + Name = name; + FunctionAppResourceId = functionAppResourceId; + FunctionName = functionName; + HttpTriggerUrl = httpTriggerUrl; + UseCommonAlertSchema = useCommonAlertSchema; + } + + /// The name of the azure function receiver. Names must be unique across all receivers within an action group. + public string Name { get; set; } + /// The azure resource id of the function app. + public string FunctionAppResourceId { get; set; } + /// The function name in the function app. + public string FunctionName { get; set; } + /// The http trigger url where http request sent to. + public string HttpTriggerUrl { get; set; } + /// Indicates whether to use common alert schema. + public bool UseCommonAlertSchema { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Baseline.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Baseline.Serialization.cs new file mode 100644 index 000000000000..60455bdeec5c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Baseline.Serialization.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Baseline + { + internal static Baseline DeserializeBaseline(JsonElement element) + { + Sensitivity sensitivity = default; + IReadOnlyList lowThresholds = default; + IReadOnlyList highThresholds = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sensitivity")) + { + sensitivity = property.Value.GetString().ToSensitivity(); + continue; + } + if (property.NameEquals("lowThresholds")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + lowThresholds = array; + continue; + } + if (property.NameEquals("highThresholds")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + highThresholds = array; + continue; + } + } + return new Baseline(sensitivity, lowThresholds, highThresholds); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Baseline.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Baseline.cs new file mode 100644 index 000000000000..3635ebf4bbc6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Baseline.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The baseline values for a single sensitivity value. + public partial class Baseline + { + /// Initializes a new instance of Baseline. + /// the sensitivity of the baseline. + /// The low thresholds of the baseline. + /// The high thresholds of the baseline. + /// or is null. + internal Baseline(Sensitivity sensitivity, IEnumerable lowThresholds, IEnumerable highThresholds) + { + if (lowThresholds == null) + { + throw new ArgumentNullException(nameof(lowThresholds)); + } + if (highThresholds == null) + { + throw new ArgumentNullException(nameof(highThresholds)); + } + + Sensitivity = sensitivity; + LowThresholds = lowThresholds.ToList(); + HighThresholds = highThresholds.ToList(); + } + + /// Initializes a new instance of Baseline. + /// the sensitivity of the baseline. + /// The low thresholds of the baseline. + /// The high thresholds of the baseline. + internal Baseline(Sensitivity sensitivity, IReadOnlyList lowThresholds, IReadOnlyList highThresholds) + { + Sensitivity = sensitivity; + LowThresholds = lowThresholds; + HighThresholds = highThresholds; + } + + /// the sensitivity of the baseline. + public Sensitivity Sensitivity { get; } + /// The low thresholds of the baseline. + public IReadOnlyList LowThresholds { get; } + /// The high thresholds of the baseline. + public IReadOnlyList HighThresholds { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadata.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadata.Serialization.cs new file mode 100644 index 000000000000..255dd645ec8d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadata.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class BaselineMetadata + { + internal static BaselineMetadata DeserializeBaselineMetadata(JsonElement element) + { + string name = default; + string value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("value")) + { + value = property.Value.GetString(); + continue; + } + } + return new BaselineMetadata(name, value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadata.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadata.cs new file mode 100644 index 000000000000..5e1738d94135 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadata.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a baseline metadata value. + public partial class BaselineMetadata + { + /// Initializes a new instance of BaselineMetadata. + /// Name of the baseline metadata. + /// Value of the baseline metadata. + /// or is null. + internal BaselineMetadata(string name, string value) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Name = name; + Value = value; + } + + /// Name of the baseline metadata. + public string Name { get; } + /// Value of the baseline metadata. + public string Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadataValue.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadataValue.Serialization.cs new file mode 100644 index 000000000000..d96fdf69ff7b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadataValue.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class BaselineMetadataValue + { + internal static BaselineMetadataValue DeserializeBaselineMetadataValue(JsonElement element) + { + Optional name = default; + Optional value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("value")) + { + value = property.Value.GetString(); + continue; + } + } + return new BaselineMetadataValue(name.Value, value.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadataValue.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadataValue.cs new file mode 100644 index 000000000000..e1d4f810290a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineMetadataValue.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a baseline metadata value. + public partial class BaselineMetadataValue + { + /// Initializes a new instance of BaselineMetadataValue. + internal BaselineMetadataValue() + { + } + + /// Initializes a new instance of BaselineMetadataValue. + /// the name of the metadata. + /// the value of the metadata. + internal BaselineMetadataValue(LocalizableString name, string value) + { + Name = name; + Value = value; + } + + /// the name of the metadata. + public LocalizableString Name { get; } + /// the value of the metadata. + public string Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineResponse.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineResponse.Serialization.cs new file mode 100644 index 000000000000..b6f2b8c8a8dc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineResponse.Serialization.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class BaselineResponse + { + internal static BaselineResponse DeserializeBaselineResponse(JsonElement element) + { + Optional id = default; + Optional type = default; + Optional name = default; + Optional timespan = default; + Optional interval = default; + Optional aggregation = default; + Optional> timestamps = default; + Optional> baseline = default; + Optional> metadata = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("timespan")) + { + timespan = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("interval")) + { + interval = property0.Value.GetTimeSpan("P"); + continue; + } + if (property0.NameEquals("aggregation")) + { + aggregation = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("timestamps")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetDateTimeOffset("O")); + } + timestamps = array; + continue; + } + if (property0.NameEquals("baseline")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(Models.Baseline.DeserializeBaseline(item)); + } + baseline = array; + continue; + } + if (property0.NameEquals("metadata")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(BaselineMetadataValue.DeserializeBaselineMetadataValue(item)); + } + metadata = array; + continue; + } + } + continue; + } + } + return new BaselineResponse(id.Value, type.Value, name.Value, timespan.Value, Optional.ToNullable(interval), aggregation.Value, Optional.ToList(timestamps), Optional.ToList(baseline), Optional.ToList(metadata)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineResponse.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineResponse.cs new file mode 100644 index 000000000000..fab246647d96 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineResponse.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The response to a baseline query. + public partial class BaselineResponse + { + /// Initializes a new instance of BaselineResponse. + internal BaselineResponse() + { + Timestamps = new ChangeTrackingList(); + Baseline = new ChangeTrackingList(); + Metadata = new ChangeTrackingList(); + } + + /// Initializes a new instance of BaselineResponse. + /// the metric baseline Id. + /// the resource type of the baseline resource. + /// the name and the display name of the metric, i.e. it is localizable string. + /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + /// The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + /// The aggregation type of the metric. + /// the array of timestamps of the baselines. + /// the baseline values for each sensitivity. + /// the baseline metadata values. + internal BaselineResponse(string id, string type, LocalizableString name, string timespan, TimeSpan? interval, string aggregation, IReadOnlyList timestamps, IReadOnlyList baseline, IReadOnlyList metadata) + { + Id = id; + Type = type; + Name = name; + Timespan = timespan; + Interval = interval; + Aggregation = aggregation; + Timestamps = timestamps; + Baseline = baseline; + Metadata = metadata; + } + + /// the metric baseline Id. + public string Id { get; } + /// the resource type of the baseline resource. + public string Type { get; } + /// the name and the display name of the metric, i.e. it is localizable string. + public LocalizableString Name { get; } + /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + public string Timespan { get; } + /// The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + public TimeSpan? Interval { get; } + /// The aggregation type of the metric. + public string Aggregation { get; } + /// the array of timestamps of the baselines. + public IReadOnlyList Timestamps { get; } + /// the baseline values for each sensitivity. + public IReadOnlyList Baseline { get; } + /// the baseline metadata values. + public IReadOnlyList Metadata { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineSensitivity.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineSensitivity.cs new file mode 100644 index 000000000000..00ce4979d5fe --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/BaselineSensitivity.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// the sensitivity of the baseline. + public readonly partial struct BaselineSensitivity : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public BaselineSensitivity(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string LowValue = "Low"; + private const string MediumValue = "Medium"; + private const string HighValue = "High"; + + /// Low. + public static BaselineSensitivity Low { get; } = new BaselineSensitivity(LowValue); + /// Medium. + public static BaselineSensitivity Medium { get; } = new BaselineSensitivity(MediumValue); + /// High. + public static BaselineSensitivity High { get; } = new BaselineSensitivity(HighValue); + /// Determines if two values are the same. + public static bool operator ==(BaselineSensitivity left, BaselineSensitivity right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(BaselineSensitivity left, BaselineSensitivity right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator BaselineSensitivity(string value) => new BaselineSensitivity(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BaselineSensitivity other && Equals(other); + /// + public bool Equals(BaselineSensitivity other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CalculateBaselineResponse.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CalculateBaselineResponse.Serialization.cs new file mode 100644 index 000000000000..1f10c21e4f50 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CalculateBaselineResponse.Serialization.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class CalculateBaselineResponse + { + internal static CalculateBaselineResponse DeserializeCalculateBaselineResponse(JsonElement element) + { + string type = default; + Optional> timestamps = default; + IReadOnlyList baseline = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("timestamps")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDateTimeOffset("O")); + } + timestamps = array; + continue; + } + if (property.NameEquals("baseline")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Models.Baseline.DeserializeBaseline(item)); + } + baseline = array; + continue; + } + } + return new CalculateBaselineResponse(type, Optional.ToList(timestamps), baseline); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CalculateBaselineResponse.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CalculateBaselineResponse.cs new file mode 100644 index 000000000000..e202e9019496 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CalculateBaselineResponse.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The response to a calculate baseline call. + public partial class CalculateBaselineResponse + { + /// Initializes a new instance of CalculateBaselineResponse. + /// the resource type of the baseline resource. + /// the baseline values for each sensitivity. + /// or is null. + internal CalculateBaselineResponse(string type, IEnumerable baseline) + { + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + if (baseline == null) + { + throw new ArgumentNullException(nameof(baseline)); + } + + Type = type; + Timestamps = new ChangeTrackingList(); + Baseline = baseline.ToList(); + } + + /// Initializes a new instance of CalculateBaselineResponse. + /// the resource type of the baseline resource. + /// the array of timestamps of the baselines. + /// the baseline values for each sensitivity. + internal CalculateBaselineResponse(string type, IReadOnlyList timestamps, IReadOnlyList baseline) + { + Type = type; + Timestamps = timestamps; + Baseline = baseline; + } + + /// the resource type of the baseline resource. + public string Type { get; } + /// the array of timestamps of the baselines. + public IReadOnlyList Timestamps { get; } + /// the baseline values for each sensitivity. + public IReadOnlyList Baseline { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CategoryType.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CategoryType.Serialization.cs new file mode 100644 index 000000000000..a5ce1b625949 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CategoryType.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class CategoryTypeExtensions + { + public static string ToSerialString(this CategoryType value) => value switch + { + CategoryType.Metrics => "Metrics", + CategoryType.Logs => "Logs", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CategoryType value.") + }; + + public static CategoryType ToCategoryType(this string value) + { + if (string.Equals(value, "Metrics", StringComparison.InvariantCultureIgnoreCase)) return CategoryType.Metrics; + if (string.Equals(value, "Logs", StringComparison.InvariantCultureIgnoreCase)) return CategoryType.Logs; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CategoryType value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CategoryType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CategoryType.cs new file mode 100644 index 000000000000..c532663def52 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CategoryType.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The type of the diagnostic settings category. + public enum CategoryType + { + /// Metrics. + Metrics, + /// Logs. + Logs + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ComparisonOperationType.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ComparisonOperationType.Serialization.cs new file mode 100644 index 000000000000..a5cbcb1c127a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ComparisonOperationType.Serialization.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class ComparisonOperationTypeExtensions + { + public static string ToSerialString(this ComparisonOperationType value) => value switch + { + ComparisonOperationType.EqualsValue => "Equals", + ComparisonOperationType.NotEquals => "NotEquals", + ComparisonOperationType.GreaterThan => "GreaterThan", + ComparisonOperationType.GreaterThanOrEqual => "GreaterThanOrEqual", + ComparisonOperationType.LessThan => "LessThan", + ComparisonOperationType.LessThanOrEqual => "LessThanOrEqual", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ComparisonOperationType value.") + }; + + public static ComparisonOperationType ToComparisonOperationType(this string value) + { + if (string.Equals(value, "Equals", StringComparison.InvariantCultureIgnoreCase)) return ComparisonOperationType.EqualsValue; + if (string.Equals(value, "NotEquals", StringComparison.InvariantCultureIgnoreCase)) return ComparisonOperationType.NotEquals; + if (string.Equals(value, "GreaterThan", StringComparison.InvariantCultureIgnoreCase)) return ComparisonOperationType.GreaterThan; + if (string.Equals(value, "GreaterThanOrEqual", StringComparison.InvariantCultureIgnoreCase)) return ComparisonOperationType.GreaterThanOrEqual; + if (string.Equals(value, "LessThan", StringComparison.InvariantCultureIgnoreCase)) return ComparisonOperationType.LessThan; + if (string.Equals(value, "LessThanOrEqual", StringComparison.InvariantCultureIgnoreCase)) return ComparisonOperationType.LessThanOrEqual; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ComparisonOperationType value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ComparisonOperationType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ComparisonOperationType.cs new file mode 100644 index 000000000000..e772837ff9a1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ComparisonOperationType.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the operator that is used to compare the metric data and the threshold. + public enum ComparisonOperationType + { + /// Equals. + EqualsValue, + /// NotEquals. + NotEquals, + /// GreaterThan. + GreaterThan, + /// GreaterThanOrEqual. + GreaterThanOrEqual, + /// LessThan. + LessThan, + /// LessThanOrEqual. + LessThanOrEqual + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ConditionOperator.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ConditionOperator.Serialization.cs new file mode 100644 index 000000000000..bdc7442d62e4 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ConditionOperator.Serialization.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class ConditionOperatorExtensions + { + public static string ToSerialString(this ConditionOperator value) => value switch + { + ConditionOperator.GreaterThan => "GreaterThan", + ConditionOperator.GreaterThanOrEqual => "GreaterThanOrEqual", + ConditionOperator.LessThan => "LessThan", + ConditionOperator.LessThanOrEqual => "LessThanOrEqual", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ConditionOperator value.") + }; + + public static ConditionOperator ToConditionOperator(this string value) + { + if (string.Equals(value, "GreaterThan", StringComparison.InvariantCultureIgnoreCase)) return ConditionOperator.GreaterThan; + if (string.Equals(value, "GreaterThanOrEqual", StringComparison.InvariantCultureIgnoreCase)) return ConditionOperator.GreaterThanOrEqual; + if (string.Equals(value, "LessThan", StringComparison.InvariantCultureIgnoreCase)) return ConditionOperator.LessThan; + if (string.Equals(value, "LessThanOrEqual", StringComparison.InvariantCultureIgnoreCase)) return ConditionOperator.LessThanOrEqual; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ConditionOperator value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ConditionOperator.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ConditionOperator.cs new file mode 100644 index 000000000000..f9839f08f232 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ConditionOperator.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Operators allowed in the rule condition. + public enum ConditionOperator + { + /// GreaterThan. + GreaterThan, + /// GreaterThanOrEqual. + GreaterThanOrEqual, + /// LessThan. + LessThan, + /// LessThanOrEqual. + LessThanOrEqual + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ConditionalOperator.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ConditionalOperator.cs new file mode 100644 index 000000000000..0e43f83ef5f6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ConditionalOperator.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Result Condition Evaluation criteria. Supported Values - 'GreaterThan' or 'LessThan' or 'Equal'. + public readonly partial struct ConditionalOperator : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public ConditionalOperator(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string GreaterThanValue = "GreaterThan"; + private const string LessThanValue = "LessThan"; + private const string EqualValue = "Equal"; + + /// GreaterThan. + public static ConditionalOperator GreaterThan { get; } = new ConditionalOperator(GreaterThanValue); + /// LessThan. + public static ConditionalOperator LessThan { get; } = new ConditionalOperator(LessThanValue); + /// Equal. + public static ConditionalOperator Equal { get; } = new ConditionalOperator(EqualValue); + /// Determines if two values are the same. + public static bool operator ==(ConditionalOperator left, ConditionalOperator right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ConditionalOperator left, ConditionalOperator right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ConditionalOperator(string value) => new ConditionalOperator(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ConditionalOperator other && Equals(other); + /// + public bool Equals(ConditionalOperator other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Criteria.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Criteria.Serialization.cs new file mode 100644 index 000000000000..a59151d28afc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Criteria.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Criteria : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("metricName"); + writer.WriteStringValue(MetricName); + if (Optional.IsCollectionDefined(Dimensions)) + { + writer.WritePropertyName("dimensions"); + writer.WriteStartArray(); + foreach (var item in Dimensions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + internal static Criteria DeserializeCriteria(JsonElement element) + { + string metricName = default; + Optional> dimensions = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metricName")) + { + metricName = property.Value.GetString(); + continue; + } + if (property.NameEquals("dimensions")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Dimension.DeserializeDimension(item)); + } + dimensions = array; + continue; + } + } + return new Criteria(metricName, Optional.ToList(dimensions)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Criteria.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Criteria.cs new file mode 100644 index 000000000000..f558b3950290 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Criteria.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the criteria for converting log to metric. + public partial class Criteria + { + /// Initializes a new instance of Criteria. + /// Name of the metric. + /// is null. + public Criteria(string metricName) + { + if (metricName == null) + { + throw new ArgumentNullException(nameof(metricName)); + } + + MetricName = metricName; + Dimensions = new ChangeTrackingList(); + } + + /// Initializes a new instance of Criteria. + /// Name of the metric. + /// List of Dimensions for creating metric. + internal Criteria(string metricName, IList dimensions) + { + MetricName = metricName; + Dimensions = dimensions; + } + + /// Name of the metric. + public string MetricName { get; set; } + /// List of Dimensions for creating metric. + public IList Dimensions { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CriterionType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CriterionType.cs new file mode 100644 index 000000000000..cb8e6f0e5bd4 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/CriterionType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the type of threshold criteria. + public readonly partial struct CriterionType : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public CriterionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string StaticThresholdCriterionValue = "StaticThresholdCriterion"; + private const string DynamicThresholdCriterionValue = "DynamicThresholdCriterion"; + + /// StaticThresholdCriterion. + public static CriterionType StaticThresholdCriterion { get; } = new CriterionType(StaticThresholdCriterionValue); + /// DynamicThresholdCriterion. + public static CriterionType DynamicThresholdCriterion { get; } = new CriterionType(DynamicThresholdCriterionValue); + /// Determines if two values are the same. + public static bool operator ==(CriterionType left, CriterionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CriterionType left, CriterionType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CriterionType(string value) => new CriterionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CriterionType other && Equals(other); + /// + public bool Equals(CriterionType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DataContainer.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DataContainer.Serialization.cs new file mode 100644 index 000000000000..b229af75b772 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DataContainer.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class DataContainer + { + internal static DataContainer DeserializeDataContainer(JsonElement element) + { + WorkspaceInfo workspace = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("workspace")) + { + workspace = WorkspaceInfo.DeserializeWorkspaceInfo(property.Value); + continue; + } + } + return new DataContainer(workspace); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DataContainer.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DataContainer.cs new file mode 100644 index 000000000000..94d2c11999f1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DataContainer.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Information about a container with data for a given resource. + public partial class DataContainer + { + /// Initializes a new instance of DataContainer. + /// Log Analytics workspace information. + /// is null. + internal DataContainer(WorkspaceInfo workspace) + { + if (workspace == null) + { + throw new ArgumentNullException(nameof(workspace)); + } + + Workspace = workspace; + } + + /// Log Analytics workspace information. + public WorkspaceInfo Workspace { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DataStatus.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DataStatus.cs new file mode 100644 index 000000000000..be24cbf3ed84 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DataStatus.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The status of VM Insights data from the resource. When reported as `present` the data array will contain information about the data containers to which data for the specified resource is being routed. + public readonly partial struct DataStatus : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public DataStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PresentValue = "present"; + private const string NotPresentValue = "notPresent"; + + /// present. + public static DataStatus Present { get; } = new DataStatus(PresentValue); + /// notPresent. + public static DataStatus NotPresent { get; } = new DataStatus(NotPresentValue); + /// Determines if two values are the same. + public static bool operator ==(DataStatus left, DataStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataStatus left, DataStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DataStatus(string value) => new DataStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataStatus other && Equals(other); + /// + public bool Equals(DataStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResource.Serialization.cs new file mode 100644 index 000000000000..d9dc31c60d16 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResource.Serialization.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class DiagnosticSettingsCategoryResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(CategoryType)) + { + writer.WritePropertyName("categoryType"); + writer.WriteStringValue(CategoryType.Value.ToSerialString()); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static DiagnosticSettingsCategoryResource DeserializeDiagnosticSettingsCategoryResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + Optional categoryType = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("categoryType")) + { + categoryType = property0.Value.GetString().ToCategoryType(); + continue; + } + } + continue; + } + } + return new DiagnosticSettingsCategoryResource(id.Value, name.Value, type.Value, Optional.ToNullable(categoryType)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResource.cs new file mode 100644 index 000000000000..6db2da6f945d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResource.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The diagnostic settings category resource. + public partial class DiagnosticSettingsCategoryResource : ProxyOnlyResource + { + /// Initializes a new instance of DiagnosticSettingsCategoryResource. + public DiagnosticSettingsCategoryResource() + { + } + + /// Initializes a new instance of DiagnosticSettingsCategoryResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// The type of the diagnostic settings category. + internal DiagnosticSettingsCategoryResource(string id, string name, string type, CategoryType? categoryType) : base(id, name, type) + { + CategoryType = categoryType; + } + + /// The type of the diagnostic settings category. + public CategoryType? CategoryType { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResourceCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResourceCollection.Serialization.cs new file mode 100644 index 000000000000..bd065d91bb17 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResourceCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class DiagnosticSettingsCategoryResourceCollection + { + internal static DiagnosticSettingsCategoryResourceCollection DeserializeDiagnosticSettingsCategoryResourceCollection(JsonElement element) + { + Optional> value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DiagnosticSettingsCategoryResource.DeserializeDiagnosticSettingsCategoryResource(item)); + } + value = array; + continue; + } + } + return new DiagnosticSettingsCategoryResourceCollection(Optional.ToList(value)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResourceCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResourceCollection.cs new file mode 100644 index 000000000000..f9a5cbf9d9bc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsCategoryResourceCollection.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a collection of diagnostic setting category resources. + public partial class DiagnosticSettingsCategoryResourceCollection + { + /// Initializes a new instance of DiagnosticSettingsCategoryResourceCollection. + internal DiagnosticSettingsCategoryResourceCollection() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of DiagnosticSettingsCategoryResourceCollection. + /// The collection of diagnostic settings category resources. + internal DiagnosticSettingsCategoryResourceCollection(IReadOnlyList value) + { + Value = value; + } + + /// The collection of diagnostic settings category resources. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResource.Serialization.cs new file mode 100644 index 000000000000..b7d249cf2eb2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResource.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class DiagnosticSettingsResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(StorageAccountId)) + { + writer.WritePropertyName("storageAccountId"); + writer.WriteStringValue(StorageAccountId); + } + if (Optional.IsDefined(ServiceBusRuleId)) + { + writer.WritePropertyName("serviceBusRuleId"); + writer.WriteStringValue(ServiceBusRuleId); + } + if (Optional.IsDefined(EventHubAuthorizationRuleId)) + { + writer.WritePropertyName("eventHubAuthorizationRuleId"); + writer.WriteStringValue(EventHubAuthorizationRuleId); + } + if (Optional.IsDefined(EventHubName)) + { + writer.WritePropertyName("eventHubName"); + writer.WriteStringValue(EventHubName); + } + if (Optional.IsCollectionDefined(Metrics)) + { + writer.WritePropertyName("metrics"); + writer.WriteStartArray(); + foreach (var item in Metrics) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Logs)) + { + writer.WritePropertyName("logs"); + writer.WriteStartArray(); + foreach (var item in Logs) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(WorkspaceId)) + { + writer.WritePropertyName("workspaceId"); + writer.WriteStringValue(WorkspaceId); + } + if (Optional.IsDefined(LogAnalyticsDestinationType)) + { + writer.WritePropertyName("logAnalyticsDestinationType"); + writer.WriteStringValue(LogAnalyticsDestinationType); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static DiagnosticSettingsResource DeserializeDiagnosticSettingsResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + Optional storageAccountId = default; + Optional serviceBusRuleId = default; + Optional eventHubAuthorizationRuleId = default; + Optional eventHubName = default; + Optional> metrics = default; + Optional> logs = default; + Optional workspaceId = default; + Optional logAnalyticsDestinationType = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("storageAccountId")) + { + storageAccountId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("serviceBusRuleId")) + { + serviceBusRuleId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("eventHubAuthorizationRuleId")) + { + eventHubAuthorizationRuleId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("eventHubName")) + { + eventHubName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("metrics")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(MetricSettings.DeserializeMetricSettings(item)); + } + metrics = array; + continue; + } + if (property0.NameEquals("logs")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(LogSettings.DeserializeLogSettings(item)); + } + logs = array; + continue; + } + if (property0.NameEquals("workspaceId")) + { + workspaceId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("logAnalyticsDestinationType")) + { + logAnalyticsDestinationType = property0.Value.GetString(); + continue; + } + } + continue; + } + } + return new DiagnosticSettingsResource(id.Value, name.Value, type.Value, storageAccountId.Value, serviceBusRuleId.Value, eventHubAuthorizationRuleId.Value, eventHubName.Value, Optional.ToList(metrics), Optional.ToList(logs), workspaceId.Value, logAnalyticsDestinationType.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResource.cs new file mode 100644 index 000000000000..624f8bc6c7aa --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResource.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The diagnostic setting resource. + public partial class DiagnosticSettingsResource : ProxyOnlyResource + { + /// Initializes a new instance of DiagnosticSettingsResource. + public DiagnosticSettingsResource() + { + Metrics = new ChangeTrackingList(); + Logs = new ChangeTrackingList(); + } + + /// Initializes a new instance of DiagnosticSettingsResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// The resource ID of the storage account to which you would like to send Diagnostic Logs. + /// The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. + /// The resource Id for the event hub authorization rule. + /// The name of the event hub. If none is specified, the default event hub will be selected. + /// The list of metric settings. + /// The list of logs settings. + /// The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + /// A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: <normalized service identity>_<normalized category name>. Possible values are: Dedicated and null (null is default.). + internal DiagnosticSettingsResource(string id, string name, string type, string storageAccountId, string serviceBusRuleId, string eventHubAuthorizationRuleId, string eventHubName, IList metrics, IList logs, string workspaceId, string logAnalyticsDestinationType) : base(id, name, type) + { + StorageAccountId = storageAccountId; + ServiceBusRuleId = serviceBusRuleId; + EventHubAuthorizationRuleId = eventHubAuthorizationRuleId; + EventHubName = eventHubName; + Metrics = metrics; + Logs = logs; + WorkspaceId = workspaceId; + LogAnalyticsDestinationType = logAnalyticsDestinationType; + } + + /// The resource ID of the storage account to which you would like to send Diagnostic Logs. + public string StorageAccountId { get; set; } + /// The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. + public string ServiceBusRuleId { get; set; } + /// The resource Id for the event hub authorization rule. + public string EventHubAuthorizationRuleId { get; set; } + /// The name of the event hub. If none is specified, the default event hub will be selected. + public string EventHubName { get; set; } + /// The list of metric settings. + public IList Metrics { get; } + /// The list of logs settings. + public IList Logs { get; } + /// The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + public string WorkspaceId { get; set; } + /// A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: <normalized service identity>_<normalized category name>. Possible values are: Dedicated and null (null is default.). + public string LogAnalyticsDestinationType { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResourceCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResourceCollection.Serialization.cs new file mode 100644 index 000000000000..b070e2564910 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResourceCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class DiagnosticSettingsResourceCollection + { + internal static DiagnosticSettingsResourceCollection DeserializeDiagnosticSettingsResourceCollection(JsonElement element) + { + Optional> value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DiagnosticSettingsResource.DeserializeDiagnosticSettingsResource(item)); + } + value = array; + continue; + } + } + return new DiagnosticSettingsResourceCollection(Optional.ToList(value)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResourceCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResourceCollection.cs new file mode 100644 index 000000000000..25625225ad8a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DiagnosticSettingsResourceCollection.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a collection of alert rule resources. + public partial class DiagnosticSettingsResourceCollection + { + /// Initializes a new instance of DiagnosticSettingsResourceCollection. + internal DiagnosticSettingsResourceCollection() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of DiagnosticSettingsResourceCollection. + /// The collection of diagnostic settings resources;. + internal DiagnosticSettingsResourceCollection(IReadOnlyList value) + { + Value = value; + } + + /// The collection of diagnostic settings resources;. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Dimension.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Dimension.Serialization.cs new file mode 100644 index 000000000000..4526459a948d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Dimension.Serialization.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Dimension : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("operator"); + writer.WriteStringValue(Operator.ToString()); + writer.WritePropertyName("values"); + writer.WriteStartArray(); + foreach (var item in Values) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } + + internal static Dimension DeserializeDimension(JsonElement element) + { + string name = default; + Operator @operator = default; + IList values = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("operator")) + { + @operator = new Operator(property.Value.GetString()); + continue; + } + if (property.NameEquals("values")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + values = array; + continue; + } + } + return new Dimension(name, @operator, values); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Dimension.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Dimension.cs new file mode 100644 index 000000000000..25000087b05e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Dimension.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the criteria for converting log to metric. + public partial class Dimension + { + /// Initializes a new instance of Dimension. + /// Name of the dimension. + /// Operator for dimension values. + /// List of dimension values. + /// or is null. + public Dimension(string name, Operator @operator, IEnumerable values) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (values == null) + { + throw new ArgumentNullException(nameof(values)); + } + + Name = name; + Operator = @operator; + Values = values.ToList(); + } + + /// Initializes a new instance of Dimension. + /// Name of the dimension. + /// Operator for dimension values. + /// List of dimension values. + internal Dimension(string name, Operator @operator, IList values) + { + Name = name; + Operator = @operator; + Values = values; + } + + /// Name of the dimension. + public string Name { get; set; } + /// Operator for dimension values. + public Operator Operator { get; set; } + /// List of dimension values. + public IList Values { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicMetricCriteria.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicMetricCriteria.Serialization.cs new file mode 100644 index 000000000000..e2353e4b1bbb --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicMetricCriteria.Serialization.cs @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class DynamicMetricCriteria : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("operator"); + writer.WriteStringValue(Operator.ToString()); + writer.WritePropertyName("alertSensitivity"); + writer.WriteStringValue(AlertSensitivity.ToString()); + writer.WritePropertyName("failingPeriods"); + writer.WriteObjectValue(FailingPeriods); + if (Optional.IsDefined(IgnoreDataBefore)) + { + writer.WritePropertyName("ignoreDataBefore"); + writer.WriteStringValue(IgnoreDataBefore.Value, "O"); + } + writer.WritePropertyName("criterionType"); + writer.WriteStringValue(CriterionType.ToString()); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("metricName"); + writer.WriteStringValue(MetricName); + if (Optional.IsDefined(MetricNamespace)) + { + writer.WritePropertyName("metricNamespace"); + writer.WriteStringValue(MetricNamespace); + } + writer.WritePropertyName("timeAggregation"); + writer.WriteStringValue(TimeAggregation.ToSerialString()); + if (Optional.IsCollectionDefined(Dimensions)) + { + writer.WritePropertyName("dimensions"); + writer.WriteStartArray(); + foreach (var item in Dimensions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value); + } + writer.WriteEndObject(); + } + + internal static DynamicMetricCriteria DeserializeDynamicMetricCriteria(JsonElement element) + { + DynamicThresholdOperator @operator = default; + DynamicThresholdSensitivity alertSensitivity = default; + DynamicThresholdFailingPeriods failingPeriods = default; + Optional ignoreDataBefore = default; + CriterionType criterionType = default; + string name = default; + string metricName = default; + Optional metricNamespace = default; + AggregationType timeAggregation = default; + Optional> dimensions = default; + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operator")) + { + @operator = new DynamicThresholdOperator(property.Value.GetString()); + continue; + } + if (property.NameEquals("alertSensitivity")) + { + alertSensitivity = new DynamicThresholdSensitivity(property.Value.GetString()); + continue; + } + if (property.NameEquals("failingPeriods")) + { + failingPeriods = DynamicThresholdFailingPeriods.DeserializeDynamicThresholdFailingPeriods(property.Value); + continue; + } + if (property.NameEquals("ignoreDataBefore")) + { + ignoreDataBefore = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("criterionType")) + { + criterionType = new CriterionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricName")) + { + metricName = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricNamespace")) + { + metricNamespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("timeAggregation")) + { + timeAggregation = property.Value.GetString().ToAggregationType(); + continue; + } + if (property.NameEquals("dimensions")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricDimension.DeserializeMetricDimension(item)); + } + dimensions = array; + continue; + } + additionalPropertiesDictionary ??= new Dictionary(); + additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); + } + additionalProperties = additionalPropertiesDictionary; + return new DynamicMetricCriteria(criterionType, name, metricName, metricNamespace.Value, timeAggregation, Optional.ToList(dimensions), additionalProperties, @operator, alertSensitivity, failingPeriods, Optional.ToNullable(ignoreDataBefore)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicMetricCriteria.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicMetricCriteria.cs new file mode 100644 index 000000000000..c9287ef875a3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicMetricCriteria.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Criterion for dynamic threshold. + public partial class DynamicMetricCriteria : MultiMetricCriteria + { + /// Initializes a new instance of DynamicMetricCriteria. + /// Name of the criteria. + /// Name of the metric. + /// the criteria time aggregation types. + /// The operator used to compare the metric value against the threshold. + /// The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. + /// The minimum number of violations required within the selected lookback time window required to raise an alert. + /// , , or is null. + public DynamicMetricCriteria(string name, string metricName, AggregationType timeAggregation, DynamicThresholdOperator @operator, DynamicThresholdSensitivity alertSensitivity, DynamicThresholdFailingPeriods failingPeriods) : base(name, metricName, timeAggregation) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (metricName == null) + { + throw new ArgumentNullException(nameof(metricName)); + } + if (failingPeriods == null) + { + throw new ArgumentNullException(nameof(failingPeriods)); + } + + Operator = @operator; + AlertSensitivity = alertSensitivity; + FailingPeriods = failingPeriods; + CriterionType = CriterionType.DynamicThresholdCriterion; + } + + /// Initializes a new instance of DynamicMetricCriteria. + /// Specifies the type of threshold criteria. + /// Name of the criteria. + /// Name of the metric. + /// Namespace of the metric. + /// the criteria time aggregation types. + /// List of dimension conditions. + /// . + /// The operator used to compare the metric value against the threshold. + /// The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. + /// The minimum number of violations required within the selected lookback time window required to raise an alert. + /// Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format). + internal DynamicMetricCriteria(CriterionType criterionType, string name, string metricName, string metricNamespace, AggregationType timeAggregation, IList dimensions, IDictionary additionalProperties, DynamicThresholdOperator @operator, DynamicThresholdSensitivity alertSensitivity, DynamicThresholdFailingPeriods failingPeriods, DateTimeOffset? ignoreDataBefore) : base(criterionType, name, metricName, metricNamespace, timeAggregation, dimensions, additionalProperties) + { + Operator = @operator; + AlertSensitivity = alertSensitivity; + FailingPeriods = failingPeriods; + IgnoreDataBefore = ignoreDataBefore; + CriterionType = criterionType; + } + + /// The operator used to compare the metric value against the threshold. + public DynamicThresholdOperator Operator { get; set; } + /// The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. + public DynamicThresholdSensitivity AlertSensitivity { get; set; } + /// The minimum number of violations required within the selected lookback time window required to raise an alert. + public DynamicThresholdFailingPeriods FailingPeriods { get; set; } + /// Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format). + public DateTimeOffset? IgnoreDataBefore { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdFailingPeriods.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdFailingPeriods.Serialization.cs new file mode 100644 index 000000000000..32c36f7280b3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdFailingPeriods.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class DynamicThresholdFailingPeriods : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("numberOfEvaluationPeriods"); + writer.WriteNumberValue(NumberOfEvaluationPeriods); + writer.WritePropertyName("minFailingPeriodsToAlert"); + writer.WriteNumberValue(MinFailingPeriodsToAlert); + writer.WriteEndObject(); + } + + internal static DynamicThresholdFailingPeriods DeserializeDynamicThresholdFailingPeriods(JsonElement element) + { + float numberOfEvaluationPeriods = default; + float minFailingPeriodsToAlert = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("numberOfEvaluationPeriods")) + { + numberOfEvaluationPeriods = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("minFailingPeriodsToAlert")) + { + minFailingPeriodsToAlert = property.Value.GetSingle(); + continue; + } + } + return new DynamicThresholdFailingPeriods(numberOfEvaluationPeriods, minFailingPeriodsToAlert); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdFailingPeriods.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdFailingPeriods.cs new file mode 100644 index 000000000000..255fd2e02496 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdFailingPeriods.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The minimum number of violations required within the selected lookback time window required to raise an alert. + public partial class DynamicThresholdFailingPeriods + { + /// Initializes a new instance of DynamicThresholdFailingPeriods. + /// The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + /// The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. + public DynamicThresholdFailingPeriods(float numberOfEvaluationPeriods, float minFailingPeriodsToAlert) + { + NumberOfEvaluationPeriods = numberOfEvaluationPeriods; + MinFailingPeriodsToAlert = minFailingPeriodsToAlert; + } + + /// The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + public float NumberOfEvaluationPeriods { get; set; } + /// The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. + public float MinFailingPeriodsToAlert { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdOperator.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdOperator.cs new file mode 100644 index 000000000000..612759ee7cf3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdOperator.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The operator used to compare the metric value against the threshold. + public readonly partial struct DynamicThresholdOperator : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public DynamicThresholdOperator(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string GreaterThanValue = "GreaterThan"; + private const string LessThanValue = "LessThan"; + private const string GreaterOrLessThanValue = "GreaterOrLessThan"; + + /// GreaterThan. + public static DynamicThresholdOperator GreaterThan { get; } = new DynamicThresholdOperator(GreaterThanValue); + /// LessThan. + public static DynamicThresholdOperator LessThan { get; } = new DynamicThresholdOperator(LessThanValue); + /// GreaterOrLessThan. + public static DynamicThresholdOperator GreaterOrLessThan { get; } = new DynamicThresholdOperator(GreaterOrLessThanValue); + /// Determines if two values are the same. + public static bool operator ==(DynamicThresholdOperator left, DynamicThresholdOperator right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DynamicThresholdOperator left, DynamicThresholdOperator right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DynamicThresholdOperator(string value) => new DynamicThresholdOperator(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DynamicThresholdOperator other && Equals(other); + /// + public bool Equals(DynamicThresholdOperator other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdSensitivity.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdSensitivity.cs new file mode 100644 index 000000000000..fdd8c4202b2d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/DynamicThresholdSensitivity.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. + public readonly partial struct DynamicThresholdSensitivity : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public DynamicThresholdSensitivity(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string LowValue = "Low"; + private const string MediumValue = "Medium"; + private const string HighValue = "High"; + + /// Low. + public static DynamicThresholdSensitivity Low { get; } = new DynamicThresholdSensitivity(LowValue); + /// Medium. + public static DynamicThresholdSensitivity Medium { get; } = new DynamicThresholdSensitivity(MediumValue); + /// High. + public static DynamicThresholdSensitivity High { get; } = new DynamicThresholdSensitivity(HighValue); + /// Determines if two values are the same. + public static bool operator ==(DynamicThresholdSensitivity left, DynamicThresholdSensitivity right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DynamicThresholdSensitivity left, DynamicThresholdSensitivity right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DynamicThresholdSensitivity(string value) => new DynamicThresholdSensitivity(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DynamicThresholdSensitivity other && Equals(other); + /// + public bool Equals(DynamicThresholdSensitivity other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailNotification.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailNotification.Serialization.cs new file mode 100644 index 000000000000..95ed24599e32 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailNotification.Serialization.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class EmailNotification : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(SendToSubscriptionAdministrator)) + { + writer.WritePropertyName("sendToSubscriptionAdministrator"); + writer.WriteBooleanValue(SendToSubscriptionAdministrator.Value); + } + if (Optional.IsDefined(SendToSubscriptionCoAdministrators)) + { + writer.WritePropertyName("sendToSubscriptionCoAdministrators"); + writer.WriteBooleanValue(SendToSubscriptionCoAdministrators.Value); + } + if (Optional.IsCollectionDefined(CustomEmails)) + { + writer.WritePropertyName("customEmails"); + writer.WriteStartArray(); + foreach (var item in CustomEmails) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + internal static EmailNotification DeserializeEmailNotification(JsonElement element) + { + Optional sendToSubscriptionAdministrator = default; + Optional sendToSubscriptionCoAdministrators = default; + Optional> customEmails = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sendToSubscriptionAdministrator")) + { + sendToSubscriptionAdministrator = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("sendToSubscriptionCoAdministrators")) + { + sendToSubscriptionCoAdministrators = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("customEmails")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + customEmails = array; + continue; + } + } + return new EmailNotification(Optional.ToNullable(sendToSubscriptionAdministrator), Optional.ToNullable(sendToSubscriptionCoAdministrators), Optional.ToList(customEmails)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailNotification.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailNotification.cs new file mode 100644 index 000000000000..bc8b45244c00 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailNotification.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Email notification of an autoscale event. + public partial class EmailNotification + { + /// Initializes a new instance of EmailNotification. + public EmailNotification() + { + CustomEmails = new ChangeTrackingList(); + } + + /// Initializes a new instance of EmailNotification. + /// a value indicating whether to send email to subscription administrator. + /// a value indicating whether to send email to subscription co-administrators. + /// the custom e-mails list. This value can be null or empty, in which case this attribute will be ignored. + internal EmailNotification(bool? sendToSubscriptionAdministrator, bool? sendToSubscriptionCoAdministrators, IList customEmails) + { + SendToSubscriptionAdministrator = sendToSubscriptionAdministrator; + SendToSubscriptionCoAdministrators = sendToSubscriptionCoAdministrators; + CustomEmails = customEmails; + } + + /// a value indicating whether to send email to subscription administrator. + public bool? SendToSubscriptionAdministrator { get; set; } + /// a value indicating whether to send email to subscription co-administrators. + public bool? SendToSubscriptionCoAdministrators { get; set; } + /// the custom e-mails list. This value can be null or empty, in which case this attribute will be ignored. + public IList CustomEmails { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailReceiver.Serialization.cs new file mode 100644 index 000000000000..073b659e2c9e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailReceiver.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class EmailReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("emailAddress"); + writer.WriteStringValue(EmailAddress); + writer.WritePropertyName("useCommonAlertSchema"); + writer.WriteBooleanValue(UseCommonAlertSchema); + writer.WriteEndObject(); + } + + internal static EmailReceiver DeserializeEmailReceiver(JsonElement element) + { + string name = default; + string emailAddress = default; + bool useCommonAlertSchema = default; + Optional status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("emailAddress")) + { + emailAddress = property.Value.GetString(); + continue; + } + if (property.NameEquals("useCommonAlertSchema")) + { + useCommonAlertSchema = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("status")) + { + status = property.Value.GetString().ToReceiverStatus(); + continue; + } + } + return new EmailReceiver(name, emailAddress, useCommonAlertSchema, Optional.ToNullable(status)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailReceiver.cs new file mode 100644 index 000000000000..536582037a69 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EmailReceiver.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An email receiver. + public partial class EmailReceiver + { + /// Initializes a new instance of EmailReceiver. + /// The name of the email receiver. Names must be unique across all receivers within an action group. + /// The email address of this receiver. + /// Indicates whether to use common alert schema. + /// or is null. + public EmailReceiver(string name, string emailAddress, bool useCommonAlertSchema) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (emailAddress == null) + { + throw new ArgumentNullException(nameof(emailAddress)); + } + + Name = name; + EmailAddress = emailAddress; + UseCommonAlertSchema = useCommonAlertSchema; + } + + /// Initializes a new instance of EmailReceiver. + /// The name of the email receiver. Names must be unique across all receivers within an action group. + /// The email address of this receiver. + /// Indicates whether to use common alert schema. + /// The receiver status of the e-mail. + internal EmailReceiver(string name, string emailAddress, bool useCommonAlertSchema, ReceiverStatus? status) + { + Name = name; + EmailAddress = emailAddress; + UseCommonAlertSchema = useCommonAlertSchema; + Status = status; + } + + /// The name of the email receiver. Names must be unique across all receivers within an action group. + public string Name { get; set; } + /// The email address of this receiver. + public string EmailAddress { get; set; } + /// Indicates whether to use common alert schema. + public bool UseCommonAlertSchema { get; set; } + /// The receiver status of the e-mail. + public ReceiverStatus? Status { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EnableRequest.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EnableRequest.Serialization.cs new file mode 100644 index 000000000000..4bd51c8120ac --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EnableRequest.Serialization.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class EnableRequest : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("receiverName"); + writer.WriteStringValue(ReceiverName); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EnableRequest.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EnableRequest.cs new file mode 100644 index 000000000000..4fd5c4fb909a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EnableRequest.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Describes a receiver that should be resubscribed. + public partial class EnableRequest + { + /// Initializes a new instance of EnableRequest. + /// The name of the receiver to resubscribe. + /// is null. + public EnableRequest(string receiverName) + { + if (receiverName == null) + { + throw new ArgumentNullException(nameof(receiverName)); + } + + ReceiverName = receiverName; + } + + /// The name of the receiver to resubscribe. + public string ReceiverName { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Enabled.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Enabled.cs new file mode 100644 index 000000000000..55d3f432e010 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Enabled.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The flag which indicates whether the Log Search rule is enabled. Value should be true or false. + public readonly partial struct Enabled : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public Enabled(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TrueValue = "true"; + private const string FalseValue = "false"; + + /// true. + public static Enabled True { get; } = new Enabled(TrueValue); + /// false. + public static Enabled False { get; } = new Enabled(FalseValue); + /// Determines if two values are the same. + public static bool operator ==(Enabled left, Enabled right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Enabled left, Enabled right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator Enabled(string value) => new Enabled(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Enabled other && Equals(other); + /// + public bool Equals(Enabled other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Error.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Error.Serialization.cs new file mode 100644 index 000000000000..80483f3c1212 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Error.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + internal partial class Error + { + internal static Error DeserializeError(JsonElement element) + { + string code = default; + Optional message = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code")) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("message")) + { + message = property.Value.GetString(); + continue; + } + } + return new Error(code, message.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Error.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Error.cs new file mode 100644 index 000000000000..25961e9fe452 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Error.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Error details. + internal partial class Error + { + /// Initializes a new instance of Error. + /// Error code identifying the specific error. + /// is null. + internal Error(string code) + { + if (code == null) + { + throw new ArgumentNullException(nameof(code)); + } + + Code = code; + } + + /// Initializes a new instance of Error. + /// Error code identifying the specific error. + /// Error message in the caller's locale. + internal Error(string code, string message) + { + Code = code; + Message = message; + } + + /// Error code identifying the specific error. + public string Code { get; } + /// Error message in the caller's locale. + public string Message { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ErrorResponse.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ErrorResponse.Serialization.cs new file mode 100644 index 000000000000..b993eaf5cdfc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ErrorResponse.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + internal partial class ErrorResponse + { + internal static ErrorResponse DeserializeErrorResponse(JsonElement element) + { + Optional code = default; + Optional message = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code")) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("message")) + { + message = property.Value.GetString(); + continue; + } + } + return new ErrorResponse(code.Value, message.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ErrorResponse.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..84d2af00d827 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ErrorResponse.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Describes the format of Error response. + internal partial class ErrorResponse + { + /// Initializes a new instance of ErrorResponse. + internal ErrorResponse() + { + } + + /// Initializes a new instance of ErrorResponse. + /// Error code. + /// Error message indicating why the operation failed. + internal ErrorResponse(string code, string message) + { + Code = code; + Message = message; + } + + /// Error code. + public string Code { get; } + /// Error message indicating why the operation failed. + public string Message { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventCategoryCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventCategoryCollection.Serialization.cs new file mode 100644 index 000000000000..b17e4e420747 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventCategoryCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class EventCategoryCollection + { + internal static EventCategoryCollection DeserializeEventCategoryCollection(JsonElement element) + { + IReadOnlyList value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LocalizableString.DeserializeLocalizableString(item)); + } + value = array; + continue; + } + } + return new EventCategoryCollection(value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventCategoryCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventCategoryCollection.cs new file mode 100644 index 000000000000..6b91847b97b6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventCategoryCollection.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A collection of event categories. Currently possible values are: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. + public partial class EventCategoryCollection + { + /// Initializes a new instance of EventCategoryCollection. + /// the list that includes the Azure event categories. + /// is null. + internal EventCategoryCollection(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of EventCategoryCollection. + /// the list that includes the Azure event categories. + internal EventCategoryCollection(IReadOnlyList value) + { + Value = value; + } + + /// the list that includes the Azure event categories. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventData.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventData.Serialization.cs new file mode 100644 index 000000000000..5778f6d3b6fa --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventData.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class EventData + { + internal static EventData DeserializeEventData(JsonElement element) + { + Optional authorization = default; + Optional> claims = default; + Optional caller = default; + Optional description = default; + Optional id = default; + Optional eventDataId = default; + Optional correlationId = default; + Optional eventName = default; + Optional category = default; + Optional httpRequest = default; + Optional level = default; + Optional resourceGroupName = default; + Optional resourceProviderName = default; + Optional resourceId = default; + Optional resourceType = default; + Optional operationId = default; + Optional operationName = default; + Optional> properties = default; + Optional status = default; + Optional subStatus = default; + Optional eventTimestamp = default; + Optional submissionTimestamp = default; + Optional subscriptionId = default; + Optional tenantId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authorization")) + { + authorization = SenderAuthorization.DeserializeSenderAuthorization(property.Value); + continue; + } + if (property.NameEquals("claims")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + claims = dictionary; + continue; + } + if (property.NameEquals("caller")) + { + caller = property.Value.GetString(); + continue; + } + if (property.NameEquals("description")) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("eventDataId")) + { + eventDataId = property.Value.GetString(); + continue; + } + if (property.NameEquals("correlationId")) + { + correlationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("eventName")) + { + eventName = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("category")) + { + category = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("httpRequest")) + { + httpRequest = HttpRequestInfo.DeserializeHttpRequestInfo(property.Value); + continue; + } + if (property.NameEquals("level")) + { + level = property.Value.GetString().ToEventLevel(); + continue; + } + if (property.NameEquals("resourceGroupName")) + { + resourceGroupName = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceProviderName")) + { + resourceProviderName = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("resourceId")) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceType")) + { + resourceType = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("operationId")) + { + operationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("operationName")) + { + operationName = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("properties")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + properties = dictionary; + continue; + } + if (property.NameEquals("status")) + { + status = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("subStatus")) + { + subStatus = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("eventTimestamp")) + { + eventTimestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("submissionTimestamp")) + { + submissionTimestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("subscriptionId")) + { + subscriptionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("tenantId")) + { + tenantId = property.Value.GetString(); + continue; + } + } + return new EventData(authorization.Value, Optional.ToDictionary(claims), caller.Value, description.Value, id.Value, eventDataId.Value, correlationId.Value, eventName.Value, category.Value, httpRequest.Value, Optional.ToNullable(level), resourceGroupName.Value, resourceProviderName.Value, resourceId.Value, resourceType.Value, operationId.Value, operationName.Value, Optional.ToDictionary(properties), status.Value, subStatus.Value, Optional.ToNullable(eventTimestamp), Optional.ToNullable(submissionTimestamp), subscriptionId.Value, tenantId.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventData.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventData.cs new file mode 100644 index 000000000000..8ebdf60da60e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventData.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The Azure event log entries are of type EventData. + public partial class EventData + { + /// Initializes a new instance of EventData. + internal EventData() + { + Claims = new ChangeTrackingDictionary(); + Properties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of EventData. + /// The sender authorization information. + /// key value pairs to identify ARM permissions. + /// the email address of the user who has performed the operation, the UPN claim or SPN claim based on availability. + /// the description of the event. + /// the Id of this event as required by ARM for RBAC. It contains the EventDataID and a timestamp information. + /// the event data Id. This is a unique identifier for an event. + /// the correlation Id, usually a GUID in the string format. The correlation Id is shared among the events that belong to the same uber operation. + /// the event name. This value should not be confused with OperationName. For practical purposes, OperationName might be more appealing to end users. + /// the event category. + /// the HTTP request info. Usually includes the 'clientRequestId', 'clientIpAddress' (IP address of the user who initiated the event) and 'method' (HTTP method e.g. PUT). + /// the event level. + /// the resource group name of the impacted resource. + /// the resource provider name of the impacted resource. + /// the resource uri that uniquely identifies the resource that caused this event. + /// the resource type. + /// It is usually a GUID shared among the events corresponding to single operation. This value should not be confused with EventName. + /// the operation name. + /// the set of <Key, Value> pairs (usually a Dictionary<String, String>) that includes details about the event. + /// a string describing the status of the operation. Some typical values are: Started, In progress, Succeeded, Failed, Resolved. + /// the event sub status. Most of the time, when included, this captures the HTTP status code of the REST call. Common values are: OK (HTTP Status Code: 200), Created (HTTP Status Code: 201), Accepted (HTTP Status Code: 202), No Content (HTTP Status Code: 204), Bad Request(HTTP Status Code: 400), Not Found (HTTP Status Code: 404), Conflict (HTTP Status Code: 409), Internal Server Error (HTTP Status Code: 500), Service Unavailable (HTTP Status Code:503), Gateway Timeout (HTTP Status Code: 504). + /// the timestamp of when the event was generated by the Azure service processing the request corresponding the event. It in ISO 8601 format. + /// the timestamp of when the event became available for querying via this API. It is in ISO 8601 format. This value should not be confused eventTimestamp. As there might be a delay between the occurrence time of the event, and the time that the event is submitted to the Azure logging infrastructure. + /// the Azure subscription Id usually a GUID. + /// the Azure tenant Id. + internal EventData(SenderAuthorization authorization, IReadOnlyDictionary claims, string caller, string description, string id, string eventDataId, string correlationId, LocalizableString eventName, LocalizableString category, HttpRequestInfo httpRequest, EventLevel? level, string resourceGroupName, LocalizableString resourceProviderName, string resourceId, LocalizableString resourceType, string operationId, LocalizableString operationName, IReadOnlyDictionary properties, LocalizableString status, LocalizableString subStatus, DateTimeOffset? eventTimestamp, DateTimeOffset? submissionTimestamp, string subscriptionId, string tenantId) + { + Authorization = authorization; + Claims = claims; + Caller = caller; + Description = description; + Id = id; + EventDataId = eventDataId; + CorrelationId = correlationId; + EventName = eventName; + Category = category; + HttpRequest = httpRequest; + Level = level; + ResourceGroupName = resourceGroupName; + ResourceProviderName = resourceProviderName; + ResourceId = resourceId; + ResourceType = resourceType; + OperationId = operationId; + OperationName = operationName; + Properties = properties; + Status = status; + SubStatus = subStatus; + EventTimestamp = eventTimestamp; + SubmissionTimestamp = submissionTimestamp; + SubscriptionId = subscriptionId; + TenantId = tenantId; + } + + /// The sender authorization information. + public SenderAuthorization Authorization { get; } + /// key value pairs to identify ARM permissions. + public IReadOnlyDictionary Claims { get; } + /// the email address of the user who has performed the operation, the UPN claim or SPN claim based on availability. + public string Caller { get; } + /// the description of the event. + public string Description { get; } + /// the Id of this event as required by ARM for RBAC. It contains the EventDataID and a timestamp information. + public string Id { get; } + /// the event data Id. This is a unique identifier for an event. + public string EventDataId { get; } + /// the correlation Id, usually a GUID in the string format. The correlation Id is shared among the events that belong to the same uber operation. + public string CorrelationId { get; } + /// the event name. This value should not be confused with OperationName. For practical purposes, OperationName might be more appealing to end users. + public LocalizableString EventName { get; } + /// the event category. + public LocalizableString Category { get; } + /// the HTTP request info. Usually includes the 'clientRequestId', 'clientIpAddress' (IP address of the user who initiated the event) and 'method' (HTTP method e.g. PUT). + public HttpRequestInfo HttpRequest { get; } + /// the event level. + public EventLevel? Level { get; } + /// the resource group name of the impacted resource. + public string ResourceGroupName { get; } + /// the resource provider name of the impacted resource. + public LocalizableString ResourceProviderName { get; } + /// the resource uri that uniquely identifies the resource that caused this event. + public string ResourceId { get; } + /// the resource type. + public LocalizableString ResourceType { get; } + /// It is usually a GUID shared among the events corresponding to single operation. This value should not be confused with EventName. + public string OperationId { get; } + /// the operation name. + public LocalizableString OperationName { get; } + /// the set of <Key, Value> pairs (usually a Dictionary<String, String>) that includes details about the event. + public IReadOnlyDictionary Properties { get; } + /// a string describing the status of the operation. Some typical values are: Started, In progress, Succeeded, Failed, Resolved. + public LocalizableString Status { get; } + /// the event sub status. Most of the time, when included, this captures the HTTP status code of the REST call. Common values are: OK (HTTP Status Code: 200), Created (HTTP Status Code: 201), Accepted (HTTP Status Code: 202), No Content (HTTP Status Code: 204), Bad Request(HTTP Status Code: 400), Not Found (HTTP Status Code: 404), Conflict (HTTP Status Code: 409), Internal Server Error (HTTP Status Code: 500), Service Unavailable (HTTP Status Code:503), Gateway Timeout (HTTP Status Code: 504). + public LocalizableString SubStatus { get; } + /// the timestamp of when the event was generated by the Azure service processing the request corresponding the event. It in ISO 8601 format. + public DateTimeOffset? EventTimestamp { get; } + /// the timestamp of when the event became available for querying via this API. It is in ISO 8601 format. This value should not be confused eventTimestamp. As there might be a delay between the occurrence time of the event, and the time that the event is submitted to the Azure logging infrastructure. + public DateTimeOffset? SubmissionTimestamp { get; } + /// the Azure subscription Id usually a GUID. + public string SubscriptionId { get; } + /// the Azure tenant Id. + public string TenantId { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventDataCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventDataCollection.Serialization.cs new file mode 100644 index 000000000000..d6f6e854113c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventDataCollection.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class EventDataCollection + { + internal static EventDataCollection DeserializeEventDataCollection(JsonElement element) + { + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EventData.DeserializeEventData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new EventDataCollection(value, nextLink.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventDataCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventDataCollection.cs new file mode 100644 index 000000000000..c4988df3bdc4 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventDataCollection.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents collection of events. + public partial class EventDataCollection + { + /// Initializes a new instance of EventDataCollection. + /// this list that includes the Azure audit logs. + /// is null. + internal EventDataCollection(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of EventDataCollection. + /// this list that includes the Azure audit logs. + /// Provides the link to retrieve the next set of events. + internal EventDataCollection(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// this list that includes the Azure audit logs. + public IReadOnlyList Value { get; } + /// Provides the link to retrieve the next set of events. + public string NextLink { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventLevel.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventLevel.Serialization.cs new file mode 100644 index 000000000000..a4ebff235c58 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventLevel.Serialization.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class EventLevelExtensions + { + public static string ToSerialString(this EventLevel value) => value switch + { + EventLevel.Critical => "Critical", + EventLevel.Error => "Error", + EventLevel.Warning => "Warning", + EventLevel.Informational => "Informational", + EventLevel.Verbose => "Verbose", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EventLevel value.") + }; + + public static EventLevel ToEventLevel(this string value) + { + if (string.Equals(value, "Critical", StringComparison.InvariantCultureIgnoreCase)) return EventLevel.Critical; + if (string.Equals(value, "Error", StringComparison.InvariantCultureIgnoreCase)) return EventLevel.Error; + if (string.Equals(value, "Warning", StringComparison.InvariantCultureIgnoreCase)) return EventLevel.Warning; + if (string.Equals(value, "Informational", StringComparison.InvariantCultureIgnoreCase)) return EventLevel.Informational; + if (string.Equals(value, "Verbose", StringComparison.InvariantCultureIgnoreCase)) return EventLevel.Verbose; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EventLevel value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventLevel.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventLevel.cs new file mode 100644 index 000000000000..d13bb900341d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/EventLevel.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the event level. + public enum EventLevel + { + /// Critical. + Critical, + /// Error. + Error, + /// Warning. + Warning, + /// Informational. + Informational, + /// Verbose. + Verbose + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/HttpRequestInfo.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/HttpRequestInfo.Serialization.cs new file mode 100644 index 000000000000..03d85c00a680 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/HttpRequestInfo.Serialization.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class HttpRequestInfo + { + internal static HttpRequestInfo DeserializeHttpRequestInfo(JsonElement element) + { + Optional clientRequestId = default; + Optional clientIpAddress = default; + Optional method = default; + Optional uri = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("clientRequestId")) + { + clientRequestId = property.Value.GetString(); + continue; + } + if (property.NameEquals("clientIpAddress")) + { + clientIpAddress = property.Value.GetString(); + continue; + } + if (property.NameEquals("method")) + { + method = property.Value.GetString(); + continue; + } + if (property.NameEquals("uri")) + { + uri = property.Value.GetString(); + continue; + } + } + return new HttpRequestInfo(clientRequestId.Value, clientIpAddress.Value, method.Value, uri.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/HttpRequestInfo.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/HttpRequestInfo.cs new file mode 100644 index 000000000000..76a14b7951d8 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/HttpRequestInfo.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The Http request info. + public partial class HttpRequestInfo + { + /// Initializes a new instance of HttpRequestInfo. + internal HttpRequestInfo() + { + } + + /// Initializes a new instance of HttpRequestInfo. + /// the client request id. + /// the client Ip Address. + /// the Http request method. + /// the Uri. + internal HttpRequestInfo(string clientRequestId, string clientIpAddress, string method, string uri) + { + ClientRequestId = clientRequestId; + ClientIpAddress = clientIpAddress; + Method = method; + Uri = uri; + } + + /// the client request id. + public string ClientRequestId { get; } + /// the client Ip Address. + public string ClientIpAddress { get; } + /// the Http request method. + public string Method { get; } + /// the Uri. + public string Uri { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Incident.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Incident.Serialization.cs new file mode 100644 index 000000000000..3032b9253670 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Incident.Serialization.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Incident + { + internal static Incident DeserializeIncident(JsonElement element) + { + Optional name = default; + Optional ruleName = default; + Optional isActive = default; + Optional activatedTime = default; + Optional resolvedTime = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("ruleName")) + { + ruleName = property.Value.GetString(); + continue; + } + if (property.NameEquals("isActive")) + { + isActive = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("activatedTime")) + { + activatedTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("resolvedTime")) + { + resolvedTime = property.Value.GetDateTimeOffset("O"); + continue; + } + } + return new Incident(name.Value, ruleName.Value, Optional.ToNullable(isActive), Optional.ToNullable(activatedTime), Optional.ToNullable(resolvedTime)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Incident.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Incident.cs new file mode 100644 index 000000000000..86ffd9ae0914 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Incident.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An alert incident indicates the activation status of an alert rule. + public partial class Incident + { + /// Initializes a new instance of Incident. + internal Incident() + { + } + + /// Initializes a new instance of Incident. + /// Incident name. + /// Rule name that is associated with the incident. + /// A boolean to indicate whether the incident is active or resolved. + /// The time at which the incident was activated in ISO8601 format. + /// The time at which the incident was resolved in ISO8601 format. If null, it means the incident is still active. + internal Incident(string name, string ruleName, bool? isActive, DateTimeOffset? activatedTime, DateTimeOffset? resolvedTime) + { + Name = name; + RuleName = ruleName; + IsActive = isActive; + ActivatedTime = activatedTime; + ResolvedTime = resolvedTime; + } + + /// Incident name. + public string Name { get; } + /// Rule name that is associated with the incident. + public string RuleName { get; } + /// A boolean to indicate whether the incident is active or resolved. + public bool? IsActive { get; } + /// The time at which the incident was activated in ISO8601 format. + public DateTimeOffset? ActivatedTime { get; } + /// The time at which the incident was resolved in ISO8601 format. If null, it means the incident is still active. + public DateTimeOffset? ResolvedTime { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/IncidentListResult.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/IncidentListResult.Serialization.cs new file mode 100644 index 000000000000..faef77cd0848 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/IncidentListResult.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class IncidentListResult + { + internal static IncidentListResult DeserializeIncidentListResult(JsonElement element) + { + Optional> value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Incident.DeserializeIncident(item)); + } + value = array; + continue; + } + } + return new IncidentListResult(Optional.ToList(value)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/IncidentListResult.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/IncidentListResult.cs new file mode 100644 index 000000000000..01edabcd0423 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/IncidentListResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The List incidents operation response. + public partial class IncidentListResult + { + /// Initializes a new instance of IncidentListResult. + internal IncidentListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of IncidentListResult. + /// the incident collection. + internal IncidentListResult(IReadOnlyList value) + { + Value = value; + } + + /// the incident collection. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ItsmReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ItsmReceiver.Serialization.cs new file mode 100644 index 000000000000..4e5b8c310983 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ItsmReceiver.Serialization.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ItsmReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("workspaceId"); + writer.WriteStringValue(WorkspaceId); + writer.WritePropertyName("connectionId"); + writer.WriteStringValue(ConnectionId); + writer.WritePropertyName("ticketConfiguration"); + writer.WriteStringValue(TicketConfiguration); + writer.WritePropertyName("region"); + writer.WriteStringValue(Region); + writer.WriteEndObject(); + } + + internal static ItsmReceiver DeserializeItsmReceiver(JsonElement element) + { + string name = default; + string workspaceId = default; + string connectionId = default; + string ticketConfiguration = default; + string region = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("workspaceId")) + { + workspaceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("connectionId")) + { + connectionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("ticketConfiguration")) + { + ticketConfiguration = property.Value.GetString(); + continue; + } + if (property.NameEquals("region")) + { + region = property.Value.GetString(); + continue; + } + } + return new ItsmReceiver(name, workspaceId, connectionId, ticketConfiguration, region); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ItsmReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ItsmReceiver.cs new file mode 100644 index 000000000000..c681b0fe74e1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ItsmReceiver.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An Itsm receiver. + public partial class ItsmReceiver + { + /// Initializes a new instance of ItsmReceiver. + /// The name of the Itsm receiver. Names must be unique across all receivers within an action group. + /// OMS LA instance identifier. + /// Unique identification of ITSM connection among multiple defined in above workspace. + /// JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. + /// Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + /// , , , , or is null. + public ItsmReceiver(string name, string workspaceId, string connectionId, string ticketConfiguration, string region) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (workspaceId == null) + { + throw new ArgumentNullException(nameof(workspaceId)); + } + if (connectionId == null) + { + throw new ArgumentNullException(nameof(connectionId)); + } + if (ticketConfiguration == null) + { + throw new ArgumentNullException(nameof(ticketConfiguration)); + } + if (region == null) + { + throw new ArgumentNullException(nameof(region)); + } + + Name = name; + WorkspaceId = workspaceId; + ConnectionId = connectionId; + TicketConfiguration = ticketConfiguration; + Region = region; + } + + /// The name of the Itsm receiver. Names must be unique across all receivers within an action group. + public string Name { get; set; } + /// OMS LA instance identifier. + public string WorkspaceId { get; set; } + /// Unique identification of ITSM connection among multiple defined in above workspace. + public string ConnectionId { get; set; } + /// JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. + public string TicketConfiguration { get; set; } + /// Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + public string Region { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocalizableString.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocalizableString.Serialization.cs new file mode 100644 index 000000000000..c656023eadda --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocalizableString.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LocalizableString + { + internal static LocalizableString DeserializeLocalizableString(JsonElement element) + { + string value = default; + Optional localizedValue = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("localizedValue")) + { + localizedValue = property.Value.GetString(); + continue; + } + } + return new LocalizableString(value, localizedValue.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocalizableString.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocalizableString.cs new file mode 100644 index 000000000000..31d720ffc640 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocalizableString.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The localizable string class. + public partial class LocalizableString + { + /// Initializes a new instance of LocalizableString. + /// the invariant value. + /// is null. + internal LocalizableString(string value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value; + } + + /// Initializes a new instance of LocalizableString. + /// the invariant value. + /// the locale specific value. + internal LocalizableString(string value, string localizedValue) + { + Value = value; + LocalizedValue = localizedValue; + } + + /// the invariant value. + public string Value { get; } + /// the locale specific value. + public string LocalizedValue { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocationThresholdRuleCondition.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocationThresholdRuleCondition.Serialization.cs new file mode 100644 index 000000000000..75eb8f9d0c1b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocationThresholdRuleCondition.Serialization.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LocationThresholdRuleCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(WindowSize)) + { + writer.WritePropertyName("windowSize"); + writer.WriteStringValue(WindowSize.Value, "P"); + } + writer.WritePropertyName("failedLocationCount"); + writer.WriteNumberValue(FailedLocationCount); + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + if (Optional.IsDefined(DataSource)) + { + writer.WritePropertyName("dataSource"); + writer.WriteObjectValue(DataSource); + } + writer.WriteEndObject(); + } + + internal static LocationThresholdRuleCondition DeserializeLocationThresholdRuleCondition(JsonElement element) + { + Optional windowSize = default; + int failedLocationCount = default; + string odataType = default; + Optional dataSource = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("windowSize")) + { + windowSize = property.Value.GetTimeSpan("P"); + continue; + } + if (property.NameEquals("failedLocationCount")) + { + failedLocationCount = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("dataSource")) + { + dataSource = RuleDataSource.DeserializeRuleDataSource(property.Value); + continue; + } + } + return new LocationThresholdRuleCondition(odataType, dataSource.Value, Optional.ToNullable(windowSize), failedLocationCount); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocationThresholdRuleCondition.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocationThresholdRuleCondition.cs new file mode 100644 index 000000000000..2557f35ca241 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LocationThresholdRuleCondition.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A rule condition based on a certain number of locations failing. + public partial class LocationThresholdRuleCondition : RuleCondition + { + /// Initializes a new instance of LocationThresholdRuleCondition. + /// the number of locations that must fail to activate the alert. + public LocationThresholdRuleCondition(int failedLocationCount) + { + FailedLocationCount = failedLocationCount; + OdataType = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition"; + } + + /// Initializes a new instance of LocationThresholdRuleCondition. + /// specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric). + /// the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + /// the number of locations that must fail to activate the alert. + internal LocationThresholdRuleCondition(string odataType, RuleDataSource dataSource, TimeSpan? windowSize, int failedLocationCount) : base(odataType, dataSource) + { + WindowSize = windowSize; + FailedLocationCount = failedLocationCount; + OdataType = odataType ?? "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition"; + } + + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + public TimeSpan? WindowSize { get; set; } + /// the number of locations that must fail to activate the alert. + public int FailedLocationCount { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogMetricTrigger.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogMetricTrigger.Serialization.cs new file mode 100644 index 000000000000..b29f24be9730 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogMetricTrigger.Serialization.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogMetricTrigger : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ThresholdOperator)) + { + writer.WritePropertyName("thresholdOperator"); + writer.WriteStringValue(ThresholdOperator.Value.ToString()); + } + if (Optional.IsDefined(Threshold)) + { + writer.WritePropertyName("threshold"); + writer.WriteNumberValue(Threshold.Value); + } + if (Optional.IsDefined(MetricTriggerType)) + { + writer.WritePropertyName("metricTriggerType"); + writer.WriteStringValue(MetricTriggerType.Value.ToString()); + } + if (Optional.IsDefined(MetricColumn)) + { + writer.WritePropertyName("metricColumn"); + writer.WriteStringValue(MetricColumn); + } + writer.WriteEndObject(); + } + + internal static LogMetricTrigger DeserializeLogMetricTrigger(JsonElement element) + { + Optional thresholdOperator = default; + Optional threshold = default; + Optional metricTriggerType = default; + Optional metricColumn = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("thresholdOperator")) + { + thresholdOperator = new ConditionalOperator(property.Value.GetString()); + continue; + } + if (property.NameEquals("threshold")) + { + threshold = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("metricTriggerType")) + { + metricTriggerType = new MetricTriggerType(property.Value.GetString()); + continue; + } + if (property.NameEquals("metricColumn")) + { + metricColumn = property.Value.GetString(); + continue; + } + } + return new LogMetricTrigger(Optional.ToNullable(thresholdOperator), Optional.ToNullable(threshold), Optional.ToNullable(metricTriggerType), metricColumn.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogMetricTrigger.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogMetricTrigger.cs new file mode 100644 index 000000000000..d6ca3090f043 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogMetricTrigger.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// A log metrics trigger descriptor. + public partial class LogMetricTrigger + { + /// Initializes a new instance of LogMetricTrigger. + public LogMetricTrigger() + { + } + + /// Initializes a new instance of LogMetricTrigger. + /// Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. + /// The threshold of the metric trigger. + /// Metric Trigger Type - 'Consecutive' or 'Total'. + /// Evaluation of metric on a particular column. + internal LogMetricTrigger(ConditionalOperator? thresholdOperator, double? threshold, MetricTriggerType? metricTriggerType, string metricColumn) + { + ThresholdOperator = thresholdOperator; + Threshold = threshold; + MetricTriggerType = metricTriggerType; + MetricColumn = metricColumn; + } + + /// Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. + public ConditionalOperator? ThresholdOperator { get; set; } + /// The threshold of the metric trigger. + public double? Threshold { get; set; } + /// Metric Trigger Type - 'Consecutive' or 'Total'. + public MetricTriggerType? MetricTriggerType { get; set; } + /// Evaluation of metric on a particular column. + public string MetricColumn { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileCollection.Serialization.cs new file mode 100644 index 000000000000..c577b429fa34 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogProfileCollection + { + internal static LogProfileCollection DeserializeLogProfileCollection(JsonElement element) + { + IReadOnlyList value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LogProfileResource.DeserializeLogProfileResource(item)); + } + value = array; + continue; + } + } + return new LogProfileCollection(value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileCollection.cs new file mode 100644 index 000000000000..34fba8c1608e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileCollection.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a collection of log profiles. + public partial class LogProfileCollection + { + /// Initializes a new instance of LogProfileCollection. + /// the values of the log profiles. + /// is null. + internal LogProfileCollection(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of LogProfileCollection. + /// the values of the log profiles. + internal LogProfileCollection(IReadOnlyList value) + { + Value = value; + } + + /// the values of the log profiles. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResource.Serialization.cs new file mode 100644 index 000000000000..f94f2cad41ce --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResource.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogProfileResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("location"); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(StorageAccountId)) + { + writer.WritePropertyName("storageAccountId"); + writer.WriteStringValue(StorageAccountId); + } + if (Optional.IsDefined(ServiceBusRuleId)) + { + writer.WritePropertyName("serviceBusRuleId"); + writer.WriteStringValue(ServiceBusRuleId); + } + writer.WritePropertyName("locations"); + writer.WriteStartArray(); + foreach (var item in Locations) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("categories"); + writer.WriteStartArray(); + foreach (var item in Categories) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("retentionPolicy"); + writer.WriteObjectValue(RetentionPolicy); + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static LogProfileResource DeserializeLogProfileResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + string location = default; + Optional> tags = default; + Optional storageAccountId = default; + Optional serviceBusRuleId = default; + IList locations = default; + IList categories = default; + RetentionPolicy retentionPolicy = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location")) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("storageAccountId")) + { + storageAccountId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("serviceBusRuleId")) + { + serviceBusRuleId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("locations")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + locations = array; + continue; + } + if (property0.NameEquals("categories")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + categories = array; + continue; + } + if (property0.NameEquals("retentionPolicy")) + { + retentionPolicy = RetentionPolicy.DeserializeRetentionPolicy(property0.Value); + continue; + } + } + continue; + } + } + return new LogProfileResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), storageAccountId.Value, serviceBusRuleId.Value, locations, categories, retentionPolicy); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResource.cs new file mode 100644 index 000000000000..7838da4bc514 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResource.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The log profile resource. + public partial class LogProfileResource : Resource + { + /// Initializes a new instance of LogProfileResource. + /// Resource location. + /// List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. + /// the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + /// the retention policy for the events in the log. + /// , , , or is null. + public LogProfileResource(string location, IEnumerable locations, IEnumerable categories, RetentionPolicy retentionPolicy) : base(location) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + if (locations == null) + { + throw new ArgumentNullException(nameof(locations)); + } + if (categories == null) + { + throw new ArgumentNullException(nameof(categories)); + } + if (retentionPolicy == null) + { + throw new ArgumentNullException(nameof(retentionPolicy)); + } + + Locations = locations.ToList(); + Categories = categories.ToList(); + RetentionPolicy = retentionPolicy; + } + + /// Initializes a new instance of LogProfileResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// Resource location. + /// Resource tags. + /// the resource id of the storage account to which you would like to send the Activity Log. + /// The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. + /// List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. + /// the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + /// the retention policy for the events in the log. + internal LogProfileResource(string id, string name, string type, string location, IDictionary tags, string storageAccountId, string serviceBusRuleId, IList locations, IList categories, RetentionPolicy retentionPolicy) : base(id, name, type, location, tags) + { + StorageAccountId = storageAccountId; + ServiceBusRuleId = serviceBusRuleId; + Locations = locations; + Categories = categories; + RetentionPolicy = retentionPolicy; + } + + /// the resource id of the storage account to which you would like to send the Activity Log. + public string StorageAccountId { get; set; } + /// The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. + public string ServiceBusRuleId { get; set; } + /// List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. + public IList Locations { get; } + /// the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + public IList Categories { get; } + /// the retention policy for the events in the log. + public RetentionPolicy RetentionPolicy { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResourcePatch.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResourcePatch.Serialization.cs new file mode 100644 index 000000000000..aec396834801 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResourcePatch.Serialization.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogProfileResourcePatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(StorageAccountId)) + { + writer.WritePropertyName("storageAccountId"); + writer.WriteStringValue(StorageAccountId); + } + if (Optional.IsDefined(ServiceBusRuleId)) + { + writer.WritePropertyName("serviceBusRuleId"); + writer.WriteStringValue(ServiceBusRuleId); + } + if (Optional.IsCollectionDefined(Locations)) + { + writer.WritePropertyName("locations"); + writer.WriteStartArray(); + foreach (var item in Locations) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Categories)) + { + writer.WritePropertyName("categories"); + writer.WriteStartArray(); + foreach (var item in Categories) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(RetentionPolicy)) + { + writer.WritePropertyName("retentionPolicy"); + writer.WriteObjectValue(RetentionPolicy); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResourcePatch.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResourcePatch.cs new file mode 100644 index 000000000000..452b273da333 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogProfileResourcePatch.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The log profile resource for patch operations. + public partial class LogProfileResourcePatch + { + /// Initializes a new instance of LogProfileResourcePatch. + public LogProfileResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + Locations = new ChangeTrackingList(); + Categories = new ChangeTrackingList(); + } + + /// Resource tags. + public IDictionary Tags { get; } + /// the resource id of the storage account to which you would like to send the Activity Log. + public string StorageAccountId { get; set; } + /// The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. + public string ServiceBusRuleId { get; set; } + /// List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. + public IList Locations { get; } + /// the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + public IList Categories { get; } + /// the retention policy for the events in the log. + public RetentionPolicy RetentionPolicy { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResource.Serialization.cs new file mode 100644 index 000000000000..f093e04ac317 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResource.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogSearchRuleResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("location"); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"); + writer.WriteStringValue(Enabled.Value.ToString()); + } + writer.WritePropertyName("source"); + writer.WriteObjectValue(Source); + if (Optional.IsDefined(Schedule)) + { + writer.WritePropertyName("schedule"); + writer.WriteObjectValue(Schedule); + } + writer.WritePropertyName("action"); + writer.WriteObjectValue(Action); + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static LogSearchRuleResource DeserializeLogSearchRuleResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + string location = default; + Optional> tags = default; + Optional description = default; + Optional enabled = default; + Optional lastUpdatedTime = default; + Optional provisioningState = default; + Source source = default; + Optional schedule = default; + Action action = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location")) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("description")) + { + description = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("enabled")) + { + enabled = new Enabled(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("lastUpdatedTime")) + { + lastUpdatedTime = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("provisioningState")) + { + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("source")) + { + source = Source.DeserializeSource(property0.Value); + continue; + } + if (property0.NameEquals("schedule")) + { + schedule = Schedule.DeserializeSchedule(property0.Value); + continue; + } + if (property0.NameEquals("action")) + { + action = Action.DeserializeAction(property0.Value); + continue; + } + } + continue; + } + } + return new LogSearchRuleResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), description.Value, Optional.ToNullable(enabled), Optional.ToNullable(lastUpdatedTime), Optional.ToNullable(provisioningState), source, schedule.Value, action); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResource.cs new file mode 100644 index 000000000000..0cc6ac3d8ae2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResource.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The Log Search Rule resource. + public partial class LogSearchRuleResource : Resource + { + /// Initializes a new instance of LogSearchRuleResource. + /// Resource location. + /// Data Source against which rule will Query Data. + /// Action needs to be taken on rule execution. + /// , , or is null. + public LogSearchRuleResource(string location, Source source, Action action) : base(location) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + if (action == null) + { + throw new ArgumentNullException(nameof(action)); + } + + Source = source; + Action = action; + } + + /// Initializes a new instance of LogSearchRuleResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// Resource location. + /// Resource tags. + /// The description of the Log Search rule. + /// The flag which indicates whether the Log Search rule is enabled. Value should be true or false. + /// Last time the rule was updated in IS08601 format. + /// Provisioning state of the scheduled query rule. + /// Data Source against which rule will Query Data. + /// Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction. + /// Action needs to be taken on rule execution. + internal LogSearchRuleResource(string id, string name, string type, string location, IDictionary tags, string description, Enabled? enabled, DateTimeOffset? lastUpdatedTime, ProvisioningState? provisioningState, Source source, Schedule schedule, Action action) : base(id, name, type, location, tags) + { + Description = description; + Enabled = enabled; + LastUpdatedTime = lastUpdatedTime; + ProvisioningState = provisioningState; + Source = source; + Schedule = schedule; + Action = action; + } + + /// The description of the Log Search rule. + public string Description { get; set; } + /// The flag which indicates whether the Log Search rule is enabled. Value should be true or false. + public Enabled? Enabled { get; set; } + /// Last time the rule was updated in IS08601 format. + public DateTimeOffset? LastUpdatedTime { get; } + /// Provisioning state of the scheduled query rule. + public ProvisioningState? ProvisioningState { get; } + /// Data Source against which rule will Query Data. + public Source Source { get; set; } + /// Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction. + public Schedule Schedule { get; set; } + /// Action needs to be taken on rule execution. + public Action Action { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourceCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourceCollection.Serialization.cs new file mode 100644 index 000000000000..3a8305688f7c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourceCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogSearchRuleResourceCollection + { + internal static LogSearchRuleResourceCollection DeserializeLogSearchRuleResourceCollection(JsonElement element) + { + Optional> value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LogSearchRuleResource.DeserializeLogSearchRuleResource(item)); + } + value = array; + continue; + } + } + return new LogSearchRuleResourceCollection(Optional.ToList(value)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourceCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourceCollection.cs new file mode 100644 index 000000000000..6b501a077713 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourceCollection.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a collection of Log Search rule resources. + public partial class LogSearchRuleResourceCollection + { + /// Initializes a new instance of LogSearchRuleResourceCollection. + internal LogSearchRuleResourceCollection() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of LogSearchRuleResourceCollection. + /// The values for the Log Search Rule resources. + internal LogSearchRuleResourceCollection(IReadOnlyList value) + { + Value = value; + } + + /// The values for the Log Search Rule resources. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourcePatch.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourcePatch.Serialization.cs new file mode 100644 index 000000000000..3df4da7da303 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourcePatch.Serialization.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogSearchRuleResourcePatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"); + writer.WriteStringValue(Enabled.Value.ToString()); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourcePatch.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourcePatch.cs new file mode 100644 index 000000000000..82d0bd515581 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSearchRuleResourcePatch.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The log search rule resource for patch operations. + public partial class LogSearchRuleResourcePatch + { + /// Initializes a new instance of LogSearchRuleResourcePatch. + public LogSearchRuleResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Resource tags. + public IDictionary Tags { get; } + /// The flag which indicates whether the Log Search rule is enabled. Value should be true or false. + public Enabled? Enabled { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSettings.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSettings.Serialization.cs new file mode 100644 index 000000000000..fff54a3cb090 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSettings.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogSettings : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Category)) + { + writer.WritePropertyName("category"); + writer.WriteStringValue(Category); + } + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled); + if (Optional.IsDefined(RetentionPolicy)) + { + writer.WritePropertyName("retentionPolicy"); + writer.WriteObjectValue(RetentionPolicy); + } + writer.WriteEndObject(); + } + + internal static LogSettings DeserializeLogSettings(JsonElement element) + { + Optional category = default; + bool enabled = default; + Optional retentionPolicy = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("category")) + { + category = property.Value.GetString(); + continue; + } + if (property.NameEquals("enabled")) + { + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("retentionPolicy")) + { + retentionPolicy = RetentionPolicy.DeserializeRetentionPolicy(property.Value); + continue; + } + } + return new LogSettings(category.Value, enabled, retentionPolicy.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSettings.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSettings.cs new file mode 100644 index 000000000000..a8bdc5ea2a91 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogSettings.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. + public partial class LogSettings + { + /// Initializes a new instance of LogSettings. + /// a value indicating whether this log is enabled. + public LogSettings(bool enabled) + { + Enabled = enabled; + } + + /// Initializes a new instance of LogSettings. + /// Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. + /// a value indicating whether this log is enabled. + /// the retention policy for this log. + internal LogSettings(string category, bool enabled, RetentionPolicy retentionPolicy) + { + Category = category; + Enabled = enabled; + RetentionPolicy = retentionPolicy; + } + + /// Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. + public string Category { get; set; } + /// a value indicating whether this log is enabled. + public bool Enabled { get; set; } + /// the retention policy for this log. + public RetentionPolicy RetentionPolicy { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogToMetricAction.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogToMetricAction.Serialization.cs new file mode 100644 index 000000000000..870d67f948bf --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogToMetricAction.Serialization.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogToMetricAction : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("criteria"); + writer.WriteStartArray(); + foreach (var item in Criteria) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + writer.WriteEndObject(); + } + + internal static LogToMetricAction DeserializeLogToMetricAction(JsonElement element) + { + IList criteria = default; + string odataType = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("criteria")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Models.Criteria.DeserializeCriteria(item)); + } + criteria = array; + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + } + return new LogToMetricAction(odataType, criteria); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogToMetricAction.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogToMetricAction.cs new file mode 100644 index 000000000000..da3becafff23 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogToMetricAction.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specify action need to be taken when rule type is converting log to metric. + public partial class LogToMetricAction : Action + { + /// Initializes a new instance of LogToMetricAction. + /// Criteria of Metric. + /// is null. + public LogToMetricAction(IEnumerable criteria) + { + if (criteria == null) + { + throw new ArgumentNullException(nameof(criteria)); + } + + Criteria = criteria.ToList(); + OdataType = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction"; + } + + /// Initializes a new instance of LogToMetricAction. + /// Specifies the action. Supported values - AlertingAction, LogToMetricAction. + /// Criteria of Metric. + internal LogToMetricAction(string odataType, IList criteria) : base(odataType) + { + Criteria = criteria; + OdataType = odataType ?? "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction"; + } + + /// Criteria of Metric. + public IList Criteria { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogicAppReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogicAppReceiver.Serialization.cs new file mode 100644 index 000000000000..3ba8ba87b3b0 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogicAppReceiver.Serialization.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class LogicAppReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("resourceId"); + writer.WriteStringValue(ResourceId); + writer.WritePropertyName("callbackUrl"); + writer.WriteStringValue(CallbackUrl); + writer.WritePropertyName("useCommonAlertSchema"); + writer.WriteBooleanValue(UseCommonAlertSchema); + writer.WriteEndObject(); + } + + internal static LogicAppReceiver DeserializeLogicAppReceiver(JsonElement element) + { + string name = default; + string resourceId = default; + string callbackUrl = default; + bool useCommonAlertSchema = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceId")) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("callbackUrl")) + { + callbackUrl = property.Value.GetString(); + continue; + } + if (property.NameEquals("useCommonAlertSchema")) + { + useCommonAlertSchema = property.Value.GetBoolean(); + continue; + } + } + return new LogicAppReceiver(name, resourceId, callbackUrl, useCommonAlertSchema); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogicAppReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogicAppReceiver.cs new file mode 100644 index 000000000000..9b8e39bf2afa --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/LogicAppReceiver.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A logic app receiver. + public partial class LogicAppReceiver + { + /// Initializes a new instance of LogicAppReceiver. + /// The name of the logic app receiver. Names must be unique across all receivers within an action group. + /// The azure resource id of the logic app receiver. + /// The callback url where http request sent to. + /// Indicates whether to use common alert schema. + /// , , or is null. + public LogicAppReceiver(string name, string resourceId, string callbackUrl, bool useCommonAlertSchema) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (resourceId == null) + { + throw new ArgumentNullException(nameof(resourceId)); + } + if (callbackUrl == null) + { + throw new ArgumentNullException(nameof(callbackUrl)); + } + + Name = name; + ResourceId = resourceId; + CallbackUrl = callbackUrl; + UseCommonAlertSchema = useCommonAlertSchema; + } + + /// The name of the logic app receiver. Names must be unique across all receivers within an action group. + public string Name { get; set; } + /// The azure resource id of the logic app receiver. + public string ResourceId { get; set; } + /// The callback url where http request sent to. + public string CallbackUrl { get; set; } + /// Indicates whether to use common alert schema. + public bool UseCommonAlertSchema { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventAggregationCondition.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventAggregationCondition.Serialization.cs new file mode 100644 index 000000000000..a6007cc120fa --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventAggregationCondition.Serialization.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ManagementEventAggregationCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Operator)) + { + writer.WritePropertyName("operator"); + writer.WriteStringValue(Operator.Value.ToSerialString()); + } + if (Optional.IsDefined(Threshold)) + { + writer.WritePropertyName("threshold"); + writer.WriteNumberValue(Threshold.Value); + } + if (Optional.IsDefined(WindowSize)) + { + writer.WritePropertyName("windowSize"); + writer.WriteStringValue(WindowSize.Value, "P"); + } + writer.WriteEndObject(); + } + + internal static ManagementEventAggregationCondition DeserializeManagementEventAggregationCondition(JsonElement element) + { + Optional @operator = default; + Optional threshold = default; + Optional windowSize = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operator")) + { + @operator = property.Value.GetString().ToConditionOperator(); + continue; + } + if (property.NameEquals("threshold")) + { + threshold = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("windowSize")) + { + windowSize = property.Value.GetTimeSpan("P"); + continue; + } + } + return new ManagementEventAggregationCondition(Optional.ToNullable(@operator), Optional.ToNullable(threshold), Optional.ToNullable(windowSize)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventAggregationCondition.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventAggregationCondition.cs new file mode 100644 index 000000000000..f35532e5dd55 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventAggregationCondition.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// How the data that is collected should be combined over time. + public partial class ManagementEventAggregationCondition + { + /// Initializes a new instance of ManagementEventAggregationCondition. + public ManagementEventAggregationCondition() + { + } + + /// Initializes a new instance of ManagementEventAggregationCondition. + /// the condition operator. + /// The threshold value that activates the alert. + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + internal ManagementEventAggregationCondition(ConditionOperator? @operator, double? threshold, TimeSpan? windowSize) + { + Operator = @operator; + Threshold = threshold; + WindowSize = windowSize; + } + + /// the condition operator. + public ConditionOperator? Operator { get; set; } + /// The threshold value that activates the alert. + public double? Threshold { get; set; } + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + public TimeSpan? WindowSize { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventRuleCondition.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventRuleCondition.Serialization.cs new file mode 100644 index 000000000000..66be16a0974c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventRuleCondition.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ManagementEventRuleCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Aggregation)) + { + writer.WritePropertyName("aggregation"); + writer.WriteObjectValue(Aggregation); + } + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + if (Optional.IsDefined(DataSource)) + { + writer.WritePropertyName("dataSource"); + writer.WriteObjectValue(DataSource); + } + writer.WriteEndObject(); + } + + internal static ManagementEventRuleCondition DeserializeManagementEventRuleCondition(JsonElement element) + { + Optional aggregation = default; + string odataType = default; + Optional dataSource = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("aggregation")) + { + aggregation = ManagementEventAggregationCondition.DeserializeManagementEventAggregationCondition(property.Value); + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("dataSource")) + { + dataSource = RuleDataSource.DeserializeRuleDataSource(property.Value); + continue; + } + } + return new ManagementEventRuleCondition(odataType, dataSource.Value, aggregation.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventRuleCondition.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventRuleCondition.cs new file mode 100644 index 000000000000..671f11ea5f74 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ManagementEventRuleCondition.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// A management event rule condition. + public partial class ManagementEventRuleCondition : RuleCondition + { + /// Initializes a new instance of ManagementEventRuleCondition. + public ManagementEventRuleCondition() + { + OdataType = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition"; + } + + /// Initializes a new instance of ManagementEventRuleCondition. + /// specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric). + /// the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + /// How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. + internal ManagementEventRuleCondition(string odataType, RuleDataSource dataSource, ManagementEventAggregationCondition aggregation) : base(odataType, dataSource) + { + Aggregation = aggregation; + OdataType = odataType ?? "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition"; + } + + /// How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. + public ManagementEventAggregationCondition Aggregation { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetadataValue.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetadataValue.Serialization.cs new file mode 100644 index 000000000000..0145a60933bf --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetadataValue.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetadataValue + { + internal static MetadataValue DeserializeMetadataValue(JsonElement element) + { + Optional name = default; + Optional value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("value")) + { + value = property.Value.GetString(); + continue; + } + } + return new MetadataValue(name.Value, value.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetadataValue.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetadataValue.cs new file mode 100644 index 000000000000..c2596b486154 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetadataValue.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a metric metadata value. + public partial class MetadataValue + { + /// Initializes a new instance of MetadataValue. + internal MetadataValue() + { + } + + /// Initializes a new instance of MetadataValue. + /// the name of the metadata. + /// the value of the metadata. + internal MetadataValue(LocalizableString name, string value) + { + Name = name; + Value = value; + } + + /// the name of the metadata. + public LocalizableString Name { get; } + /// the value of the metadata. + public string Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Metric.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Metric.Serialization.cs new file mode 100644 index 000000000000..d92d69e84c04 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Metric.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Metric + { + internal static Metric DeserializeMetric(JsonElement element) + { + string id = default; + string type = default; + LocalizableString name = default; + Unit unit = default; + IReadOnlyList timeseries = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("unit")) + { + unit = property.Value.GetString().ToUnit(); + continue; + } + if (property.NameEquals("timeseries")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TimeSeriesElement.DeserializeTimeSeriesElement(item)); + } + timeseries = array; + continue; + } + } + return new Metric(id, type, name, unit, timeseries); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Metric.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Metric.cs new file mode 100644 index 000000000000..8a24b59153f9 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Metric.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The result data of a query. + public partial class Metric + { + /// Initializes a new instance of Metric. + /// the metric Id. + /// the resource type of the metric resource. + /// the name and the display name of the metric, i.e. it is localizable string. + /// the unit of the metric. + /// the time series returned when a data query is performed. + /// , , , or is null. + internal Metric(string id, string type, LocalizableString name, Unit unit, IEnumerable timeseries) + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (timeseries == null) + { + throw new ArgumentNullException(nameof(timeseries)); + } + + Id = id; + Type = type; + Name = name; + Unit = unit; + Timeseries = timeseries.ToList(); + } + + /// Initializes a new instance of Metric. + /// the metric Id. + /// the resource type of the metric resource. + /// the name and the display name of the metric, i.e. it is localizable string. + /// the unit of the metric. + /// the time series returned when a data query is performed. + internal Metric(string id, string type, LocalizableString name, Unit unit, IReadOnlyList timeseries) + { + Id = id; + Type = type; + Name = name; + Unit = unit; + Timeseries = timeseries; + } + + /// the metric Id. + public string Id { get; } + /// the resource type of the metric resource. + public string Type { get; } + /// the name and the display name of the metric, i.e. it is localizable string. + public LocalizableString Name { get; } + /// the unit of the metric. + public Unit Unit { get; } + /// the time series returned when a data query is performed. + public IReadOnlyList Timeseries { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertAction.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertAction.Serialization.cs new file mode 100644 index 000000000000..b83b440c9a49 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertAction.Serialization.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertAction : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ActionGroupId)) + { + writer.WritePropertyName("actionGroupId"); + writer.WriteStringValue(ActionGroupId); + } + if (Optional.IsCollectionDefined(WebHookProperties)) + { + writer.WritePropertyName("webHookProperties"); + writer.WriteStartObject(); + foreach (var item in WebHookProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WriteEndObject(); + } + + internal static MetricAlertAction DeserializeMetricAlertAction(JsonElement element) + { + Optional actionGroupId = default; + Optional> webHookProperties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("actionGroupId")) + { + actionGroupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("webHookProperties")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + webHookProperties = dictionary; + continue; + } + } + return new MetricAlertAction(actionGroupId.Value, Optional.ToDictionary(webHookProperties)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertAction.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertAction.cs new file mode 100644 index 000000000000..514c766bf401 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertAction.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An alert action. + public partial class MetricAlertAction + { + /// Initializes a new instance of MetricAlertAction. + public MetricAlertAction() + { + WebHookProperties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of MetricAlertAction. + /// the id of the action group to use. + /// The properties of a webhook object. + internal MetricAlertAction(string actionGroupId, IDictionary webHookProperties) + { + ActionGroupId = actionGroupId; + WebHookProperties = webHookProperties; + } + + /// the id of the action group to use. + public string ActionGroupId { get; set; } + /// The properties of a webhook object. + public IDictionary WebHookProperties { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertCriteria.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertCriteria.Serialization.cs new file mode 100644 index 000000000000..3bbbedc6c16a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertCriteria.Serialization.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertCriteria : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType.ToString()); + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value); + } + writer.WriteEndObject(); + } + + internal static MetricAlertCriteria DeserializeMetricAlertCriteria(JsonElement element) + { + if (element.TryGetProperty("odata.type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria": return MetricAlertMultipleResourceMultipleMetricCriteria.DeserializeMetricAlertMultipleResourceMultipleMetricCriteria(element); + case "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria": return MetricAlertSingleResourceMultipleMetricCriteria.DeserializeMetricAlertSingleResourceMultipleMetricCriteria(element); + case "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria": return WebtestLocationAvailabilityCriteria.DeserializeWebtestLocationAvailabilityCriteria(element); + } + } + Odatatype odataType = default; + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("odata.type")) + { + odataType = new Odatatype(property.Value.GetString()); + continue; + } + additionalPropertiesDictionary ??= new Dictionary(); + additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); + } + additionalProperties = additionalPropertiesDictionary; + return new MetricAlertCriteria(odataType, additionalProperties); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertCriteria.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertCriteria.cs new file mode 100644 index 000000000000..6d5c32d07152 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertCriteria.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The rule criteria that defines the conditions of the alert rule. + public partial class MetricAlertCriteria : IDictionary + { + /// Initializes a new instance of MetricAlertCriteria. + public MetricAlertCriteria() + { + AdditionalProperties = new ChangeTrackingDictionary(); + OdataType = new Odatatype("MetricAlertCriteria"); + } + + /// Initializes a new instance of MetricAlertCriteria. + /// specifies the type of the alert criteria. + /// . + internal MetricAlertCriteria(Odatatype odataType, IDictionary additionalProperties) + { + OdataType = odataType; + AdditionalProperties = additionalProperties; + } + + /// specifies the type of the alert criteria. + internal Odatatype OdataType { get; set; } + internal IDictionary AdditionalProperties { get; } + /// + public IEnumerator> GetEnumerator() => AdditionalProperties.GetEnumerator(); + /// + IEnumerator IEnumerable.GetEnumerator() => AdditionalProperties.GetEnumerator(); + /// + public bool TryGetValue(string key, out object value) => AdditionalProperties.TryGetValue(key, out value); + /// + public bool ContainsKey(string key) => AdditionalProperties.ContainsKey(key); + /// + public ICollection Keys => AdditionalProperties.Keys; + /// + public ICollection Values => AdditionalProperties.Values; + /// + int ICollection>.Count => AdditionalProperties.Count; + /// + public void Add(string key, object value) => AdditionalProperties.Add(key, value); + /// + public bool Remove(string key) => AdditionalProperties.Remove(key); + /// + bool ICollection>.IsReadOnly => AdditionalProperties.IsReadOnly; + /// + void ICollection>.Add(KeyValuePair value) => AdditionalProperties.Add(value); + /// + bool ICollection>.Remove(KeyValuePair value) => AdditionalProperties.Remove(value); + /// + bool ICollection>.Contains(KeyValuePair value) => AdditionalProperties.Contains(value); + /// + void ICollection>.CopyTo(KeyValuePair[] destination, int offset) => AdditionalProperties.CopyTo(destination, offset); + /// + void ICollection>.Clear() => AdditionalProperties.Clear(); + /// + public object this[string key] + { + get => AdditionalProperties[key]; + set => AdditionalProperties[key] = value; + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.Serialization.cs new file mode 100644 index 000000000000..e320c16cc156 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.Serialization.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertMultipleResourceMultipleMetricCriteria : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(AllOf)) + { + writer.WritePropertyName("allOf"); + writer.WriteStartArray(); + foreach (var item in AllOf) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType.ToString()); + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value); + } + writer.WriteEndObject(); + } + + internal static MetricAlertMultipleResourceMultipleMetricCriteria DeserializeMetricAlertMultipleResourceMultipleMetricCriteria(JsonElement element) + { + Optional> allOf = default; + Odatatype odataType = default; + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("allOf")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MultiMetricCriteria.DeserializeMultiMetricCriteria(item)); + } + allOf = array; + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = new Odatatype(property.Value.GetString()); + continue; + } + additionalPropertiesDictionary ??= new Dictionary(); + additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); + } + additionalProperties = additionalPropertiesDictionary; + return new MetricAlertMultipleResourceMultipleMetricCriteria(odataType, additionalProperties, Optional.ToList(allOf)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.cs new file mode 100644 index 000000000000..0431c86482b9 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the metric alert criteria for multiple resource that has multiple metric criteria. + public partial class MetricAlertMultipleResourceMultipleMetricCriteria : MetricAlertCriteria + { + /// Initializes a new instance of MetricAlertMultipleResourceMultipleMetricCriteria. + public MetricAlertMultipleResourceMultipleMetricCriteria() + { + AllOf = new ChangeTrackingList(); + OdataType = Odatatype.MicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria; + } + + /// Initializes a new instance of MetricAlertMultipleResourceMultipleMetricCriteria. + /// specifies the type of the alert criteria. + /// . + /// the list of multiple metric criteria for this 'all of' operation. + internal MetricAlertMultipleResourceMultipleMetricCriteria(Odatatype odataType, IDictionary additionalProperties, IList allOf) : base(odataType, additionalProperties) + { + AllOf = allOf; + OdataType = odataType; + } + + /// the list of multiple metric criteria for this 'all of' operation. + public IList AllOf { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResource.Serialization.cs new file mode 100644 index 000000000000..e88bd815de91 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResource.Serialization.cs @@ -0,0 +1,218 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("location"); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + writer.WritePropertyName("description"); + writer.WriteStringValue(Description); + writer.WritePropertyName("severity"); + writer.WriteNumberValue(Severity); + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled); + if (Optional.IsCollectionDefined(Scopes)) + { + writer.WritePropertyName("scopes"); + writer.WriteStartArray(); + foreach (var item in Scopes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("evaluationFrequency"); + writer.WriteStringValue(EvaluationFrequency, "P"); + writer.WritePropertyName("windowSize"); + writer.WriteStringValue(WindowSize, "P"); + if (Optional.IsDefined(TargetResourceType)) + { + writer.WritePropertyName("targetResourceType"); + writer.WriteStringValue(TargetResourceType); + } + if (Optional.IsDefined(TargetResourceRegion)) + { + writer.WritePropertyName("targetResourceRegion"); + writer.WriteStringValue(TargetResourceRegion); + } + writer.WritePropertyName("criteria"); + writer.WriteObjectValue(Criteria); + if (Optional.IsDefined(AutoMitigate)) + { + writer.WritePropertyName("autoMitigate"); + writer.WriteBooleanValue(AutoMitigate.Value); + } + if (Optional.IsCollectionDefined(Actions)) + { + writer.WritePropertyName("actions"); + writer.WriteStartArray(); + foreach (var item in Actions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static MetricAlertResource DeserializeMetricAlertResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + string location = default; + Optional> tags = default; + string description = default; + int severity = default; + bool enabled = default; + Optional> scopes = default; + TimeSpan evaluationFrequency = default; + TimeSpan windowSize = default; + Optional targetResourceType = default; + Optional targetResourceRegion = default; + MetricAlertCriteria criteria = default; + Optional autoMitigate = default; + Optional> actions = default; + Optional lastUpdatedTime = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location")) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("description")) + { + description = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("severity")) + { + severity = property0.Value.GetInt32(); + continue; + } + if (property0.NameEquals("enabled")) + { + enabled = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("scopes")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + scopes = array; + continue; + } + if (property0.NameEquals("evaluationFrequency")) + { + evaluationFrequency = property0.Value.GetTimeSpan("P"); + continue; + } + if (property0.NameEquals("windowSize")) + { + windowSize = property0.Value.GetTimeSpan("P"); + continue; + } + if (property0.NameEquals("targetResourceType")) + { + targetResourceType = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("targetResourceRegion")) + { + targetResourceRegion = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("criteria")) + { + criteria = MetricAlertCriteria.DeserializeMetricAlertCriteria(property0.Value); + continue; + } + if (property0.NameEquals("autoMitigate")) + { + autoMitigate = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("actions")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(MetricAlertAction.DeserializeMetricAlertAction(item)); + } + actions = array; + continue; + } + if (property0.NameEquals("lastUpdatedTime")) + { + lastUpdatedTime = property0.Value.GetDateTimeOffset("O"); + continue; + } + } + continue; + } + } + return new MetricAlertResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), description, severity, enabled, Optional.ToList(scopes), evaluationFrequency, windowSize, targetResourceType.Value, targetResourceRegion.Value, criteria, Optional.ToNullable(autoMitigate), Optional.ToList(actions), Optional.ToNullable(lastUpdatedTime)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResource.cs new file mode 100644 index 000000000000..c1b9c36e2797 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResource.cs @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The metric alert resource. + public partial class MetricAlertResource : Resource + { + /// Initializes a new instance of MetricAlertResource. + /// Resource location. + /// the description of the metric alert that will be included in the alert email. + /// Alert severity {0, 1, 2, 3, 4}. + /// the flag that indicates whether the metric alert is enabled. + /// how often the metric alert is evaluated represented in ISO 8601 duration format. + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. + /// defines the specific alert criteria information. + /// , , or is null. + public MetricAlertResource(string location, string description, int severity, bool enabled, TimeSpan evaluationFrequency, TimeSpan windowSize, MetricAlertCriteria criteria) : base(location) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + if (description == null) + { + throw new ArgumentNullException(nameof(description)); + } + if (criteria == null) + { + throw new ArgumentNullException(nameof(criteria)); + } + + Description = description; + Severity = severity; + Enabled = enabled; + Scopes = new ChangeTrackingList(); + EvaluationFrequency = evaluationFrequency; + WindowSize = windowSize; + Criteria = criteria; + Actions = new ChangeTrackingList(); + } + + /// Initializes a new instance of MetricAlertResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// Resource location. + /// Resource tags. + /// the description of the metric alert that will be included in the alert email. + /// Alert severity {0, 1, 2, 3, 4}. + /// the flag that indicates whether the metric alert is enabled. + /// the list of resource id's that this metric alert is scoped to. + /// how often the metric alert is evaluated represented in ISO 8601 duration format. + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. + /// the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + /// the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + /// defines the specific alert criteria information. + /// the flag that indicates whether the alert should be auto resolved or not. The default is true. + /// the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + /// Last time the rule was updated in ISO8601 format. + internal MetricAlertResource(string id, string name, string type, string location, IDictionary tags, string description, int severity, bool enabled, IList scopes, TimeSpan evaluationFrequency, TimeSpan windowSize, string targetResourceType, string targetResourceRegion, MetricAlertCriteria criteria, bool? autoMitigate, IList actions, DateTimeOffset? lastUpdatedTime) : base(id, name, type, location, tags) + { + Description = description; + Severity = severity; + Enabled = enabled; + Scopes = scopes; + EvaluationFrequency = evaluationFrequency; + WindowSize = windowSize; + TargetResourceType = targetResourceType; + TargetResourceRegion = targetResourceRegion; + Criteria = criteria; + AutoMitigate = autoMitigate; + Actions = actions; + LastUpdatedTime = lastUpdatedTime; + } + + /// the description of the metric alert that will be included in the alert email. + public string Description { get; set; } + /// Alert severity {0, 1, 2, 3, 4}. + public int Severity { get; set; } + /// the flag that indicates whether the metric alert is enabled. + public bool Enabled { get; set; } + /// the list of resource id's that this metric alert is scoped to. + public IList Scopes { get; } + /// how often the metric alert is evaluated represented in ISO 8601 duration format. + public TimeSpan EvaluationFrequency { get; set; } + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. + public TimeSpan WindowSize { get; set; } + /// the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + public string TargetResourceType { get; set; } + /// the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + public string TargetResourceRegion { get; set; } + /// defines the specific alert criteria information. + public MetricAlertCriteria Criteria { get; set; } + /// the flag that indicates whether the alert should be auto resolved or not. The default is true. + public bool? AutoMitigate { get; set; } + /// the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + public IList Actions { get; } + /// Last time the rule was updated in ISO8601 format. + public DateTimeOffset? LastUpdatedTime { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourceCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourceCollection.Serialization.cs new file mode 100644 index 000000000000..1832ea9477f2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourceCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertResourceCollection + { + internal static MetricAlertResourceCollection DeserializeMetricAlertResourceCollection(JsonElement element) + { + Optional> value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricAlertResource.DeserializeMetricAlertResource(item)); + } + value = array; + continue; + } + } + return new MetricAlertResourceCollection(Optional.ToList(value)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourceCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourceCollection.cs new file mode 100644 index 000000000000..9a529e9d7ec4 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourceCollection.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a collection of alert rule resources. + public partial class MetricAlertResourceCollection + { + /// Initializes a new instance of MetricAlertResourceCollection. + internal MetricAlertResourceCollection() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of MetricAlertResourceCollection. + /// the values for the alert rule resources. + internal MetricAlertResourceCollection(IReadOnlyList value) + { + Value = value; + } + + /// the values for the alert rule resources. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourcePatch.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourcePatch.Serialization.cs new file mode 100644 index 000000000000..47552d9fab1e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourcePatch.Serialization.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertResourcePatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Severity)) + { + writer.WritePropertyName("severity"); + writer.WriteNumberValue(Severity.Value); + } + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsCollectionDefined(Scopes)) + { + writer.WritePropertyName("scopes"); + writer.WriteStartArray(); + foreach (var item in Scopes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(EvaluationFrequency)) + { + writer.WritePropertyName("evaluationFrequency"); + writer.WriteStringValue(EvaluationFrequency.Value, "P"); + } + if (Optional.IsDefined(WindowSize)) + { + writer.WritePropertyName("windowSize"); + writer.WriteStringValue(WindowSize.Value, "P"); + } + if (Optional.IsDefined(TargetResourceType)) + { + writer.WritePropertyName("targetResourceType"); + writer.WriteStringValue(TargetResourceType); + } + if (Optional.IsDefined(TargetResourceRegion)) + { + writer.WritePropertyName("targetResourceRegion"); + writer.WriteStringValue(TargetResourceRegion); + } + if (Optional.IsDefined(Criteria)) + { + writer.WritePropertyName("criteria"); + writer.WriteObjectValue(Criteria); + } + if (Optional.IsDefined(AutoMitigate)) + { + writer.WritePropertyName("autoMitigate"); + writer.WriteBooleanValue(AutoMitigate.Value); + } + if (Optional.IsCollectionDefined(Actions)) + { + writer.WritePropertyName("actions"); + writer.WriteStartArray(); + foreach (var item in Actions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourcePatch.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourcePatch.cs new file mode 100644 index 000000000000..d7c0b504dee3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertResourcePatch.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The metric alert resource for patch operations. + public partial class MetricAlertResourcePatch + { + /// Initializes a new instance of MetricAlertResourcePatch. + public MetricAlertResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + Scopes = new ChangeTrackingList(); + Actions = new ChangeTrackingList(); + } + + /// Resource tags. + public IDictionary Tags { get; } + /// the description of the metric alert that will be included in the alert email. + public string Description { get; set; } + /// Alert severity {0, 1, 2, 3, 4}. + public int? Severity { get; set; } + /// the flag that indicates whether the metric alert is enabled. + public bool? Enabled { get; set; } + /// the list of resource id's that this metric alert is scoped to. + public IList Scopes { get; } + /// how often the metric alert is evaluated represented in ISO 8601 duration format. + public TimeSpan? EvaluationFrequency { get; set; } + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. + public TimeSpan? WindowSize { get; set; } + /// the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + public string TargetResourceType { get; set; } + /// the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + public string TargetResourceRegion { get; set; } + /// defines the specific alert criteria information. + public MetricAlertCriteria Criteria { get; set; } + /// the flag that indicates whether the alert should be auto resolved or not. The default is true. + public bool? AutoMitigate { get; set; } + /// the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + public IList Actions { get; } + /// Last time the rule was updated in ISO8601 format. + public DateTimeOffset? LastUpdatedTime { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.Serialization.cs new file mode 100644 index 000000000000..07239c7047f9 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.Serialization.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertSingleResourceMultipleMetricCriteria : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(AllOf)) + { + writer.WritePropertyName("allOf"); + writer.WriteStartArray(); + foreach (var item in AllOf) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType.ToString()); + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value); + } + writer.WriteEndObject(); + } + + internal static MetricAlertSingleResourceMultipleMetricCriteria DeserializeMetricAlertSingleResourceMultipleMetricCriteria(JsonElement element) + { + Optional> allOf = default; + Odatatype odataType = default; + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("allOf")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricCriteria.DeserializeMetricCriteria(item)); + } + allOf = array; + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = new Odatatype(property.Value.GetString()); + continue; + } + additionalPropertiesDictionary ??= new Dictionary(); + additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); + } + additionalProperties = additionalPropertiesDictionary; + return new MetricAlertSingleResourceMultipleMetricCriteria(odataType, additionalProperties, Optional.ToList(allOf)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs new file mode 100644 index 000000000000..8c45f8d29bcc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the metric alert criteria for a single resource that has multiple metric criteria. + public partial class MetricAlertSingleResourceMultipleMetricCriteria : MetricAlertCriteria + { + /// Initializes a new instance of MetricAlertSingleResourceMultipleMetricCriteria. + public MetricAlertSingleResourceMultipleMetricCriteria() + { + AllOf = new ChangeTrackingList(); + OdataType = Odatatype.MicrosoftAzureMonitorSingleResourceMultipleMetricCriteria; + } + + /// Initializes a new instance of MetricAlertSingleResourceMultipleMetricCriteria. + /// specifies the type of the alert criteria. + /// . + /// The list of metric criteria for this 'all of' operation. + internal MetricAlertSingleResourceMultipleMetricCriteria(Odatatype odataType, IDictionary additionalProperties, IList allOf) : base(odataType, additionalProperties) + { + AllOf = allOf; + OdataType = odataType; + } + + /// The list of metric criteria for this 'all of' operation. + public IList AllOf { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatus.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatus.Serialization.cs new file mode 100644 index 000000000000..65920013c792 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatus.Serialization.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertStatus + { + internal static MetricAlertStatus DeserializeMetricAlertStatus(JsonElement element) + { + Optional name = default; + Optional id = default; + Optional type = default; + Optional properties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + properties = MetricAlertStatusProperties.DeserializeMetricAlertStatusProperties(property.Value); + continue; + } + } + return new MetricAlertStatus(name.Value, id.Value, type.Value, properties.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatus.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatus.cs new file mode 100644 index 000000000000..be86394bcda2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatus.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// An alert status. + public partial class MetricAlertStatus + { + /// Initializes a new instance of MetricAlertStatus. + internal MetricAlertStatus() + { + } + + /// Initializes a new instance of MetricAlertStatus. + /// The status name. + /// The alert rule arm id. + /// The extended resource type name. + /// The alert status properties of the metric alert status. + internal MetricAlertStatus(string name, string id, string type, MetricAlertStatusProperties properties) + { + Name = name; + Id = id; + Type = type; + Properties = properties; + } + + /// The status name. + public string Name { get; } + /// The alert rule arm id. + public string Id { get; } + /// The extended resource type name. + public string Type { get; } + /// The alert status properties of the metric alert status. + public MetricAlertStatusProperties Properties { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusCollection.Serialization.cs new file mode 100644 index 000000000000..9583549fb829 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertStatusCollection + { + internal static MetricAlertStatusCollection DeserializeMetricAlertStatusCollection(JsonElement element) + { + Optional> value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricAlertStatus.DeserializeMetricAlertStatus(item)); + } + value = array; + continue; + } + } + return new MetricAlertStatusCollection(Optional.ToList(value)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusCollection.cs new file mode 100644 index 000000000000..491db257fdee --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusCollection.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a collection of alert rule resources. + public partial class MetricAlertStatusCollection + { + /// Initializes a new instance of MetricAlertStatusCollection. + internal MetricAlertStatusCollection() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of MetricAlertStatusCollection. + /// the values for the alert rule resources. + internal MetricAlertStatusCollection(IReadOnlyList value) + { + Value = value; + } + + /// the values for the alert rule resources. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusProperties.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusProperties.Serialization.cs new file mode 100644 index 000000000000..2632dce9f3df --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusProperties.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAlertStatusProperties + { + internal static MetricAlertStatusProperties DeserializeMetricAlertStatusProperties(JsonElement element) + { + Optional> dimensions = default; + Optional status = default; + Optional timestamp = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("dimensions")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + dimensions = dictionary; + continue; + } + if (property.NameEquals("status")) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("timestamp")) + { + timestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + } + return new MetricAlertStatusProperties(Optional.ToDictionary(dimensions), status.Value, Optional.ToNullable(timestamp)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusProperties.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusProperties.cs new file mode 100644 index 000000000000..69508a23c20c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAlertStatusProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An alert status properties. + public partial class MetricAlertStatusProperties + { + /// Initializes a new instance of MetricAlertStatusProperties. + internal MetricAlertStatusProperties() + { + Dimensions = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of MetricAlertStatusProperties. + /// An object describing the type of the dimensions. + /// status value. + /// UTC time when the status was checked. + internal MetricAlertStatusProperties(IReadOnlyDictionary dimensions, string status, DateTimeOffset? timestamp) + { + Dimensions = dimensions; + Status = status; + Timestamp = timestamp; + } + + /// An object describing the type of the dimensions. + public IReadOnlyDictionary Dimensions { get; } + /// status value. + public string Status { get; } + /// UTC time when the status was checked. + public DateTimeOffset? Timestamp { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAvailability.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAvailability.Serialization.cs new file mode 100644 index 000000000000..81be2915eceb --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAvailability.Serialization.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricAvailability + { + internal static MetricAvailability DeserializeMetricAvailability(JsonElement element) + { + Optional timeGrain = default; + Optional retention = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeGrain")) + { + timeGrain = property.Value.GetTimeSpan("P"); + continue; + } + if (property.NameEquals("retention")) + { + retention = property.Value.GetTimeSpan("P"); + continue; + } + } + return new MetricAvailability(Optional.ToNullable(timeGrain), Optional.ToNullable(retention)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAvailability.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAvailability.cs new file mode 100644 index 000000000000..7fb7158c3255 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricAvailability.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. + public partial class MetricAvailability + { + /// Initializes a new instance of MetricAvailability. + internal MetricAvailability() + { + } + + /// Initializes a new instance of MetricAvailability. + /// the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. + /// the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. + internal MetricAvailability(TimeSpan? timeGrain, TimeSpan? retention) + { + TimeGrain = timeGrain; + Retention = retention; + } + + /// the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. + public TimeSpan? TimeGrain { get; } + /// the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. + public TimeSpan? Retention { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricBaselinesResponse.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricBaselinesResponse.Serialization.cs new file mode 100644 index 000000000000..78cbe8fce93b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricBaselinesResponse.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricBaselinesResponse + { + internal static MetricBaselinesResponse DeserializeMetricBaselinesResponse(JsonElement element) + { + Optional> value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SingleMetricBaseline.DeserializeSingleMetricBaseline(item)); + } + value = array; + continue; + } + } + return new MetricBaselinesResponse(Optional.ToList(value)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricBaselinesResponse.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricBaselinesResponse.cs new file mode 100644 index 000000000000..51ae45215ed5 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricBaselinesResponse.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A list of metric baselines. + public partial class MetricBaselinesResponse + { + /// Initializes a new instance of MetricBaselinesResponse. + internal MetricBaselinesResponse() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of MetricBaselinesResponse. + /// The list of metric baselines. + internal MetricBaselinesResponse(IReadOnlyList value) + { + Value = value; + } + + /// The list of metric baselines. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricCriteria.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricCriteria.Serialization.cs new file mode 100644 index 000000000000..4d3c89e9f73f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricCriteria.Serialization.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricCriteria : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("operator"); + writer.WriteStringValue(Operator.ToString()); + writer.WritePropertyName("threshold"); + writer.WriteNumberValue(Threshold); + writer.WritePropertyName("criterionType"); + writer.WriteStringValue(CriterionType.ToString()); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("metricName"); + writer.WriteStringValue(MetricName); + if (Optional.IsDefined(MetricNamespace)) + { + writer.WritePropertyName("metricNamespace"); + writer.WriteStringValue(MetricNamespace); + } + writer.WritePropertyName("timeAggregation"); + writer.WriteStringValue(TimeAggregation.ToSerialString()); + if (Optional.IsCollectionDefined(Dimensions)) + { + writer.WritePropertyName("dimensions"); + writer.WriteStartArray(); + foreach (var item in Dimensions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value); + } + writer.WriteEndObject(); + } + + internal static MetricCriteria DeserializeMetricCriteria(JsonElement element) + { + Operator @operator = default; + double threshold = default; + CriterionType criterionType = default; + string name = default; + string metricName = default; + Optional metricNamespace = default; + AggregationType timeAggregation = default; + Optional> dimensions = default; + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operator")) + { + @operator = new Operator(property.Value.GetString()); + continue; + } + if (property.NameEquals("threshold")) + { + threshold = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("criterionType")) + { + criterionType = new CriterionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricName")) + { + metricName = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricNamespace")) + { + metricNamespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("timeAggregation")) + { + timeAggregation = property.Value.GetString().ToAggregationType(); + continue; + } + if (property.NameEquals("dimensions")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricDimension.DeserializeMetricDimension(item)); + } + dimensions = array; + continue; + } + additionalPropertiesDictionary ??= new Dictionary(); + additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); + } + additionalProperties = additionalPropertiesDictionary; + return new MetricCriteria(criterionType, name, metricName, metricNamespace.Value, timeAggregation, Optional.ToList(dimensions), additionalProperties, @operator, threshold); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricCriteria.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricCriteria.cs new file mode 100644 index 000000000000..c9092a6bfb2c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricCriteria.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Criterion to filter metrics. + public partial class MetricCriteria : MultiMetricCriteria + { + /// Initializes a new instance of MetricCriteria. + /// Name of the criteria. + /// Name of the metric. + /// the criteria time aggregation types. + /// the criteria operator. + /// the criteria threshold value that activates the alert. + /// or is null. + public MetricCriteria(string name, string metricName, AggregationType timeAggregation, Operator @operator, double threshold) : base(name, metricName, timeAggregation) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (metricName == null) + { + throw new ArgumentNullException(nameof(metricName)); + } + + Operator = @operator; + Threshold = threshold; + CriterionType = CriterionType.StaticThresholdCriterion; + } + + /// Initializes a new instance of MetricCriteria. + /// Specifies the type of threshold criteria. + /// Name of the criteria. + /// Name of the metric. + /// Namespace of the metric. + /// the criteria time aggregation types. + /// List of dimension conditions. + /// . + /// the criteria operator. + /// the criteria threshold value that activates the alert. + internal MetricCriteria(CriterionType criterionType, string name, string metricName, string metricNamespace, AggregationType timeAggregation, IList dimensions, IDictionary additionalProperties, Operator @operator, double threshold) : base(criterionType, name, metricName, metricNamespace, timeAggregation, dimensions, additionalProperties) + { + Operator = @operator; + Threshold = threshold; + CriterionType = criterionType; + } + + /// the criteria operator. + public Operator Operator { get; set; } + /// the criteria threshold value that activates the alert. + public double Threshold { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinition.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinition.Serialization.cs new file mode 100644 index 000000000000..4f389b99a723 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinition.Serialization.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricDefinition + { + internal static MetricDefinition DeserializeMetricDefinition(JsonElement element) + { + Optional isDimensionRequired = default; + Optional resourceId = default; + Optional @namespace = default; + Optional name = default; + Optional unit = default; + Optional primaryAggregationType = default; + Optional> supportedAggregationTypes = default; + Optional> metricAvailabilities = default; + Optional id = default; + Optional> dimensions = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("isDimensionRequired")) + { + isDimensionRequired = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("resourceId")) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("namespace")) + { + @namespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = LocalizableString.DeserializeLocalizableString(property.Value); + continue; + } + if (property.NameEquals("unit")) + { + unit = property.Value.GetString().ToUnit(); + continue; + } + if (property.NameEquals("primaryAggregationType")) + { + primaryAggregationType = property.Value.GetString().ToAggregationType(); + continue; + } + if (property.NameEquals("supportedAggregationTypes")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString().ToAggregationType()); + } + supportedAggregationTypes = array; + continue; + } + if (property.NameEquals("metricAvailabilities")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricAvailability.DeserializeMetricAvailability(item)); + } + metricAvailabilities = array; + continue; + } + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("dimensions")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LocalizableString.DeserializeLocalizableString(item)); + } + dimensions = array; + continue; + } + } + return new MetricDefinition(Optional.ToNullable(isDimensionRequired), resourceId.Value, @namespace.Value, name.Value, Optional.ToNullable(unit), Optional.ToNullable(primaryAggregationType), Optional.ToList(supportedAggregationTypes), Optional.ToList(metricAvailabilities), id.Value, Optional.ToList(dimensions)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinition.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinition.cs new file mode 100644 index 000000000000..da004953b4e2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinition.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Metric definition class specifies the metadata for a metric. + public partial class MetricDefinition + { + /// Initializes a new instance of MetricDefinition. + internal MetricDefinition() + { + SupportedAggregationTypes = new ChangeTrackingList(); + MetricAvailabilities = new ChangeTrackingList(); + Dimensions = new ChangeTrackingList(); + } + + /// Initializes a new instance of MetricDefinition. + /// Flag to indicate whether the dimension is required. + /// the resource identifier of the resource that emitted the metric. + /// the namespace the metric belongs to. + /// the name and the display name of the metric, i.e. it is a localizable string. + /// the unit of the metric. + /// the primary aggregation type value defining how to use the values for display. + /// the collection of what aggregation types are supported. + /// the collection of what aggregation intervals are available to be queried. + /// the resource identifier of the metric definition. + /// the name and the display name of the dimension, i.e. it is a localizable string. + internal MetricDefinition(bool? isDimensionRequired, string resourceId, string @namespace, LocalizableString name, Unit? unit, AggregationType? primaryAggregationType, IReadOnlyList supportedAggregationTypes, IReadOnlyList metricAvailabilities, string id, IReadOnlyList dimensions) + { + IsDimensionRequired = isDimensionRequired; + ResourceId = resourceId; + Namespace = @namespace; + Name = name; + Unit = unit; + PrimaryAggregationType = primaryAggregationType; + SupportedAggregationTypes = supportedAggregationTypes; + MetricAvailabilities = metricAvailabilities; + Id = id; + Dimensions = dimensions; + } + + /// Flag to indicate whether the dimension is required. + public bool? IsDimensionRequired { get; } + /// the resource identifier of the resource that emitted the metric. + public string ResourceId { get; } + /// the namespace the metric belongs to. + public string Namespace { get; } + /// the name and the display name of the metric, i.e. it is a localizable string. + public LocalizableString Name { get; } + /// the unit of the metric. + public Unit? Unit { get; } + /// the primary aggregation type value defining how to use the values for display. + public AggregationType? PrimaryAggregationType { get; } + /// the collection of what aggregation types are supported. + public IReadOnlyList SupportedAggregationTypes { get; } + /// the collection of what aggregation intervals are available to be queried. + public IReadOnlyList MetricAvailabilities { get; } + /// the resource identifier of the metric definition. + public string Id { get; } + /// the name and the display name of the dimension, i.e. it is a localizable string. + public IReadOnlyList Dimensions { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinitionCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinitionCollection.Serialization.cs new file mode 100644 index 000000000000..df82ce71cd71 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinitionCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricDefinitionCollection + { + internal static MetricDefinitionCollection DeserializeMetricDefinitionCollection(JsonElement element) + { + IReadOnlyList value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricDefinition.DeserializeMetricDefinition(item)); + } + value = array; + continue; + } + } + return new MetricDefinitionCollection(value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinitionCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinitionCollection.cs new file mode 100644 index 000000000000..77ad26cf2603 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDefinitionCollection.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents collection of metric definitions. + public partial class MetricDefinitionCollection + { + /// Initializes a new instance of MetricDefinitionCollection. + /// the values for the metric definitions. + /// is null. + internal MetricDefinitionCollection(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of MetricDefinitionCollection. + /// the values for the metric definitions. + internal MetricDefinitionCollection(IReadOnlyList value) + { + Value = value; + } + + /// the values for the metric definitions. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDimension.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDimension.Serialization.cs new file mode 100644 index 000000000000..a06ef18b677d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDimension.Serialization.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricDimension : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("operator"); + writer.WriteStringValue(Operator); + writer.WritePropertyName("values"); + writer.WriteStartArray(); + foreach (var item in Values) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } + + internal static MetricDimension DeserializeMetricDimension(JsonElement element) + { + string name = default; + string @operator = default; + IList values = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("operator")) + { + @operator = property.Value.GetString(); + continue; + } + if (property.NameEquals("values")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + values = array; + continue; + } + } + return new MetricDimension(name, @operator, values); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDimension.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDimension.cs new file mode 100644 index 000000000000..fa2c9741fd6c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricDimension.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies a metric dimension. + public partial class MetricDimension + { + /// Initializes a new instance of MetricDimension. + /// Name of the dimension. + /// the dimension operator. Only 'Include' and 'Exclude' are supported. + /// list of dimension values. + /// , , or is null. + public MetricDimension(string name, string @operator, IEnumerable values) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (@operator == null) + { + throw new ArgumentNullException(nameof(@operator)); + } + if (values == null) + { + throw new ArgumentNullException(nameof(values)); + } + + Name = name; + Operator = @operator; + Values = values.ToList(); + } + + /// Initializes a new instance of MetricDimension. + /// Name of the dimension. + /// the dimension operator. Only 'Include' and 'Exclude' are supported. + /// list of dimension values. + internal MetricDimension(string name, string @operator, IList values) + { + Name = name; + Operator = @operator; + Values = values; + } + + /// Name of the dimension. + public string Name { get; set; } + /// the dimension operator. Only 'Include' and 'Exclude' are supported. + public string Operator { get; set; } + /// list of dimension values. + public IList Values { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespace.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespace.Serialization.cs new file mode 100644 index 000000000000..ba34a14973be --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespace.Serialization.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricNamespace + { + internal static MetricNamespace DeserializeMetricNamespace(JsonElement element) + { + Optional id = default; + Optional type = default; + Optional name = default; + Optional properties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + properties = MetricNamespaceName.DeserializeMetricNamespaceName(property.Value); + continue; + } + } + return new MetricNamespace(id.Value, type.Value, name.Value, properties.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespace.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespace.cs new file mode 100644 index 000000000000..8b6695b37637 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespace.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Metric namespace class specifies the metadata for a metric namespace. + public partial class MetricNamespace + { + /// Initializes a new instance of MetricNamespace. + internal MetricNamespace() + { + } + + /// Initializes a new instance of MetricNamespace. + /// The ID of the metricNamespace. + /// The type of the namespace. + /// The name of the namespace. + /// Properties which include the fully qualified namespace name. + internal MetricNamespace(string id, string type, string name, MetricNamespaceName properties) + { + Id = id; + Type = type; + Name = name; + Properties = properties; + } + + /// The ID of the metricNamespace. + public string Id { get; } + /// The type of the namespace. + public string Type { get; } + /// The name of the namespace. + public string Name { get; } + /// Properties which include the fully qualified namespace name. + public MetricNamespaceName Properties { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceCollection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceCollection.Serialization.cs new file mode 100644 index 000000000000..f8ce860dad72 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceCollection.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricNamespaceCollection + { + internal static MetricNamespaceCollection DeserializeMetricNamespaceCollection(JsonElement element) + { + IReadOnlyList value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricNamespace.DeserializeMetricNamespace(item)); + } + value = array; + continue; + } + } + return new MetricNamespaceCollection(value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceCollection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceCollection.cs new file mode 100644 index 000000000000..4e6db3822dc6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceCollection.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents collection of metric namespaces. + public partial class MetricNamespaceCollection + { + /// Initializes a new instance of MetricNamespaceCollection. + /// The values for the metric namespaces. + /// is null. + internal MetricNamespaceCollection(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of MetricNamespaceCollection. + /// The values for the metric namespaces. + internal MetricNamespaceCollection(IReadOnlyList value) + { + Value = value; + } + + /// The values for the metric namespaces. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceName.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceName.Serialization.cs new file mode 100644 index 000000000000..43ee70869ad0 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceName.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricNamespaceName + { + internal static MetricNamespaceName DeserializeMetricNamespaceName(JsonElement element) + { + Optional metricNamespaceName = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metricNamespaceName")) + { + metricNamespaceName = property.Value.GetString(); + continue; + } + } + return new MetricNamespaceName(metricNamespaceName.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceName.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceName.cs new file mode 100644 index 000000000000..4acb302ecc30 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricNamespaceName.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The fully qualified metric namespace name. + public partial class MetricNamespaceName + { + /// Initializes a new instance of MetricNamespaceName. + internal MetricNamespaceName() + { + } + + /// Initializes a new instance of MetricNamespaceName. + /// The metric namespace name. + internal MetricNamespaceName(string metricNamespaceNameValue) + { + MetricNamespaceNameValue = metricNamespaceNameValue; + } + + /// The metric namespace name. + public string MetricNamespaceNameValue { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSettings.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSettings.Serialization.cs new file mode 100644 index 000000000000..fdebe183774f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSettings.Serialization.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricSettings : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(TimeGrain)) + { + writer.WritePropertyName("timeGrain"); + writer.WriteStringValue(TimeGrain.Value, "P"); + } + if (Optional.IsDefined(Category)) + { + writer.WritePropertyName("category"); + writer.WriteStringValue(Category); + } + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled); + if (Optional.IsDefined(RetentionPolicy)) + { + writer.WritePropertyName("retentionPolicy"); + writer.WriteObjectValue(RetentionPolicy); + } + writer.WriteEndObject(); + } + + internal static MetricSettings DeserializeMetricSettings(JsonElement element) + { + Optional timeGrain = default; + Optional category = default; + bool enabled = default; + Optional retentionPolicy = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeGrain")) + { + timeGrain = property.Value.GetTimeSpan("P"); + continue; + } + if (property.NameEquals("category")) + { + category = property.Value.GetString(); + continue; + } + if (property.NameEquals("enabled")) + { + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("retentionPolicy")) + { + retentionPolicy = RetentionPolicy.DeserializeRetentionPolicy(property.Value); + continue; + } + } + return new MetricSettings(Optional.ToNullable(timeGrain), category.Value, enabled, retentionPolicy.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSettings.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSettings.cs new file mode 100644 index 000000000000..892a8539eb92 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSettings.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. + public partial class MetricSettings + { + /// Initializes a new instance of MetricSettings. + /// a value indicating whether this category is enabled. + public MetricSettings(bool enabled) + { + Enabled = enabled; + } + + /// Initializes a new instance of MetricSettings. + /// the timegrain of the metric in ISO8601 format. + /// Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. + /// a value indicating whether this category is enabled. + /// the retention policy for this category. + internal MetricSettings(TimeSpan? timeGrain, string category, bool enabled, RetentionPolicy retentionPolicy) + { + TimeGrain = timeGrain; + Category = category; + Enabled = enabled; + RetentionPolicy = retentionPolicy; + } + + /// the timegrain of the metric in ISO8601 format. + public TimeSpan? TimeGrain { get; set; } + /// Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. + public string Category { get; set; } + /// a value indicating whether this category is enabled. + public bool Enabled { get; set; } + /// the retention policy for this category. + public RetentionPolicy RetentionPolicy { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSingleDimension.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSingleDimension.Serialization.cs new file mode 100644 index 000000000000..19903af026e7 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSingleDimension.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricSingleDimension + { + internal static MetricSingleDimension DeserializeMetricSingleDimension(JsonElement element) + { + string name = default; + string value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("value")) + { + value = property.Value.GetString(); + continue; + } + } + return new MetricSingleDimension(name, value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSingleDimension.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSingleDimension.cs new file mode 100644 index 000000000000..cacdeebd82d9 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricSingleDimension.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The metric dimension name and value. + public partial class MetricSingleDimension + { + /// Initializes a new instance of MetricSingleDimension. + /// Name of the dimension. + /// Value of the dimension. + /// or is null. + internal MetricSingleDimension(string name, string value) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Name = name; + Value = value; + } + + /// Name of the dimension. + public string Name { get; } + /// Value of the dimension. + public string Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricStatisticType.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricStatisticType.Serialization.cs new file mode 100644 index 000000000000..7559034d7961 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricStatisticType.Serialization.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class MetricStatisticTypeExtensions + { + public static string ToSerialString(this MetricStatisticType value) => value switch + { + MetricStatisticType.Average => "Average", + MetricStatisticType.Min => "Min", + MetricStatisticType.Max => "Max", + MetricStatisticType.Sum => "Sum", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown MetricStatisticType value.") + }; + + public static MetricStatisticType ToMetricStatisticType(this string value) + { + if (string.Equals(value, "Average", StringComparison.InvariantCultureIgnoreCase)) return MetricStatisticType.Average; + if (string.Equals(value, "Min", StringComparison.InvariantCultureIgnoreCase)) return MetricStatisticType.Min; + if (string.Equals(value, "Max", StringComparison.InvariantCultureIgnoreCase)) return MetricStatisticType.Max; + if (string.Equals(value, "Sum", StringComparison.InvariantCultureIgnoreCase)) return MetricStatisticType.Sum; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown MetricStatisticType value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricStatisticType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricStatisticType.cs new file mode 100644 index 000000000000..dd081f80ead1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricStatisticType.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the metric statistic type. How the metrics from multiple instances are combined. + public enum MetricStatisticType + { + /// Average. + Average, + /// Min. + Min, + /// Max. + Max, + /// Sum. + Sum + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricTrigger.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricTrigger.Serialization.cs new file mode 100644 index 000000000000..388064b91850 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricTrigger.Serialization.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricTrigger : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("metricName"); + writer.WriteStringValue(MetricName); + if (Optional.IsDefined(MetricNamespace)) + { + writer.WritePropertyName("metricNamespace"); + writer.WriteStringValue(MetricNamespace); + } + writer.WritePropertyName("metricResourceUri"); + writer.WriteStringValue(MetricResourceUri); + writer.WritePropertyName("timeGrain"); + writer.WriteStringValue(TimeGrain, "P"); + writer.WritePropertyName("statistic"); + writer.WriteStringValue(Statistic.ToSerialString()); + writer.WritePropertyName("timeWindow"); + writer.WriteStringValue(TimeWindow, "P"); + writer.WritePropertyName("timeAggregation"); + writer.WriteStringValue(TimeAggregation.ToSerialString()); + writer.WritePropertyName("operator"); + writer.WriteStringValue(Operator.ToSerialString()); + writer.WritePropertyName("threshold"); + writer.WriteNumberValue(Threshold); + if (Optional.IsCollectionDefined(Dimensions)) + { + writer.WritePropertyName("dimensions"); + writer.WriteStartArray(); + foreach (var item in Dimensions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + internal static MetricTrigger DeserializeMetricTrigger(JsonElement element) + { + string metricName = default; + Optional metricNamespace = default; + string metricResourceUri = default; + TimeSpan timeGrain = default; + MetricStatisticType statistic = default; + TimeSpan timeWindow = default; + TimeAggregationType timeAggregation = default; + ComparisonOperationType @operator = default; + double threshold = default; + Optional> dimensions = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metricName")) + { + metricName = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricNamespace")) + { + metricNamespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricResourceUri")) + { + metricResourceUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("timeGrain")) + { + timeGrain = property.Value.GetTimeSpan("P"); + continue; + } + if (property.NameEquals("statistic")) + { + statistic = property.Value.GetString().ToMetricStatisticType(); + continue; + } + if (property.NameEquals("timeWindow")) + { + timeWindow = property.Value.GetTimeSpan("P"); + continue; + } + if (property.NameEquals("timeAggregation")) + { + timeAggregation = property.Value.GetString().ToTimeAggregationType(); + continue; + } + if (property.NameEquals("operator")) + { + @operator = property.Value.GetString().ToComparisonOperationType(); + continue; + } + if (property.NameEquals("threshold")) + { + threshold = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("dimensions")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ScaleRuleMetricDimension.DeserializeScaleRuleMetricDimension(item)); + } + dimensions = array; + continue; + } + } + return new MetricTrigger(metricName, metricNamespace.Value, metricResourceUri, timeGrain, statistic, timeWindow, timeAggregation, @operator, threshold, Optional.ToList(dimensions)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricTrigger.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricTrigger.cs new file mode 100644 index 000000000000..2a5ed988b540 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricTrigger.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The trigger that results in a scaling action. + public partial class MetricTrigger + { + /// Initializes a new instance of MetricTrigger. + /// the name of the metric that defines what the rule monitors. + /// the resource identifier of the resource the rule monitors. + /// the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. + /// the metric statistic type. How the metrics from multiple instances are combined. + /// the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. + /// time aggregation type. How the data that is collected should be combined over time. The default value is Average. + /// the operator that is used to compare the metric data and the threshold. + /// the threshold of the metric that triggers the scale action. + /// or is null. + public MetricTrigger(string metricName, string metricResourceUri, TimeSpan timeGrain, MetricStatisticType statistic, TimeSpan timeWindow, TimeAggregationType timeAggregation, ComparisonOperationType @operator, double threshold) + { + if (metricName == null) + { + throw new ArgumentNullException(nameof(metricName)); + } + if (metricResourceUri == null) + { + throw new ArgumentNullException(nameof(metricResourceUri)); + } + + MetricName = metricName; + MetricResourceUri = metricResourceUri; + TimeGrain = timeGrain; + Statistic = statistic; + TimeWindow = timeWindow; + TimeAggregation = timeAggregation; + Operator = @operator; + Threshold = threshold; + Dimensions = new ChangeTrackingList(); + } + + /// Initializes a new instance of MetricTrigger. + /// the name of the metric that defines what the rule monitors. + /// the namespace of the metric that defines what the rule monitors. + /// the resource identifier of the resource the rule monitors. + /// the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. + /// the metric statistic type. How the metrics from multiple instances are combined. + /// the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. + /// time aggregation type. How the data that is collected should be combined over time. The default value is Average. + /// the operator that is used to compare the metric data and the threshold. + /// the threshold of the metric that triggers the scale action. + /// List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + internal MetricTrigger(string metricName, string metricNamespace, string metricResourceUri, TimeSpan timeGrain, MetricStatisticType statistic, TimeSpan timeWindow, TimeAggregationType timeAggregation, ComparisonOperationType @operator, double threshold, IList dimensions) + { + MetricName = metricName; + MetricNamespace = metricNamespace; + MetricResourceUri = metricResourceUri; + TimeGrain = timeGrain; + Statistic = statistic; + TimeWindow = timeWindow; + TimeAggregation = timeAggregation; + Operator = @operator; + Threshold = threshold; + Dimensions = dimensions; + } + + /// the name of the metric that defines what the rule monitors. + public string MetricName { get; set; } + /// the namespace of the metric that defines what the rule monitors. + public string MetricNamespace { get; set; } + /// the resource identifier of the resource the rule monitors. + public string MetricResourceUri { get; set; } + /// the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. + public TimeSpan TimeGrain { get; set; } + /// the metric statistic type. How the metrics from multiple instances are combined. + public MetricStatisticType Statistic { get; set; } + /// the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. + public TimeSpan TimeWindow { get; set; } + /// time aggregation type. How the data that is collected should be combined over time. The default value is Average. + public TimeAggregationType TimeAggregation { get; set; } + /// the operator that is used to compare the metric data and the threshold. + public ComparisonOperationType Operator { get; set; } + /// the threshold of the metric that triggers the scale action. + public double Threshold { get; set; } + /// List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + public IList Dimensions { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricTriggerType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricTriggerType.cs new file mode 100644 index 000000000000..8736f1222ca6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricTriggerType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Metric Trigger Evaluation Type. + public readonly partial struct MetricTriggerType : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public MetricTriggerType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ConsecutiveValue = "Consecutive"; + private const string TotalValue = "Total"; + + /// Consecutive. + public static MetricTriggerType Consecutive { get; } = new MetricTriggerType(ConsecutiveValue); + /// Total. + public static MetricTriggerType Total { get; } = new MetricTriggerType(TotalValue); + /// Determines if two values are the same. + public static bool operator ==(MetricTriggerType left, MetricTriggerType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MetricTriggerType left, MetricTriggerType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MetricTriggerType(string value) => new MetricTriggerType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MetricTriggerType other && Equals(other); + /// + public bool Equals(MetricTriggerType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricValue.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricValue.Serialization.cs new file mode 100644 index 000000000000..587b685403b1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricValue.Serialization.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MetricValue + { + internal static MetricValue DeserializeMetricValue(JsonElement element) + { + DateTimeOffset timeStamp = default; + Optional average = default; + Optional minimum = default; + Optional maximum = default; + Optional total = default; + Optional count = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeStamp")) + { + timeStamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("average")) + { + average = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("minimum")) + { + minimum = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("maximum")) + { + maximum = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("total")) + { + total = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("count")) + { + count = property.Value.GetDouble(); + continue; + } + } + return new MetricValue(timeStamp, Optional.ToNullable(average), Optional.ToNullable(minimum), Optional.ToNullable(maximum), Optional.ToNullable(total), Optional.ToNullable(count)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricValue.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricValue.cs new file mode 100644 index 000000000000..ccb1cbe2bec3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MetricValue.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Represents a metric value. + public partial class MetricValue + { + /// Initializes a new instance of MetricValue. + /// the timestamp for the metric value in ISO 8601 format. + internal MetricValue(DateTimeOffset timeStamp) + { + TimeStamp = timeStamp; + } + + /// Initializes a new instance of MetricValue. + /// the timestamp for the metric value in ISO 8601 format. + /// the average value in the time range. + /// the least value in the time range. + /// the greatest value in the time range. + /// the sum of all of the values in the time range. + /// the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. + internal MetricValue(DateTimeOffset timeStamp, double? average, double? minimum, double? maximum, double? total, double? count) + { + TimeStamp = timeStamp; + Average = average; + Minimum = minimum; + Maximum = maximum; + Total = total; + Count = count; + } + + /// the timestamp for the metric value in ISO 8601 format. + public DateTimeOffset TimeStamp { get; } + /// the average value in the time range. + public double? Average { get; } + /// the least value in the time range. + public double? Minimum { get; } + /// the greatest value in the time range. + public double? Maximum { get; } + /// the sum of all of the values in the time range. + public double? Total { get; } + /// the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. + public double? Count { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MultiMetricCriteria.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MultiMetricCriteria.Serialization.cs new file mode 100644 index 000000000000..7c5c8d73d1b1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MultiMetricCriteria.Serialization.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class MultiMetricCriteria : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("criterionType"); + writer.WriteStringValue(CriterionType.ToString()); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("metricName"); + writer.WriteStringValue(MetricName); + if (Optional.IsDefined(MetricNamespace)) + { + writer.WritePropertyName("metricNamespace"); + writer.WriteStringValue(MetricNamespace); + } + writer.WritePropertyName("timeAggregation"); + writer.WriteStringValue(TimeAggregation.ToSerialString()); + if (Optional.IsCollectionDefined(Dimensions)) + { + writer.WritePropertyName("dimensions"); + writer.WriteStartArray(); + foreach (var item in Dimensions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value); + } + writer.WriteEndObject(); + } + + internal static MultiMetricCriteria DeserializeMultiMetricCriteria(JsonElement element) + { + if (element.TryGetProperty("criterionType", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "DynamicThresholdCriterion": return DynamicMetricCriteria.DeserializeDynamicMetricCriteria(element); + case "StaticThresholdCriterion": return MetricCriteria.DeserializeMetricCriteria(element); + } + } + CriterionType criterionType = default; + string name = default; + string metricName = default; + Optional metricNamespace = default; + AggregationType timeAggregation = default; + Optional> dimensions = default; + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("criterionType")) + { + criterionType = new CriterionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricName")) + { + metricName = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricNamespace")) + { + metricNamespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("timeAggregation")) + { + timeAggregation = property.Value.GetString().ToAggregationType(); + continue; + } + if (property.NameEquals("dimensions")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricDimension.DeserializeMetricDimension(item)); + } + dimensions = array; + continue; + } + additionalPropertiesDictionary ??= new Dictionary(); + additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); + } + additionalProperties = additionalPropertiesDictionary; + return new MultiMetricCriteria(criterionType, name, metricName, metricNamespace.Value, timeAggregation, Optional.ToList(dimensions), additionalProperties); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MultiMetricCriteria.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MultiMetricCriteria.cs new file mode 100644 index 000000000000..bfeb608a633f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/MultiMetricCriteria.cs @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The types of conditions for a multi resource alert. + public partial class MultiMetricCriteria : IDictionary + { + /// Initializes a new instance of MultiMetricCriteria. + /// Name of the criteria. + /// Name of the metric. + /// the criteria time aggregation types. + /// or is null. + public MultiMetricCriteria(string name, string metricName, AggregationType timeAggregation) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (metricName == null) + { + throw new ArgumentNullException(nameof(metricName)); + } + + Name = name; + MetricName = metricName; + TimeAggregation = timeAggregation; + Dimensions = new ChangeTrackingList(); + AdditionalProperties = new ChangeTrackingDictionary(); + CriterionType = new CriterionType("MultiMetricCriteria"); + } + + /// Initializes a new instance of MultiMetricCriteria. + /// Specifies the type of threshold criteria. + /// Name of the criteria. + /// Name of the metric. + /// Namespace of the metric. + /// the criteria time aggregation types. + /// List of dimension conditions. + /// . + internal MultiMetricCriteria(CriterionType criterionType, string name, string metricName, string metricNamespace, AggregationType timeAggregation, IList dimensions, IDictionary additionalProperties) + { + CriterionType = criterionType; + Name = name; + MetricName = metricName; + MetricNamespace = metricNamespace; + TimeAggregation = timeAggregation; + Dimensions = dimensions; + AdditionalProperties = additionalProperties; + } + + /// Specifies the type of threshold criteria. + internal CriterionType CriterionType { get; set; } + /// Name of the criteria. + public string Name { get; set; } + /// Name of the metric. + public string MetricName { get; set; } + /// Namespace of the metric. + public string MetricNamespace { get; set; } + /// the criteria time aggregation types. + public AggregationType TimeAggregation { get; set; } + /// List of dimension conditions. + public IList Dimensions { get; } + internal IDictionary AdditionalProperties { get; } + /// + public IEnumerator> GetEnumerator() => AdditionalProperties.GetEnumerator(); + /// + IEnumerator IEnumerable.GetEnumerator() => AdditionalProperties.GetEnumerator(); + /// + public bool TryGetValue(string key, out object value) => AdditionalProperties.TryGetValue(key, out value); + /// + public bool ContainsKey(string key) => AdditionalProperties.ContainsKey(key); + /// + public ICollection Keys => AdditionalProperties.Keys; + /// + public ICollection Values => AdditionalProperties.Values; + /// + int ICollection>.Count => AdditionalProperties.Count; + /// + public void Add(string key, object value) => AdditionalProperties.Add(key, value); + /// + public bool Remove(string key) => AdditionalProperties.Remove(key); + /// + bool ICollection>.IsReadOnly => AdditionalProperties.IsReadOnly; + /// + void ICollection>.Add(KeyValuePair value) => AdditionalProperties.Add(value); + /// + bool ICollection>.Remove(KeyValuePair value) => AdditionalProperties.Remove(value); + /// + bool ICollection>.Contains(KeyValuePair value) => AdditionalProperties.Contains(value); + /// + void ICollection>.CopyTo(KeyValuePair[] destination, int offset) => AdditionalProperties.CopyTo(destination, offset); + /// + void ICollection>.Clear() => AdditionalProperties.Clear(); + /// + public object this[string key] + { + get => AdditionalProperties[key]; + set => AdditionalProperties[key] = value; + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Odatatype.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Odatatype.cs new file mode 100644 index 000000000000..59a2866843ee --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Odatatype.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// specifies the type of the alert criteria. + public readonly partial struct Odatatype : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public Odatatype(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MicrosoftAzureMonitorSingleResourceMultipleMetricCriteriaValue = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"; + private const string MicrosoftAzureMonitorMultipleResourceMultipleMetricCriteriaValue = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"; + private const string MicrosoftAzureMonitorWebtestLocationAvailabilityCriteriaValue = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria"; + + /// Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria. + public static Odatatype MicrosoftAzureMonitorSingleResourceMultipleMetricCriteria { get; } = new Odatatype(MicrosoftAzureMonitorSingleResourceMultipleMetricCriteriaValue); + /// Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria. + public static Odatatype MicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria { get; } = new Odatatype(MicrosoftAzureMonitorMultipleResourceMultipleMetricCriteriaValue); + /// Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria. + public static Odatatype MicrosoftAzureMonitorWebtestLocationAvailabilityCriteria { get; } = new Odatatype(MicrosoftAzureMonitorWebtestLocationAvailabilityCriteriaValue); + /// Determines if two values are the same. + public static bool operator ==(Odatatype left, Odatatype right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Odatatype left, Odatatype right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator Odatatype(string value) => new Odatatype(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Odatatype other && Equals(other); + /// + public bool Equals(Odatatype other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OnboardingStatus.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OnboardingStatus.cs new file mode 100644 index 000000000000..fcf166a52e32 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OnboardingStatus.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. + public readonly partial struct OnboardingStatus : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public OnboardingStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string OnboardedValue = "onboarded"; + private const string NotOnboardedValue = "notOnboarded"; + private const string UnknownValue = "unknown"; + + /// onboarded. + public static OnboardingStatus Onboarded { get; } = new OnboardingStatus(OnboardedValue); + /// notOnboarded. + public static OnboardingStatus NotOnboarded { get; } = new OnboardingStatus(NotOnboardedValue); + /// unknown. + public static OnboardingStatus Unknown { get; } = new OnboardingStatus(UnknownValue); + /// Determines if two values are the same. + public static bool operator ==(OnboardingStatus left, OnboardingStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OnboardingStatus left, OnboardingStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OnboardingStatus(string value) => new OnboardingStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OnboardingStatus other && Equals(other); + /// + public bool Equals(OnboardingStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Operation.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Operation.Serialization.cs new file mode 100644 index 000000000000..bc671bb3b4c7 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Operation.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Operation + { + internal static Operation DeserializeOperation(JsonElement element) + { + Optional name = default; + Optional display = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("display")) + { + display = OperationDisplay.DeserializeOperationDisplay(property.Value); + continue; + } + } + return new Operation(name.Value, display.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Operation.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..d37247e3580d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Operation.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Microsoft Insights API operation definition. + public partial class Operation + { + /// Initializes a new instance of Operation. + internal Operation() + { + } + + /// Initializes a new instance of Operation. + /// Operation name: {provider}/{resource}/{operation}. + /// Display metadata associated with the operation. + internal Operation(string name, OperationDisplay display) + { + Name = name; + Display = display; + } + + /// Operation name: {provider}/{resource}/{operation}. + public string Name { get; } + /// Display metadata associated with the operation. + public OperationDisplay Display { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationDisplay.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationDisplay.Serialization.cs new file mode 100644 index 000000000000..c6422378a051 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationDisplay.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class OperationDisplay + { + internal static OperationDisplay DeserializeOperationDisplay(JsonElement element) + { + Optional provider = default; + Optional resource = default; + Optional operation = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provider")) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("resource")) + { + resource = property.Value.GetString(); + continue; + } + if (property.NameEquals("operation")) + { + operation = property.Value.GetString(); + continue; + } + } + return new OperationDisplay(provider.Value, resource.Value, operation.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationDisplay.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..c4c3b3ab1342 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationDisplay.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Display metadata associated with the operation. + public partial class OperationDisplay + { + /// Initializes a new instance of OperationDisplay. + internal OperationDisplay() + { + } + + /// Initializes a new instance of OperationDisplay. + /// Service provider: Microsoft.Insights. + /// Resource on which the operation is performed: AlertRules, Autoscale, etc. + /// Operation type: Read, write, delete, etc. + internal OperationDisplay(string provider, string resource, string operation) + { + Provider = provider; + Resource = resource; + Operation = operation; + } + + /// Service provider: Microsoft.Insights. + public string Provider { get; } + /// Resource on which the operation is performed: AlertRules, Autoscale, etc. + public string Resource { get; } + /// Operation type: Read, write, delete, etc. + public string Operation { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationListResult.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationListResult.Serialization.cs new file mode 100644 index 000000000000..38c3e12b17c5 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationListResult.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class OperationListResult + { + internal static OperationListResult DeserializeOperationListResult(JsonElement element) + { + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Operation.DeserializeOperation(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new OperationListResult(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationListResult.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationListResult.cs new file mode 100644 index 000000000000..1babbb1deffc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/OperationListResult.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Result of the request to list Microsoft.Insights operations. It contains a list of operations and a URL link to get the next set of results. + public partial class OperationListResult + { + /// Initializes a new instance of OperationListResult. + internal OperationListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of OperationListResult. + /// List of operations supported by the Microsoft.Insights provider. + /// URL to get the next set of operation list results if there are any. + internal OperationListResult(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// List of operations supported by the Microsoft.Insights provider. + public IReadOnlyList Value { get; } + /// URL to get the next set of operation list results if there are any. + public string NextLink { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Operator.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Operator.cs new file mode 100644 index 000000000000..801dbcc0fcf6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Operator.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// the criteria operator. + public readonly partial struct Operator : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public Operator(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EqualsValueValue = "Equals"; + private const string NotEqualsValue = "NotEquals"; + private const string GreaterThanValue = "GreaterThan"; + private const string GreaterThanOrEqualValue = "GreaterThanOrEqual"; + private const string LessThanValue = "LessThan"; + private const string LessThanOrEqualValue = "LessThanOrEqual"; + private const string IncludeValue = "Include"; + + /// Equals. + public static Operator EqualsValue { get; } = new Operator(EqualsValueValue); + /// NotEquals. + public static Operator NotEquals { get; } = new Operator(NotEqualsValue); + /// GreaterThan. + public static Operator GreaterThan { get; } = new Operator(GreaterThanValue); + /// GreaterThanOrEqual. + public static Operator GreaterThanOrEqual { get; } = new Operator(GreaterThanOrEqualValue); + /// LessThan. + public static Operator LessThan { get; } = new Operator(LessThanValue); + /// LessThanOrEqual. + public static Operator LessThanOrEqual { get; } = new Operator(LessThanOrEqualValue); + /// Include. + public static Operator Include { get; } = new Operator(IncludeValue); + /// Determines if two values are the same. + public static bool operator ==(Operator left, Operator right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Operator left, Operator right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator Operator(string value) => new Operator(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Operator other && Equals(other); + /// + public bool Equals(Operator other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProvisioningState.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..524dac44532e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Provisioning state of the scheduled query rule. + public readonly partial struct ProvisioningState : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public ProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string DeployingValue = "Deploying"; + private const string CanceledValue = "Canceled"; + private const string FailedValue = "Failed"; + + /// Succeeded. + public static ProvisioningState Succeeded { get; } = new ProvisioningState(SucceededValue); + /// Deploying. + public static ProvisioningState Deploying { get; } = new ProvisioningState(DeployingValue); + /// Canceled. + public static ProvisioningState Canceled { get; } = new ProvisioningState(CanceledValue); + /// Failed. + public static ProvisioningState Failed { get; } = new ProvisioningState(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(ProvisioningState left, ProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ProvisioningState left, ProvisioningState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ProvisioningState(string value) => new ProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProvisioningState other && Equals(other); + /// + public bool Equals(ProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyOnlyResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyOnlyResource.Serialization.cs new file mode 100644 index 000000000000..6a3fef762b0f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyOnlyResource.Serialization.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ProxyOnlyResource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } + + internal static ProxyOnlyResource DeserializeProxyOnlyResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + } + return new ProxyOnlyResource(id.Value, name.Value, type.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyOnlyResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyOnlyResource.cs new file mode 100644 index 000000000000..295f1309ad27 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyOnlyResource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// A proxy only azure resource object. + public partial class ProxyOnlyResource + { + /// Initializes a new instance of ProxyOnlyResource. + public ProxyOnlyResource() + { + } + + /// Initializes a new instance of ProxyOnlyResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + internal ProxyOnlyResource(string id, string name, string type) + { + Id = id; + Name = name; + Type = type; + } + + /// Azure resource Id. + public string Id { get; } + /// Azure resource name. + public string Name { get; } + /// Azure resource type. + public string Type { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyResource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyResource.Serialization.cs new file mode 100644 index 000000000000..d96953c66ca2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyResource.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ProxyResource + { + internal static ProxyResource DeserializeProxyResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + } + return new ProxyResource(id.Value, name.Value, type.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyResource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyResource.cs new file mode 100644 index 000000000000..21de537644b8 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ProxyResource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// An azure resource object. + public partial class ProxyResource + { + /// Initializes a new instance of ProxyResource. + internal ProxyResource() + { + } + + /// Initializes a new instance of ProxyResource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + internal ProxyResource(string id, string name, string type) + { + Id = id; + Name = name; + Type = type; + } + + /// Azure resource Id. + public string Id { get; } + /// Azure resource name. + public string Name { get; } + /// Azure resource type. + public string Type { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/QueryType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/QueryType.cs new file mode 100644 index 000000000000..58f863fa5e2b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/QueryType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Set value to 'ResultAccount'. + public readonly partial struct QueryType : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public QueryType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ResultCountValue = "ResultCount"; + + /// ResultCount. + public static QueryType ResultCount { get; } = new QueryType(ResultCountValue); + /// Determines if two values are the same. + public static bool operator ==(QueryType left, QueryType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(QueryType left, QueryType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator QueryType(string value) => new QueryType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is QueryType other && Equals(other); + /// + public bool Equals(QueryType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ReceiverStatus.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ReceiverStatus.Serialization.cs new file mode 100644 index 000000000000..aed9318b90c2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ReceiverStatus.Serialization.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class ReceiverStatusExtensions + { + public static string ToSerialString(this ReceiverStatus value) => value switch + { + ReceiverStatus.NotSpecified => "NotSpecified", + ReceiverStatus.Enabled => "Enabled", + ReceiverStatus.Disabled => "Disabled", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ReceiverStatus value.") + }; + + public static ReceiverStatus ToReceiverStatus(this string value) + { + if (string.Equals(value, "NotSpecified", StringComparison.InvariantCultureIgnoreCase)) return ReceiverStatus.NotSpecified; + if (string.Equals(value, "Enabled", StringComparison.InvariantCultureIgnoreCase)) return ReceiverStatus.Enabled; + if (string.Equals(value, "Disabled", StringComparison.InvariantCultureIgnoreCase)) return ReceiverStatus.Disabled; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ReceiverStatus value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ReceiverStatus.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ReceiverStatus.cs new file mode 100644 index 000000000000..3848fe1a12b6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ReceiverStatus.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. + public enum ReceiverStatus + { + /// NotSpecified. + NotSpecified, + /// Enabled. + Enabled, + /// Disabled. + Disabled + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Recurrence.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Recurrence.Serialization.cs new file mode 100644 index 000000000000..9913e808d62c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Recurrence.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Recurrence : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("frequency"); + writer.WriteStringValue(Frequency.ToSerialString()); + writer.WritePropertyName("schedule"); + writer.WriteObjectValue(Schedule); + writer.WriteEndObject(); + } + + internal static Recurrence DeserializeRecurrence(JsonElement element) + { + RecurrenceFrequency frequency = default; + RecurrentSchedule schedule = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("frequency")) + { + frequency = property.Value.GetString().ToRecurrenceFrequency(); + continue; + } + if (property.NameEquals("schedule")) + { + schedule = RecurrentSchedule.DeserializeRecurrentSchedule(property.Value); + continue; + } + } + return new Recurrence(frequency, schedule); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Recurrence.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Recurrence.cs new file mode 100644 index 000000000000..16143d20c91d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Recurrence.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The repeating times at which this profile begins. This element is not used if the FixedDate element is used. + public partial class Recurrence + { + /// Initializes a new instance of Recurrence. + /// the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly. + /// the scheduling constraints for when the profile begins. + /// is null. + public Recurrence(RecurrenceFrequency frequency, RecurrentSchedule schedule) + { + if (schedule == null) + { + throw new ArgumentNullException(nameof(schedule)); + } + + Frequency = frequency; + Schedule = schedule; + } + + /// the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly. + public RecurrenceFrequency Frequency { get; set; } + /// the scheduling constraints for when the profile begins. + public RecurrentSchedule Schedule { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrenceFrequency.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrenceFrequency.Serialization.cs new file mode 100644 index 000000000000..31f6de0365dc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrenceFrequency.Serialization.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class RecurrenceFrequencyExtensions + { + public static string ToSerialString(this RecurrenceFrequency value) => value switch + { + RecurrenceFrequency.None => "None", + RecurrenceFrequency.Second => "Second", + RecurrenceFrequency.Minute => "Minute", + RecurrenceFrequency.Hour => "Hour", + RecurrenceFrequency.Day => "Day", + RecurrenceFrequency.Week => "Week", + RecurrenceFrequency.Month => "Month", + RecurrenceFrequency.Year => "Year", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown RecurrenceFrequency value.") + }; + + public static RecurrenceFrequency ToRecurrenceFrequency(this string value) + { + if (string.Equals(value, "None", StringComparison.InvariantCultureIgnoreCase)) return RecurrenceFrequency.None; + if (string.Equals(value, "Second", StringComparison.InvariantCultureIgnoreCase)) return RecurrenceFrequency.Second; + if (string.Equals(value, "Minute", StringComparison.InvariantCultureIgnoreCase)) return RecurrenceFrequency.Minute; + if (string.Equals(value, "Hour", StringComparison.InvariantCultureIgnoreCase)) return RecurrenceFrequency.Hour; + if (string.Equals(value, "Day", StringComparison.InvariantCultureIgnoreCase)) return RecurrenceFrequency.Day; + if (string.Equals(value, "Week", StringComparison.InvariantCultureIgnoreCase)) return RecurrenceFrequency.Week; + if (string.Equals(value, "Month", StringComparison.InvariantCultureIgnoreCase)) return RecurrenceFrequency.Month; + if (string.Equals(value, "Year", StringComparison.InvariantCultureIgnoreCase)) return RecurrenceFrequency.Year; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown RecurrenceFrequency value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrenceFrequency.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrenceFrequency.cs new file mode 100644 index 000000000000..aa9417b9d9be --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrenceFrequency.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly. + public enum RecurrenceFrequency + { + /// None. + None, + /// Second. + Second, + /// Minute. + Minute, + /// Hour. + Hour, + /// Day. + Day, + /// Week. + Week, + /// Month. + Month, + /// Year. + Year + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrentSchedule.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrentSchedule.Serialization.cs new file mode 100644 index 000000000000..d37405024374 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrentSchedule.Serialization.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RecurrentSchedule : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("timeZone"); + writer.WriteStringValue(TimeZone); + writer.WritePropertyName("days"); + writer.WriteStartArray(); + foreach (var item in Days) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("hours"); + writer.WriteStartArray(); + foreach (var item in Hours) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("minutes"); + writer.WriteStartArray(); + foreach (var item in Minutes) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } + + internal static RecurrentSchedule DeserializeRecurrentSchedule(JsonElement element) + { + string timeZone = default; + IList days = default; + IList hours = default; + IList minutes = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeZone")) + { + timeZone = property.Value.GetString(); + continue; + } + if (property.NameEquals("days")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + days = array; + continue; + } + if (property.NameEquals("hours")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + hours = array; + continue; + } + if (property.NameEquals("minutes")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + minutes = array; + continue; + } + } + return new RecurrentSchedule(timeZone, days, hours, minutes); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrentSchedule.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrentSchedule.cs new file mode 100644 index 000000000000..c797a3a410cf --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RecurrentSchedule.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The scheduling constraints for when the profile begins. + public partial class RecurrentSchedule + { + /// Initializes a new instance of RecurrentSchedule. + /// the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. + /// the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. + /// A collection of hours that the profile takes effect on. Values supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + /// A collection of minutes at which the profile takes effect at. + /// , , , or is null. + public RecurrentSchedule(string timeZone, IEnumerable days, IEnumerable hours, IEnumerable minutes) + { + if (timeZone == null) + { + throw new ArgumentNullException(nameof(timeZone)); + } + if (days == null) + { + throw new ArgumentNullException(nameof(days)); + } + if (hours == null) + { + throw new ArgumentNullException(nameof(hours)); + } + if (minutes == null) + { + throw new ArgumentNullException(nameof(minutes)); + } + + TimeZone = timeZone; + Days = days.ToList(); + Hours = hours.ToList(); + Minutes = minutes.ToList(); + } + + /// Initializes a new instance of RecurrentSchedule. + /// the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. + /// the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. + /// A collection of hours that the profile takes effect on. Values supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + /// A collection of minutes at which the profile takes effect at. + internal RecurrentSchedule(string timeZone, IList days, IList hours, IList minutes) + { + TimeZone = timeZone; + Days = days; + Hours = hours; + Minutes = minutes; + } + + /// the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. + public string TimeZone { get; set; } + /// the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. + public IList Days { get; } + /// A collection of hours that the profile takes effect on. Values supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + public IList Hours { get; } + /// A collection of minutes at which the profile takes effect at. + public IList Minutes { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Resource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Resource.Serialization.cs new file mode 100644 index 000000000000..98eef108445c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Resource.Serialization.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Resource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("location"); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WriteEndObject(); + } + + internal static Resource DeserializeResource(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + string location = default; + Optional> tags = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location")) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + } + return new Resource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Resource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Resource.cs new file mode 100644 index 000000000000..9914d9e57f9c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Resource.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An azure resource object. + public partial class Resource + { + /// Initializes a new instance of Resource. + /// Resource location. + /// is null. + public Resource(string location) + { + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + + Location = location; + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of Resource. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// Resource location. + /// Resource tags. + internal Resource(string id, string name, string type, string location, IDictionary tags) + { + Id = id; + Name = name; + Type = type; + Location = location; + Tags = tags; + } + + /// Azure resource Id. + public string Id { get; } + /// Azure resource name. + public string Name { get; } + /// Azure resource type. + public string Type { get; } + /// Resource location. + public string Location { get; set; } + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Response.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Response.Serialization.cs new file mode 100644 index 000000000000..6774519240a2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Response.Serialization.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Response + { + internal static Response DeserializeResponse(JsonElement element) + { + Optional cost = default; + string timespan = default; + Optional interval = default; + Optional @namespace = default; + Optional resourceregion = default; + IReadOnlyList value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("cost")) + { + cost = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("timespan")) + { + timespan = property.Value.GetString(); + continue; + } + if (property.NameEquals("interval")) + { + interval = property.Value.GetTimeSpan("P"); + continue; + } + if (property.NameEquals("namespace")) + { + @namespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceregion")) + { + resourceregion = property.Value.GetString(); + continue; + } + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Metric.DeserializeMetric(item)); + } + value = array; + continue; + } + } + return new Response(Optional.ToNullable(cost), timespan, Optional.ToNullable(interval), @namespace.Value, resourceregion.Value, value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Response.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Response.cs new file mode 100644 index 000000000000..c0e8f5b4d6b1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Response.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The response to a metrics query. + public partial class Response + { + /// Initializes a new instance of Response. + /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + /// the value of the collection. + /// or is null. + internal Response(string timespan, IEnumerable value) + { + if (timespan == null) + { + throw new ArgumentNullException(nameof(timespan)); + } + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Timespan = timespan; + Value = value.ToList(); + } + + /// Initializes a new instance of Response. + /// The integer value representing the cost of the query, for data case. + /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + /// The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + /// The namespace of the metrics been queried. + /// The region of the resource been queried for metrics. + /// the value of the collection. + internal Response(int? cost, string timespan, TimeSpan? interval, string @namespace, string resourceregion, IReadOnlyList value) + { + Cost = cost; + Timespan = timespan; + Interval = interval; + Namespace = @namespace; + Resourceregion = resourceregion; + Value = value; + } + + /// The integer value representing the cost of the query, for data case. + public int? Cost { get; } + /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + public string Timespan { get; } + /// The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + public TimeSpan? Interval { get; } + /// The namespace of the metrics been queried. + public string Namespace { get; } + /// The region of the resource been queried for metrics. + public string Resourceregion { get; } + /// the value of the collection. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResponseWithError.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResponseWithError.Serialization.cs new file mode 100644 index 000000000000..82a7517dc8bf --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResponseWithError.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + internal partial class ResponseWithError + { + internal static ResponseWithError DeserializeResponseWithError(JsonElement element) + { + Error error = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("error")) + { + error = Error.DeserializeError(property.Value); + continue; + } + } + return new ResponseWithError(error); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResponseWithError.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResponseWithError.cs new file mode 100644 index 000000000000..a2d117c5fd9b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResponseWithError.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An error response from the API. + internal partial class ResponseWithError + { + /// Initializes a new instance of ResponseWithError. + /// Error information. + /// is null. + internal ResponseWithError(Error error) + { + if (error == null) + { + throw new ArgumentNullException(nameof(error)); + } + + Error = error; + } + + /// Error information. + public Error Error { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResultType.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResultType.Serialization.cs new file mode 100644 index 000000000000..53dbd523ee53 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResultType.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class ResultTypeExtensions + { + public static string ToSerialString(this ResultType value) => value switch + { + ResultType.Data => "Data", + ResultType.Metadata => "Metadata", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResultType value.") + }; + + public static ResultType ToResultType(this string value) + { + if (string.Equals(value, "Data", StringComparison.InvariantCultureIgnoreCase)) return ResultType.Data; + if (string.Equals(value, "Metadata", StringComparison.InvariantCultureIgnoreCase)) return ResultType.Metadata; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResultType value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResultType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResultType.cs new file mode 100644 index 000000000000..2bdd19cbd663 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ResultType.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The ResultType. + public enum ResultType + { + /// Data. + Data, + /// Metadata. + Metadata + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RetentionPolicy.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RetentionPolicy.Serialization.cs new file mode 100644 index 000000000000..36ac1e700f8f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RetentionPolicy.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RetentionPolicy : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("enabled"); + writer.WriteBooleanValue(Enabled); + writer.WritePropertyName("days"); + writer.WriteNumberValue(Days); + writer.WriteEndObject(); + } + + internal static RetentionPolicy DeserializeRetentionPolicy(JsonElement element) + { + bool enabled = default; + int days = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enabled")) + { + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("days")) + { + days = property.Value.GetInt32(); + continue; + } + } + return new RetentionPolicy(enabled, days); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RetentionPolicy.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RetentionPolicy.cs new file mode 100644 index 000000000000..7746810e520b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RetentionPolicy.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the retention policy for the log. + public partial class RetentionPolicy + { + /// Initializes a new instance of RetentionPolicy. + /// a value indicating whether the retention policy is enabled. + /// the number of days for the retention in days. A value of 0 will retain the events indefinitely. + public RetentionPolicy(bool enabled, int days) + { + Enabled = enabled; + Days = days; + } + + /// a value indicating whether the retention policy is enabled. + public bool Enabled { get; set; } + /// the number of days for the retention in days. A value of 0 will retain the events indefinitely. + public int Days { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleAction.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleAction.Serialization.cs new file mode 100644 index 000000000000..8a154643e791 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleAction.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RuleAction : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + writer.WriteEndObject(); + } + + internal static RuleAction DeserializeRuleAction(JsonElement element) + { + if (element.TryGetProperty("odata.type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Microsoft.Azure.Management.Insights.Models.RuleEmailAction": return RuleEmailAction.DeserializeRuleEmailAction(element); + case "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction": return RuleWebhookAction.DeserializeRuleWebhookAction(element); + } + } + string odataType = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + } + return new RuleAction(odataType); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleAction.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleAction.cs new file mode 100644 index 000000000000..1f9923dc958f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleAction.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The action that is performed when the alert rule becomes active, and when an alert condition is resolved. + public partial class RuleAction + { + /// Initializes a new instance of RuleAction. + public RuleAction() + { + } + + /// Initializes a new instance of RuleAction. + /// specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction. + internal RuleAction(string odataType) + { + OdataType = odataType; + } + + /// specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction. + internal string OdataType { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleCondition.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleCondition.Serialization.cs new file mode 100644 index 000000000000..d65a86063400 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleCondition.Serialization.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RuleCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + if (Optional.IsDefined(DataSource)) + { + writer.WritePropertyName("dataSource"); + writer.WriteObjectValue(DataSource); + } + writer.WriteEndObject(); + } + + internal static RuleCondition DeserializeRuleCondition(JsonElement element) + { + if (element.TryGetProperty("odata.type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition": return LocationThresholdRuleCondition.DeserializeLocationThresholdRuleCondition(element); + case "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition": return ManagementEventRuleCondition.DeserializeManagementEventRuleCondition(element); + case "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition": return ThresholdRuleCondition.DeserializeThresholdRuleCondition(element); + } + } + string odataType = default; + Optional dataSource = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("dataSource")) + { + dataSource = RuleDataSource.DeserializeRuleDataSource(property.Value); + continue; + } + } + return new RuleCondition(odataType, dataSource.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleCondition.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleCondition.cs new file mode 100644 index 000000000000..791edc908420 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleCondition.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The condition that results in the alert rule being activated. + public partial class RuleCondition + { + /// Initializes a new instance of RuleCondition. + public RuleCondition() + { + } + + /// Initializes a new instance of RuleCondition. + /// specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric). + /// the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + internal RuleCondition(string odataType, RuleDataSource dataSource) + { + OdataType = odataType; + DataSource = dataSource; + } + + /// specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric). + internal string OdataType { get; set; } + /// the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + public RuleDataSource DataSource { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleDataSource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleDataSource.Serialization.cs new file mode 100644 index 000000000000..efd178474d61 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleDataSource.Serialization.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RuleDataSource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + if (Optional.IsDefined(ResourceUri)) + { + writer.WritePropertyName("resourceUri"); + writer.WriteStringValue(ResourceUri); + } + writer.WriteEndObject(); + } + + internal static RuleDataSource DeserializeRuleDataSource(JsonElement element) + { + if (element.TryGetProperty("odata.type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource": return RuleManagementEventDataSource.DeserializeRuleManagementEventDataSource(element); + case "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource": return RuleMetricDataSource.DeserializeRuleMetricDataSource(element); + } + } + string odataType = default; + Optional resourceUri = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceUri")) + { + resourceUri = property.Value.GetString(); + continue; + } + } + return new RuleDataSource(odataType, resourceUri.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleDataSource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleDataSource.cs new file mode 100644 index 000000000000..2a0e8f1c33a7 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleDataSource.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The resource from which the rule collects its data. + public partial class RuleDataSource + { + /// Initializes a new instance of RuleDataSource. + public RuleDataSource() + { + } + + /// Initializes a new instance of RuleDataSource. + /// specifies the type of data source. There are two types of rule data sources: RuleMetricDataSource and RuleManagementEventDataSource. + /// the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + internal RuleDataSource(string odataType, string resourceUri) + { + OdataType = odataType; + ResourceUri = resourceUri; + } + + /// specifies the type of data source. There are two types of rule data sources: RuleMetricDataSource and RuleManagementEventDataSource. + internal string OdataType { get; set; } + /// the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + public string ResourceUri { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleEmailAction.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleEmailAction.Serialization.cs new file mode 100644 index 000000000000..00d24a0c1b60 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleEmailAction.Serialization.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RuleEmailAction : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(SendToServiceOwners)) + { + writer.WritePropertyName("sendToServiceOwners"); + writer.WriteBooleanValue(SendToServiceOwners.Value); + } + if (Optional.IsCollectionDefined(CustomEmails)) + { + writer.WritePropertyName("customEmails"); + writer.WriteStartArray(); + foreach (var item in CustomEmails) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + writer.WriteEndObject(); + } + + internal static RuleEmailAction DeserializeRuleEmailAction(JsonElement element) + { + Optional sendToServiceOwners = default; + Optional> customEmails = default; + string odataType = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sendToServiceOwners")) + { + sendToServiceOwners = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("customEmails")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + customEmails = array; + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + } + return new RuleEmailAction(odataType, Optional.ToNullable(sendToServiceOwners), Optional.ToList(customEmails)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleEmailAction.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleEmailAction.cs new file mode 100644 index 000000000000..c05935ea24b3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleEmailAction.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the action to send email when the rule condition is evaluated. The discriminator is always RuleEmailAction in this case. + public partial class RuleEmailAction : RuleAction + { + /// Initializes a new instance of RuleEmailAction. + public RuleEmailAction() + { + CustomEmails = new ChangeTrackingList(); + OdataType = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction"; + } + + /// Initializes a new instance of RuleEmailAction. + /// specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction. + /// Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. + /// the list of administrator's custom email addresses to notify of the activation of the alert. + internal RuleEmailAction(string odataType, bool? sendToServiceOwners, IList customEmails) : base(odataType) + { + SendToServiceOwners = sendToServiceOwners; + CustomEmails = customEmails; + OdataType = odataType ?? "Microsoft.Azure.Management.Insights.Models.RuleEmailAction"; + } + + /// Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. + public bool? SendToServiceOwners { get; set; } + /// the list of administrator's custom email addresses to notify of the activation of the alert. + public IList CustomEmails { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventClaimsDataSource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventClaimsDataSource.Serialization.cs new file mode 100644 index 000000000000..687b3ffcb37b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventClaimsDataSource.Serialization.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RuleManagementEventClaimsDataSource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(EmailAddress)) + { + writer.WritePropertyName("emailAddress"); + writer.WriteStringValue(EmailAddress); + } + writer.WriteEndObject(); + } + + internal static RuleManagementEventClaimsDataSource DeserializeRuleManagementEventClaimsDataSource(JsonElement element) + { + Optional emailAddress = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("emailAddress")) + { + emailAddress = property.Value.GetString(); + continue; + } + } + return new RuleManagementEventClaimsDataSource(emailAddress.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventClaimsDataSource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventClaimsDataSource.cs new file mode 100644 index 000000000000..187b216f79a2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventClaimsDataSource.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The claims for a rule management event data source. + public partial class RuleManagementEventClaimsDataSource + { + /// Initializes a new instance of RuleManagementEventClaimsDataSource. + public RuleManagementEventClaimsDataSource() + { + } + + /// Initializes a new instance of RuleManagementEventClaimsDataSource. + /// the email address. + internal RuleManagementEventClaimsDataSource(string emailAddress) + { + EmailAddress = emailAddress; + } + + /// the email address. + public string EmailAddress { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventDataSource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventDataSource.Serialization.cs new file mode 100644 index 000000000000..315878393fd6 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventDataSource.Serialization.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RuleManagementEventDataSource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(EventName)) + { + writer.WritePropertyName("eventName"); + writer.WriteStringValue(EventName); + } + if (Optional.IsDefined(EventSource)) + { + writer.WritePropertyName("eventSource"); + writer.WriteStringValue(EventSource); + } + if (Optional.IsDefined(Level)) + { + writer.WritePropertyName("level"); + writer.WriteStringValue(Level); + } + if (Optional.IsDefined(OperationName)) + { + writer.WritePropertyName("operationName"); + writer.WriteStringValue(OperationName); + } + if (Optional.IsDefined(ResourceGroupName)) + { + writer.WritePropertyName("resourceGroupName"); + writer.WriteStringValue(ResourceGroupName); + } + if (Optional.IsDefined(ResourceProviderName)) + { + writer.WritePropertyName("resourceProviderName"); + writer.WriteStringValue(ResourceProviderName); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"); + writer.WriteStringValue(Status); + } + if (Optional.IsDefined(SubStatus)) + { + writer.WritePropertyName("subStatus"); + writer.WriteStringValue(SubStatus); + } + if (Optional.IsDefined(Claims)) + { + writer.WritePropertyName("claims"); + writer.WriteObjectValue(Claims); + } + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + if (Optional.IsDefined(ResourceUri)) + { + writer.WritePropertyName("resourceUri"); + writer.WriteStringValue(ResourceUri); + } + writer.WriteEndObject(); + } + + internal static RuleManagementEventDataSource DeserializeRuleManagementEventDataSource(JsonElement element) + { + Optional eventName = default; + Optional eventSource = default; + Optional level = default; + Optional operationName = default; + Optional resourceGroupName = default; + Optional resourceProviderName = default; + Optional status = default; + Optional subStatus = default; + Optional claims = default; + string odataType = default; + Optional resourceUri = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("eventName")) + { + eventName = property.Value.GetString(); + continue; + } + if (property.NameEquals("eventSource")) + { + eventSource = property.Value.GetString(); + continue; + } + if (property.NameEquals("level")) + { + level = property.Value.GetString(); + continue; + } + if (property.NameEquals("operationName")) + { + operationName = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceGroupName")) + { + resourceGroupName = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceProviderName")) + { + resourceProviderName = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("subStatus")) + { + subStatus = property.Value.GetString(); + continue; + } + if (property.NameEquals("claims")) + { + claims = RuleManagementEventClaimsDataSource.DeserializeRuleManagementEventClaimsDataSource(property.Value); + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceUri")) + { + resourceUri = property.Value.GetString(); + continue; + } + } + return new RuleManagementEventDataSource(odataType, resourceUri.Value, eventName.Value, eventSource.Value, level.Value, operationName.Value, resourceGroupName.Value, resourceProviderName.Value, status.Value, subStatus.Value, claims.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventDataSource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventDataSource.cs new file mode 100644 index 000000000000..55e34e50de9f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleManagementEventDataSource.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. + public partial class RuleManagementEventDataSource : RuleDataSource + { + /// Initializes a new instance of RuleManagementEventDataSource. + public RuleManagementEventDataSource() + { + OdataType = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource"; + } + + /// Initializes a new instance of RuleManagementEventDataSource. + /// specifies the type of data source. There are two types of rule data sources: RuleMetricDataSource and RuleManagementEventDataSource. + /// the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + /// the event name. + /// the event source. + /// the level. + /// The name of the operation that should be checked for. If no name is provided, any operation will match. + /// the resource group name. + /// the resource provider name. + /// The status of the operation that should be checked for. If no status is provided, any status will match. + /// the substatus. + /// the claims. + internal RuleManagementEventDataSource(string odataType, string resourceUri, string eventName, string eventSource, string level, string operationName, string resourceGroupName, string resourceProviderName, string status, string subStatus, RuleManagementEventClaimsDataSource claims) : base(odataType, resourceUri) + { + EventName = eventName; + EventSource = eventSource; + Level = level; + OperationName = operationName; + ResourceGroupName = resourceGroupName; + ResourceProviderName = resourceProviderName; + Status = status; + SubStatus = subStatus; + Claims = claims; + OdataType = odataType ?? "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource"; + } + + /// the event name. + public string EventName { get; set; } + /// the event source. + public string EventSource { get; set; } + /// the level. + public string Level { get; set; } + /// The name of the operation that should be checked for. If no name is provided, any operation will match. + public string OperationName { get; set; } + /// the resource group name. + public string ResourceGroupName { get; set; } + /// the resource provider name. + public string ResourceProviderName { get; set; } + /// The status of the operation that should be checked for. If no status is provided, any status will match. + public string Status { get; set; } + /// the substatus. + public string SubStatus { get; set; } + /// the claims. + public RuleManagementEventClaimsDataSource Claims { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleMetricDataSource.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleMetricDataSource.Serialization.cs new file mode 100644 index 000000000000..48a7e554dfcf --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleMetricDataSource.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RuleMetricDataSource : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(MetricName)) + { + writer.WritePropertyName("metricName"); + writer.WriteStringValue(MetricName); + } + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + if (Optional.IsDefined(ResourceUri)) + { + writer.WritePropertyName("resourceUri"); + writer.WriteStringValue(ResourceUri); + } + writer.WriteEndObject(); + } + + internal static RuleMetricDataSource DeserializeRuleMetricDataSource(JsonElement element) + { + Optional metricName = default; + string odataType = default; + Optional resourceUri = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metricName")) + { + metricName = property.Value.GetString(); + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceUri")) + { + resourceUri = property.Value.GetString(); + continue; + } + } + return new RuleMetricDataSource(odataType, resourceUri.Value, metricName.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleMetricDataSource.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleMetricDataSource.cs new file mode 100644 index 000000000000..936a56b1868b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleMetricDataSource.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// A rule metric data source. The discriminator value is always RuleMetricDataSource in this case. + public partial class RuleMetricDataSource : RuleDataSource + { + /// Initializes a new instance of RuleMetricDataSource. + public RuleMetricDataSource() + { + OdataType = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource"; + } + + /// Initializes a new instance of RuleMetricDataSource. + /// specifies the type of data source. There are two types of rule data sources: RuleMetricDataSource and RuleManagementEventDataSource. + /// the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + /// the name of the metric that defines what the rule monitors. + internal RuleMetricDataSource(string odataType, string resourceUri, string metricName) : base(odataType, resourceUri) + { + MetricName = metricName; + OdataType = odataType ?? "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource"; + } + + /// the name of the metric that defines what the rule monitors. + public string MetricName { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleWebhookAction.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleWebhookAction.Serialization.cs new file mode 100644 index 000000000000..287611bcb185 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleWebhookAction.Serialization.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class RuleWebhookAction : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ServiceUri)) + { + writer.WritePropertyName("serviceUri"); + writer.WriteStringValue(ServiceUri); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + writer.WriteEndObject(); + } + + internal static RuleWebhookAction DeserializeRuleWebhookAction(JsonElement element) + { + Optional serviceUri = default; + Optional> properties = default; + string odataType = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("serviceUri")) + { + serviceUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + properties = dictionary; + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + } + return new RuleWebhookAction(odataType, serviceUri.Value, Optional.ToDictionary(properties)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleWebhookAction.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleWebhookAction.cs new file mode 100644 index 000000000000..4fed139ae9f4 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/RuleWebhookAction.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the action to post to service when the rule condition is evaluated. The discriminator is always RuleWebhookAction in this case. + public partial class RuleWebhookAction : RuleAction + { + /// Initializes a new instance of RuleWebhookAction. + public RuleWebhookAction() + { + Properties = new ChangeTrackingDictionary(); + OdataType = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction"; + } + + /// Initializes a new instance of RuleWebhookAction. + /// specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction. + /// the service uri to Post the notification when the alert activates or resolves. + /// the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + internal RuleWebhookAction(string odataType, string serviceUri, IDictionary properties) : base(odataType) + { + ServiceUri = serviceUri; + Properties = properties; + OdataType = odataType ?? "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction"; + } + + /// the service uri to Post the notification when the alert activates or resolves. + public string ServiceUri { get; set; } + /// the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + public IDictionary Properties { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleAction.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleAction.Serialization.cs new file mode 100644 index 000000000000..575ee28e5f6f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleAction.Serialization.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ScaleAction : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("direction"); + writer.WriteStringValue(Direction.ToSerialString()); + writer.WritePropertyName("type"); + writer.WriteStringValue(Type.ToSerialString()); + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"); + writer.WriteStringValue(Value); + } + writer.WritePropertyName("cooldown"); + writer.WriteStringValue(Cooldown, "P"); + writer.WriteEndObject(); + } + + internal static ScaleAction DeserializeScaleAction(JsonElement element) + { + ScaleDirection direction = default; + ScaleType type = default; + Optional value = default; + TimeSpan cooldown = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("direction")) + { + direction = property.Value.GetString().ToScaleDirection(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString().ToScaleType(); + continue; + } + if (property.NameEquals("value")) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("cooldown")) + { + cooldown = property.Value.GetTimeSpan("P"); + continue; + } + } + return new ScaleAction(direction, type, value.Value, cooldown); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleAction.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleAction.cs new file mode 100644 index 000000000000..0b12fc8d1e26 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleAction.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The parameters for the scaling action. + public partial class ScaleAction + { + /// Initializes a new instance of ScaleAction. + /// the scale direction. Whether the scaling action increases or decreases the number of instances. + /// the type of action that should occur when the scale rule fires. + /// the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + public ScaleAction(ScaleDirection direction, ScaleType type, TimeSpan cooldown) + { + Direction = direction; + Type = type; + Cooldown = cooldown; + } + + /// Initializes a new instance of ScaleAction. + /// the scale direction. Whether the scaling action increases or decreases the number of instances. + /// the type of action that should occur when the scale rule fires. + /// the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. + /// the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + internal ScaleAction(ScaleDirection direction, ScaleType type, string value, TimeSpan cooldown) + { + Direction = direction; + Type = type; + Value = value; + Cooldown = cooldown; + } + + /// the scale direction. Whether the scaling action increases or decreases the number of instances. + public ScaleDirection Direction { get; set; } + /// the type of action that should occur when the scale rule fires. + public ScaleType Type { get; set; } + /// the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. + public string Value { get; set; } + /// the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + public TimeSpan Cooldown { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleCapacity.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleCapacity.Serialization.cs new file mode 100644 index 000000000000..7e04b9a24ad5 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleCapacity.Serialization.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ScaleCapacity : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("minimum"); + writer.WriteStringValue(Minimum); + writer.WritePropertyName("maximum"); + writer.WriteStringValue(Maximum); + writer.WritePropertyName("default"); + writer.WriteStringValue(Default); + writer.WriteEndObject(); + } + + internal static ScaleCapacity DeserializeScaleCapacity(JsonElement element) + { + string minimum = default; + string maximum = default; + string @default = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("minimum")) + { + minimum = property.Value.GetString(); + continue; + } + if (property.NameEquals("maximum")) + { + maximum = property.Value.GetString(); + continue; + } + if (property.NameEquals("default")) + { + @default = property.Value.GetString(); + continue; + } + } + return new ScaleCapacity(minimum, maximum, @default); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleCapacity.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleCapacity.cs new file mode 100644 index 000000000000..ff35e706cc1c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleCapacity.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The number of instances that can be used during this profile. + public partial class ScaleCapacity + { + /// Initializes a new instance of ScaleCapacity. + /// the minimum number of instances for the resource. + /// the maximum number of instances for the resource. The actual maximum number of instances is limited by the cores that are available in the subscription. + /// the number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default. + /// , , or is null. + public ScaleCapacity(string minimum, string maximum, string @default) + { + if (minimum == null) + { + throw new ArgumentNullException(nameof(minimum)); + } + if (maximum == null) + { + throw new ArgumentNullException(nameof(maximum)); + } + if (@default == null) + { + throw new ArgumentNullException(nameof(@default)); + } + + Minimum = minimum; + Maximum = maximum; + Default = @default; + } + + /// the minimum number of instances for the resource. + public string Minimum { get; set; } + /// the maximum number of instances for the resource. The actual maximum number of instances is limited by the cores that are available in the subscription. + public string Maximum { get; set; } + /// the number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default. + public string Default { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleDirection.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleDirection.Serialization.cs new file mode 100644 index 000000000000..50c335323523 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleDirection.Serialization.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class ScaleDirectionExtensions + { + public static string ToSerialString(this ScaleDirection value) => value switch + { + ScaleDirection.None => "None", + ScaleDirection.Increase => "Increase", + ScaleDirection.Decrease => "Decrease", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ScaleDirection value.") + }; + + public static ScaleDirection ToScaleDirection(this string value) + { + if (string.Equals(value, "None", StringComparison.InvariantCultureIgnoreCase)) return ScaleDirection.None; + if (string.Equals(value, "Increase", StringComparison.InvariantCultureIgnoreCase)) return ScaleDirection.Increase; + if (string.Equals(value, "Decrease", StringComparison.InvariantCultureIgnoreCase)) return ScaleDirection.Decrease; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ScaleDirection value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleDirection.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleDirection.cs new file mode 100644 index 000000000000..76c8e4414cbe --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleDirection.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the scale direction. Whether the scaling action increases or decreases the number of instances. + public enum ScaleDirection + { + /// None. + None, + /// Increase. + Increase, + /// Decrease. + Decrease + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRule.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRule.Serialization.cs new file mode 100644 index 000000000000..3f8c797dae4b --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRule.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ScaleRule : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("metricTrigger"); + writer.WriteObjectValue(MetricTrigger); + writer.WritePropertyName("scaleAction"); + writer.WriteObjectValue(ScaleAction); + writer.WriteEndObject(); + } + + internal static ScaleRule DeserializeScaleRule(JsonElement element) + { + MetricTrigger metricTrigger = default; + ScaleAction scaleAction = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metricTrigger")) + { + metricTrigger = MetricTrigger.DeserializeMetricTrigger(property.Value); + continue; + } + if (property.NameEquals("scaleAction")) + { + scaleAction = ScaleAction.DeserializeScaleAction(property.Value); + continue; + } + } + return new ScaleRule(metricTrigger, scaleAction); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRule.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRule.cs new file mode 100644 index 000000000000..2fd85c49939e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRule.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A rule that provide the triggers and parameters for the scaling action. + public partial class ScaleRule + { + /// Initializes a new instance of ScaleRule. + /// the trigger that results in a scaling action. + /// the parameters for the scaling action. + /// or is null. + public ScaleRule(MetricTrigger metricTrigger, ScaleAction scaleAction) + { + if (metricTrigger == null) + { + throw new ArgumentNullException(nameof(metricTrigger)); + } + if (scaleAction == null) + { + throw new ArgumentNullException(nameof(scaleAction)); + } + + MetricTrigger = metricTrigger; + ScaleAction = scaleAction; + } + + /// the trigger that results in a scaling action. + public MetricTrigger MetricTrigger { get; set; } + /// the parameters for the scaling action. + public ScaleAction ScaleAction { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRuleMetricDimension.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRuleMetricDimension.Serialization.cs new file mode 100644 index 000000000000..4e766cacf3ea --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRuleMetricDimension.Serialization.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ScaleRuleMetricDimension : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("DimensionName"); + writer.WriteStringValue(DimensionName); + writer.WritePropertyName("Operator"); + writer.WriteStringValue(Operator.ToString()); + writer.WritePropertyName("Values"); + writer.WriteStartArray(); + foreach (var item in Values) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } + + internal static ScaleRuleMetricDimension DeserializeScaleRuleMetricDimension(JsonElement element) + { + string dimensionName = default; + ScaleRuleMetricDimensionOperationType @operator = default; + IList values = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("DimensionName")) + { + dimensionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("Operator")) + { + @operator = new ScaleRuleMetricDimensionOperationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("Values")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + values = array; + continue; + } + } + return new ScaleRuleMetricDimension(dimensionName, @operator, values); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRuleMetricDimension.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRuleMetricDimension.cs new file mode 100644 index 000000000000..4f6d7dbcd99d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRuleMetricDimension.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies an auto scale rule metric dimension. + public partial class ScaleRuleMetricDimension + { + /// Initializes a new instance of ScaleRuleMetricDimension. + /// Name of the dimension. + /// the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. + /// list of dimension values. For example: ["App1","App2"]. + /// or is null. + public ScaleRuleMetricDimension(string dimensionName, ScaleRuleMetricDimensionOperationType @operator, IEnumerable values) + { + if (dimensionName == null) + { + throw new ArgumentNullException(nameof(dimensionName)); + } + if (values == null) + { + throw new ArgumentNullException(nameof(values)); + } + + DimensionName = dimensionName; + Operator = @operator; + Values = values.ToList(); + } + + /// Initializes a new instance of ScaleRuleMetricDimension. + /// Name of the dimension. + /// the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. + /// list of dimension values. For example: ["App1","App2"]. + internal ScaleRuleMetricDimension(string dimensionName, ScaleRuleMetricDimensionOperationType @operator, IList values) + { + DimensionName = dimensionName; + Operator = @operator; + Values = values; + } + + /// Name of the dimension. + public string DimensionName { get; set; } + /// the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. + public ScaleRuleMetricDimensionOperationType Operator { get; set; } + /// list of dimension values. For example: ["App1","App2"]. + public IList Values { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRuleMetricDimensionOperationType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRuleMetricDimensionOperationType.cs new file mode 100644 index 000000000000..75a57890fd3d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleRuleMetricDimensionOperationType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Insights.Models +{ + /// the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. + public readonly partial struct ScaleRuleMetricDimensionOperationType : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public ScaleRuleMetricDimensionOperationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EqualsValueValue = "Equals"; + private const string NotEqualsValue = "NotEquals"; + + /// Equals. + public static ScaleRuleMetricDimensionOperationType EqualsValue { get; } = new ScaleRuleMetricDimensionOperationType(EqualsValueValue); + /// NotEquals. + public static ScaleRuleMetricDimensionOperationType NotEquals { get; } = new ScaleRuleMetricDimensionOperationType(NotEqualsValue); + /// Determines if two values are the same. + public static bool operator ==(ScaleRuleMetricDimensionOperationType left, ScaleRuleMetricDimensionOperationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ScaleRuleMetricDimensionOperationType left, ScaleRuleMetricDimensionOperationType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ScaleRuleMetricDimensionOperationType(string value) => new ScaleRuleMetricDimensionOperationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ScaleRuleMetricDimensionOperationType other && Equals(other); + /// + public bool Equals(ScaleRuleMetricDimensionOperationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleType.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleType.Serialization.cs new file mode 100644 index 000000000000..24929ac31159 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleType.Serialization.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class ScaleTypeExtensions + { + public static string ToSerialString(this ScaleType value) => value switch + { + ScaleType.ChangeCount => "ChangeCount", + ScaleType.PercentChangeCount => "PercentChangeCount", + ScaleType.ExactCount => "ExactCount", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ScaleType value.") + }; + + public static ScaleType ToScaleType(this string value) + { + if (string.Equals(value, "ChangeCount", StringComparison.InvariantCultureIgnoreCase)) return ScaleType.ChangeCount; + if (string.Equals(value, "PercentChangeCount", StringComparison.InvariantCultureIgnoreCase)) return ScaleType.PercentChangeCount; + if (string.Equals(value, "ExactCount", StringComparison.InvariantCultureIgnoreCase)) return ScaleType.ExactCount; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ScaleType value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleType.cs new file mode 100644 index 000000000000..4b9a1d2c7235 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ScaleType.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the type of action that should occur when the scale rule fires. + public enum ScaleType + { + /// ChangeCount. + ChangeCount, + /// PercentChangeCount. + PercentChangeCount, + /// ExactCount. + ExactCount + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Schedule.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Schedule.Serialization.cs new file mode 100644 index 000000000000..55f252eea7ec --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Schedule.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Schedule : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("frequencyInMinutes"); + writer.WriteNumberValue(FrequencyInMinutes); + writer.WritePropertyName("timeWindowInMinutes"); + writer.WriteNumberValue(TimeWindowInMinutes); + writer.WriteEndObject(); + } + + internal static Schedule DeserializeSchedule(JsonElement element) + { + int frequencyInMinutes = default; + int timeWindowInMinutes = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("frequencyInMinutes")) + { + frequencyInMinutes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("timeWindowInMinutes")) + { + timeWindowInMinutes = property.Value.GetInt32(); + continue; + } + } + return new Schedule(frequencyInMinutes, timeWindowInMinutes); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Schedule.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Schedule.cs new file mode 100644 index 000000000000..232cb9a90cd9 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Schedule.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Defines how often to run the search and the time interval. + public partial class Schedule + { + /// Initializes a new instance of Schedule. + /// frequency (in minutes) at which rule condition should be evaluated. + /// Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). + public Schedule(int frequencyInMinutes, int timeWindowInMinutes) + { + FrequencyInMinutes = frequencyInMinutes; + TimeWindowInMinutes = timeWindowInMinutes; + } + + /// frequency (in minutes) at which rule condition should be evaluated. + public int FrequencyInMinutes { get; set; } + /// Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). + public int TimeWindowInMinutes { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SenderAuthorization.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SenderAuthorization.Serialization.cs new file mode 100644 index 000000000000..0621abdccfe9 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SenderAuthorization.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class SenderAuthorization + { + internal static SenderAuthorization DeserializeSenderAuthorization(JsonElement element) + { + Optional action = default; + Optional role = default; + Optional scope = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("action")) + { + action = property.Value.GetString(); + continue; + } + if (property.NameEquals("role")) + { + role = property.Value.GetString(); + continue; + } + if (property.NameEquals("scope")) + { + scope = property.Value.GetString(); + continue; + } + } + return new SenderAuthorization(action.Value, role.Value, scope.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SenderAuthorization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SenderAuthorization.cs new file mode 100644 index 000000000000..b3653c667ef1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SenderAuthorization.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the authorization used by the user who has performed the operation that led to this event. This captures the RBAC properties of the event. These usually include the 'action', 'role' and the 'scope'. + public partial class SenderAuthorization + { + /// Initializes a new instance of SenderAuthorization. + internal SenderAuthorization() + { + } + + /// Initializes a new instance of SenderAuthorization. + /// the permissible actions. For instance: microsoft.support/supporttickets/write. + /// the role of the user. For instance: Subscription Admin. + /// the scope. + internal SenderAuthorization(string action, string role, string scope) + { + Action = action; + Role = role; + Scope = scope; + } + + /// the permissible actions. For instance: microsoft.support/supporttickets/write. + public string Action { get; } + /// the role of the user. For instance: Subscription Admin. + public string Role { get; } + /// the scope. + public string Scope { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Sensitivity.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Sensitivity.Serialization.cs new file mode 100644 index 000000000000..bdf4555297fb --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Sensitivity.Serialization.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class SensitivityExtensions + { + public static string ToSerialString(this Sensitivity value) => value switch + { + Sensitivity.Low => "Low", + Sensitivity.Medium => "Medium", + Sensitivity.High => "High", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown Sensitivity value.") + }; + + public static Sensitivity ToSensitivity(this string value) + { + if (string.Equals(value, "Low", StringComparison.InvariantCultureIgnoreCase)) return Sensitivity.Low; + if (string.Equals(value, "Medium", StringComparison.InvariantCultureIgnoreCase)) return Sensitivity.Medium; + if (string.Equals(value, "High", StringComparison.InvariantCultureIgnoreCase)) return Sensitivity.High; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown Sensitivity value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Sensitivity.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Sensitivity.cs new file mode 100644 index 000000000000..153d2d0a0044 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Sensitivity.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the sensitivity of the baseline. + public enum Sensitivity + { + /// Low. + Low, + /// Medium. + Medium, + /// High. + High + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleBaseline.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleBaseline.Serialization.cs new file mode 100644 index 000000000000..ccc2d27366d5 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleBaseline.Serialization.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class SingleBaseline + { + internal static SingleBaseline DeserializeSingleBaseline(JsonElement element) + { + BaselineSensitivity sensitivity = default; + IReadOnlyList lowThresholds = default; + IReadOnlyList highThresholds = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sensitivity")) + { + sensitivity = new BaselineSensitivity(property.Value.GetString()); + continue; + } + if (property.NameEquals("lowThresholds")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + lowThresholds = array; + continue; + } + if (property.NameEquals("highThresholds")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + highThresholds = array; + continue; + } + } + return new SingleBaseline(sensitivity, lowThresholds, highThresholds); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleBaseline.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleBaseline.cs new file mode 100644 index 000000000000..c35d4464eb6f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleBaseline.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The baseline values for a single sensitivity value. + public partial class SingleBaseline + { + /// Initializes a new instance of SingleBaseline. + /// the sensitivity of the baseline. + /// The low thresholds of the baseline. + /// The high thresholds of the baseline. + /// or is null. + internal SingleBaseline(BaselineSensitivity sensitivity, IEnumerable lowThresholds, IEnumerable highThresholds) + { + if (lowThresholds == null) + { + throw new ArgumentNullException(nameof(lowThresholds)); + } + if (highThresholds == null) + { + throw new ArgumentNullException(nameof(highThresholds)); + } + + Sensitivity = sensitivity; + LowThresholds = lowThresholds.ToList(); + HighThresholds = highThresholds.ToList(); + } + + /// Initializes a new instance of SingleBaseline. + /// the sensitivity of the baseline. + /// The low thresholds of the baseline. + /// The high thresholds of the baseline. + internal SingleBaseline(BaselineSensitivity sensitivity, IReadOnlyList lowThresholds, IReadOnlyList highThresholds) + { + Sensitivity = sensitivity; + LowThresholds = lowThresholds; + HighThresholds = highThresholds; + } + + /// the sensitivity of the baseline. + public BaselineSensitivity Sensitivity { get; } + /// The low thresholds of the baseline. + public IReadOnlyList LowThresholds { get; } + /// The high thresholds of the baseline. + public IReadOnlyList HighThresholds { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleMetricBaseline.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleMetricBaseline.Serialization.cs new file mode 100644 index 000000000000..468e1cb5d1e0 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleMetricBaseline.Serialization.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class SingleMetricBaseline + { + internal static SingleMetricBaseline DeserializeSingleMetricBaseline(JsonElement element) + { + string id = default; + string type = default; + string name = default; + string timespan = default; + TimeSpan interval = default; + Optional @namespace = default; + IReadOnlyList baselines = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("timespan")) + { + timespan = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("interval")) + { + interval = property0.Value.GetTimeSpan("P"); + continue; + } + if (property0.NameEquals("namespace")) + { + @namespace = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("baselines")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(TimeSeriesBaseline.DeserializeTimeSeriesBaseline(item)); + } + baselines = array; + continue; + } + } + continue; + } + } + return new SingleMetricBaseline(id, type, name, timespan, interval, @namespace.Value, baselines); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleMetricBaseline.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleMetricBaseline.cs new file mode 100644 index 000000000000..f0828e606630 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SingleMetricBaseline.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The baseline results of a single metric. + public partial class SingleMetricBaseline + { + /// Initializes a new instance of SingleMetricBaseline. + /// The metric baseline Id. + /// The resource type of the metric baseline resource. + /// The name of the metric for which the baselines were retrieved. + /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + /// The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + /// The baseline for each time series that was queried. + /// , , , , or is null. + internal SingleMetricBaseline(string id, string type, string name, string timespan, TimeSpan interval, IEnumerable baselines) + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (timespan == null) + { + throw new ArgumentNullException(nameof(timespan)); + } + if (baselines == null) + { + throw new ArgumentNullException(nameof(baselines)); + } + + Id = id; + Type = type; + Name = name; + Timespan = timespan; + Interval = interval; + Baselines = baselines.ToList(); + } + + /// Initializes a new instance of SingleMetricBaseline. + /// The metric baseline Id. + /// The resource type of the metric baseline resource. + /// The name of the metric for which the baselines were retrieved. + /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + /// The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + /// The namespace of the metrics been queried. + /// The baseline for each time series that was queried. + internal SingleMetricBaseline(string id, string type, string name, string timespan, TimeSpan interval, string @namespace, IReadOnlyList baselines) + { + Id = id; + Type = type; + Name = name; + Timespan = timespan; + Interval = interval; + Namespace = @namespace; + Baselines = baselines; + } + + /// The metric baseline Id. + public string Id { get; } + /// The resource type of the metric baseline resource. + public string Type { get; } + /// The name of the metric for which the baselines were retrieved. + public string Name { get; } + /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + public string Timespan { get; } + /// The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + public TimeSpan Interval { get; } + /// The namespace of the metrics been queried. + public string Namespace { get; } + /// The baseline for each time series that was queried. + public IReadOnlyList Baselines { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SmsReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SmsReceiver.Serialization.cs new file mode 100644 index 000000000000..1f762ba03e6c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SmsReceiver.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class SmsReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("countryCode"); + writer.WriteStringValue(CountryCode); + writer.WritePropertyName("phoneNumber"); + writer.WriteStringValue(PhoneNumber); + writer.WriteEndObject(); + } + + internal static SmsReceiver DeserializeSmsReceiver(JsonElement element) + { + string name = default; + string countryCode = default; + string phoneNumber = default; + Optional status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("countryCode")) + { + countryCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("phoneNumber")) + { + phoneNumber = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = property.Value.GetString().ToReceiverStatus(); + continue; + } + } + return new SmsReceiver(name, countryCode, phoneNumber, Optional.ToNullable(status)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SmsReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SmsReceiver.cs new file mode 100644 index 000000000000..8b4f58b43996 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/SmsReceiver.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// An SMS receiver. + public partial class SmsReceiver + { + /// Initializes a new instance of SmsReceiver. + /// The name of the SMS receiver. Names must be unique across all receivers within an action group. + /// The country code of the SMS receiver. + /// The phone number of the SMS receiver. + /// , , or is null. + public SmsReceiver(string name, string countryCode, string phoneNumber) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (countryCode == null) + { + throw new ArgumentNullException(nameof(countryCode)); + } + if (phoneNumber == null) + { + throw new ArgumentNullException(nameof(phoneNumber)); + } + + Name = name; + CountryCode = countryCode; + PhoneNumber = phoneNumber; + } + + /// Initializes a new instance of SmsReceiver. + /// The name of the SMS receiver. Names must be unique across all receivers within an action group. + /// The country code of the SMS receiver. + /// The phone number of the SMS receiver. + /// The status of the receiver. + internal SmsReceiver(string name, string countryCode, string phoneNumber, ReceiverStatus? status) + { + Name = name; + CountryCode = countryCode; + PhoneNumber = phoneNumber; + Status = status; + } + + /// The name of the SMS receiver. Names must be unique across all receivers within an action group. + public string Name { get; set; } + /// The country code of the SMS receiver. + public string CountryCode { get; set; } + /// The phone number of the SMS receiver. + public string PhoneNumber { get; set; } + /// The status of the receiver. + public ReceiverStatus? Status { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Source.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Source.Serialization.cs new file mode 100644 index 000000000000..79a41055ad2e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Source.Serialization.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class Source : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Query)) + { + writer.WritePropertyName("query"); + writer.WriteStringValue(Query); + } + if (Optional.IsCollectionDefined(AuthorizedResources)) + { + writer.WritePropertyName("authorizedResources"); + writer.WriteStartArray(); + foreach (var item in AuthorizedResources) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("dataSourceId"); + writer.WriteStringValue(DataSourceId); + if (Optional.IsDefined(QueryType)) + { + writer.WritePropertyName("queryType"); + writer.WriteStringValue(QueryType.Value.ToString()); + } + writer.WriteEndObject(); + } + + internal static Source DeserializeSource(JsonElement element) + { + Optional query = default; + Optional> authorizedResources = default; + string dataSourceId = default; + Optional queryType = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("query")) + { + query = property.Value.GetString(); + continue; + } + if (property.NameEquals("authorizedResources")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + authorizedResources = array; + continue; + } + if (property.NameEquals("dataSourceId")) + { + dataSourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("queryType")) + { + queryType = new QueryType(property.Value.GetString()); + continue; + } + } + return new Source(query.Value, Optional.ToList(authorizedResources), dataSourceId, Optional.ToNullable(queryType)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Source.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Source.cs new file mode 100644 index 000000000000..39fe351425cd --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Source.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the log search query. + public partial class Source + { + /// Initializes a new instance of Source. + /// The resource uri over which log search query is to be run. + /// is null. + public Source(string dataSourceId) + { + if (dataSourceId == null) + { + throw new ArgumentNullException(nameof(dataSourceId)); + } + + AuthorizedResources = new ChangeTrackingList(); + DataSourceId = dataSourceId; + } + + /// Initializes a new instance of Source. + /// Log search query. Required for action type - AlertingAction. + /// List of Resource referred into query. + /// The resource uri over which log search query is to be run. + /// Set value to 'ResultCount' . + internal Source(string query, IList authorizedResources, string dataSourceId, QueryType? queryType) + { + Query = query; + AuthorizedResources = authorizedResources; + DataSourceId = dataSourceId; + QueryType = queryType; + } + + /// Log search query. Required for action type - AlertingAction. + public string Query { get; set; } + /// List of Resource referred into query. + public IList AuthorizedResources { get; } + /// The resource uri over which log search query is to be run. + public string DataSourceId { get; set; } + /// Set value to 'ResultCount' . + public QueryType? QueryType { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ThresholdRuleCondition.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ThresholdRuleCondition.Serialization.cs new file mode 100644 index 000000000000..4b3d127d03ac --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ThresholdRuleCondition.Serialization.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class ThresholdRuleCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("operator"); + writer.WriteStringValue(Operator.ToSerialString()); + writer.WritePropertyName("threshold"); + writer.WriteNumberValue(Threshold); + if (Optional.IsDefined(WindowSize)) + { + writer.WritePropertyName("windowSize"); + writer.WriteStringValue(WindowSize.Value, "P"); + } + if (Optional.IsDefined(TimeAggregation)) + { + writer.WritePropertyName("timeAggregation"); + writer.WriteStringValue(TimeAggregation.Value.ToSerialString()); + } + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType); + if (Optional.IsDefined(DataSource)) + { + writer.WritePropertyName("dataSource"); + writer.WriteObjectValue(DataSource); + } + writer.WriteEndObject(); + } + + internal static ThresholdRuleCondition DeserializeThresholdRuleCondition(JsonElement element) + { + ConditionOperator @operator = default; + double threshold = default; + Optional windowSize = default; + Optional timeAggregation = default; + string odataType = default; + Optional dataSource = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operator")) + { + @operator = property.Value.GetString().ToConditionOperator(); + continue; + } + if (property.NameEquals("threshold")) + { + threshold = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("windowSize")) + { + windowSize = property.Value.GetTimeSpan("P"); + continue; + } + if (property.NameEquals("timeAggregation")) + { + timeAggregation = property.Value.GetString().ToTimeAggregationOperator(); + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("dataSource")) + { + dataSource = RuleDataSource.DeserializeRuleDataSource(property.Value); + continue; + } + } + return new ThresholdRuleCondition(odataType, dataSource.Value, @operator, threshold, Optional.ToNullable(windowSize), Optional.ToNullable(timeAggregation)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ThresholdRuleCondition.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ThresholdRuleCondition.cs new file mode 100644 index 000000000000..02b9c54e92a7 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/ThresholdRuleCondition.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A rule condition based on a metric crossing a threshold. + public partial class ThresholdRuleCondition : RuleCondition + { + /// Initializes a new instance of ThresholdRuleCondition. + /// the operator used to compare the data and the threshold. + /// the threshold value that activates the alert. + public ThresholdRuleCondition(ConditionOperator @operator, double threshold) + { + Operator = @operator; + Threshold = threshold; + OdataType = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition"; + } + + /// Initializes a new instance of ThresholdRuleCondition. + /// specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric). + /// the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + /// the operator used to compare the data and the threshold. + /// the threshold value that activates the alert. + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + /// the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. + internal ThresholdRuleCondition(string odataType, RuleDataSource dataSource, ConditionOperator @operator, double threshold, TimeSpan? windowSize, TimeAggregationOperator? timeAggregation) : base(odataType, dataSource) + { + Operator = @operator; + Threshold = threshold; + WindowSize = windowSize; + TimeAggregation = timeAggregation; + OdataType = odataType ?? "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition"; + } + + /// the operator used to compare the data and the threshold. + public ConditionOperator Operator { get; set; } + /// the threshold value that activates the alert. + public double Threshold { get; set; } + /// the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + public TimeSpan? WindowSize { get; set; } + /// the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. + public TimeAggregationOperator? TimeAggregation { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationOperator.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationOperator.Serialization.cs new file mode 100644 index 000000000000..e05030d10d12 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationOperator.Serialization.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class TimeAggregationOperatorExtensions + { + public static string ToSerialString(this TimeAggregationOperator value) => value switch + { + TimeAggregationOperator.Average => "Average", + TimeAggregationOperator.Minimum => "Minimum", + TimeAggregationOperator.Maximum => "Maximum", + TimeAggregationOperator.Total => "Total", + TimeAggregationOperator.Last => "Last", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TimeAggregationOperator value.") + }; + + public static TimeAggregationOperator ToTimeAggregationOperator(this string value) + { + if (string.Equals(value, "Average", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationOperator.Average; + if (string.Equals(value, "Minimum", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationOperator.Minimum; + if (string.Equals(value, "Maximum", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationOperator.Maximum; + if (string.Equals(value, "Total", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationOperator.Total; + if (string.Equals(value, "Last", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationOperator.Last; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TimeAggregationOperator value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationOperator.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationOperator.cs new file mode 100644 index 000000000000..35d247fa69bf --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationOperator.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// Aggregation operators allowed in a rule. + public enum TimeAggregationOperator + { + /// Average. + Average, + /// Minimum. + Minimum, + /// Maximum. + Maximum, + /// Total. + Total, + /// Last. + Last + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationType.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationType.Serialization.cs new file mode 100644 index 000000000000..9dc486d773cc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationType.Serialization.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class TimeAggregationTypeExtensions + { + public static string ToSerialString(this TimeAggregationType value) => value switch + { + TimeAggregationType.Average => "Average", + TimeAggregationType.Minimum => "Minimum", + TimeAggregationType.Maximum => "Maximum", + TimeAggregationType.Total => "Total", + TimeAggregationType.Count => "Count", + TimeAggregationType.Last => "Last", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TimeAggregationType value.") + }; + + public static TimeAggregationType ToTimeAggregationType(this string value) + { + if (string.Equals(value, "Average", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationType.Average; + if (string.Equals(value, "Minimum", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationType.Minimum; + if (string.Equals(value, "Maximum", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationType.Maximum; + if (string.Equals(value, "Total", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationType.Total; + if (string.Equals(value, "Count", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationType.Count; + if (string.Equals(value, "Last", StringComparison.InvariantCultureIgnoreCase)) return TimeAggregationType.Last; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TimeAggregationType value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationType.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationType.cs new file mode 100644 index 000000000000..1be168a46402 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeAggregationType.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// time aggregation type. How the data that is collected should be combined over time. The default value is Average. + public enum TimeAggregationType + { + /// Average. + Average, + /// Minimum. + Minimum, + /// Maximum. + Maximum, + /// Total. + Total, + /// Count. + Count, + /// Last. + Last + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesBaseline.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesBaseline.Serialization.cs new file mode 100644 index 000000000000..a16cea01173f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesBaseline.Serialization.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class TimeSeriesBaseline + { + internal static TimeSeriesBaseline DeserializeTimeSeriesBaseline(JsonElement element) + { + string aggregation = default; + Optional> dimensions = default; + IReadOnlyList timestamps = default; + IReadOnlyList data = default; + Optional> metadata = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("aggregation")) + { + aggregation = property.Value.GetString(); + continue; + } + if (property.NameEquals("dimensions")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricSingleDimension.DeserializeMetricSingleDimension(item)); + } + dimensions = array; + continue; + } + if (property.NameEquals("timestamps")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDateTimeOffset("O")); + } + timestamps = array; + continue; + } + if (property.NameEquals("data")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SingleBaseline.DeserializeSingleBaseline(item)); + } + data = array; + continue; + } + if (property.NameEquals("metadata")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(BaselineMetadata.DeserializeBaselineMetadata(item)); + } + metadata = array; + continue; + } + } + return new TimeSeriesBaseline(aggregation, Optional.ToList(dimensions), timestamps, data, Optional.ToList(metadata)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesBaseline.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesBaseline.cs new file mode 100644 index 000000000000..befae31585ce --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesBaseline.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The baseline values for a single time series. + public partial class TimeSeriesBaseline + { + /// Initializes a new instance of TimeSeriesBaseline. + /// The aggregation type of the metric. + /// The list of timestamps of the baselines. + /// The baseline values for each sensitivity. + /// , , or is null. + internal TimeSeriesBaseline(string aggregation, IEnumerable timestamps, IEnumerable data) + { + if (aggregation == null) + { + throw new ArgumentNullException(nameof(aggregation)); + } + if (timestamps == null) + { + throw new ArgumentNullException(nameof(timestamps)); + } + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + Aggregation = aggregation; + Dimensions = new ChangeTrackingList(); + Timestamps = timestamps.ToList(); + Data = data.ToList(); + Metadata = new ChangeTrackingList(); + } + + /// Initializes a new instance of TimeSeriesBaseline. + /// The aggregation type of the metric. + /// The dimensions of this time series. + /// The list of timestamps of the baselines. + /// The baseline values for each sensitivity. + /// The baseline metadata values. + internal TimeSeriesBaseline(string aggregation, IReadOnlyList dimensions, IReadOnlyList timestamps, IReadOnlyList data, IReadOnlyList metadata) + { + Aggregation = aggregation; + Dimensions = dimensions; + Timestamps = timestamps; + Data = data; + Metadata = metadata; + } + + /// The aggregation type of the metric. + public string Aggregation { get; } + /// The dimensions of this time series. + public IReadOnlyList Dimensions { get; } + /// The list of timestamps of the baselines. + public IReadOnlyList Timestamps { get; } + /// The baseline values for each sensitivity. + public IReadOnlyList Data { get; } + /// The baseline metadata values. + public IReadOnlyList Metadata { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesElement.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesElement.Serialization.cs new file mode 100644 index 000000000000..4fa9240a6ddc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesElement.Serialization.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class TimeSeriesElement + { + internal static TimeSeriesElement DeserializeTimeSeriesElement(JsonElement element) + { + Optional> metadatavalues = default; + Optional> data = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metadatavalues")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetadataValue.DeserializeMetadataValue(item)); + } + metadatavalues = array; + continue; + } + if (property.NameEquals("data")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricValue.DeserializeMetricValue(item)); + } + data = array; + continue; + } + } + return new TimeSeriesElement(Optional.ToList(metadatavalues), Optional.ToList(data)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesElement.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesElement.cs new file mode 100644 index 000000000000..0c7e343abe0f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesElement.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A time series result type. The discriminator value is always TimeSeries in this case. + public partial class TimeSeriesElement + { + /// Initializes a new instance of TimeSeriesElement. + internal TimeSeriesElement() + { + Metadatavalues = new ChangeTrackingList(); + Data = new ChangeTrackingList(); + } + + /// Initializes a new instance of TimeSeriesElement. + /// the metadata values returned if $filter was specified in the call. + /// An array of data points representing the metric values. This is only returned if a result type of data is specified. + internal TimeSeriesElement(IReadOnlyList metadatavalues, IReadOnlyList data) + { + Metadatavalues = metadatavalues; + Data = data; + } + + /// the metadata values returned if $filter was specified in the call. + public IReadOnlyList Metadatavalues { get; } + /// An array of data points representing the metric values. This is only returned if a result type of data is specified. + public IReadOnlyList Data { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesInformation.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesInformation.Serialization.cs new file mode 100644 index 000000000000..154e3b599d9f --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesInformation.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class TimeSeriesInformation : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("sensitivities"); + writer.WriteStartArray(); + foreach (var item in Sensitivities) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("values"); + writer.WriteStartArray(); + foreach (var item in Values) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(Timestamps)) + { + writer.WritePropertyName("timestamps"); + writer.WriteStartArray(); + foreach (var item in Timestamps) + { + writer.WriteStringValue(item, "O"); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesInformation.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesInformation.cs new file mode 100644 index 000000000000..c9f948abe2cb --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeSeriesInformation.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// The time series info needed for calculating the baseline. + public partial class TimeSeriesInformation + { + /// Initializes a new instance of TimeSeriesInformation. + /// the list of sensitivities for calculating the baseline. + /// The metric values to calculate the baseline. + /// or is null. + public TimeSeriesInformation(IEnumerable sensitivities, IEnumerable values) + { + if (sensitivities == null) + { + throw new ArgumentNullException(nameof(sensitivities)); + } + if (values == null) + { + throw new ArgumentNullException(nameof(values)); + } + + Sensitivities = sensitivities.ToList(); + Values = values.ToList(); + Timestamps = new ChangeTrackingList(); + } + + /// the list of sensitivities for calculating the baseline. + public IList Sensitivities { get; } + /// The metric values to calculate the baseline. + public IList Values { get; } + /// the array of timestamps of the baselines. + public IList Timestamps { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeWindow.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeWindow.Serialization.cs new file mode 100644 index 000000000000..610094f3e941 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeWindow.Serialization.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class TimeWindow : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(TimeZone)) + { + writer.WritePropertyName("timeZone"); + writer.WriteStringValue(TimeZone); + } + writer.WritePropertyName("start"); + writer.WriteStringValue(Start, "O"); + writer.WritePropertyName("end"); + writer.WriteStringValue(End, "O"); + writer.WriteEndObject(); + } + + internal static TimeWindow DeserializeTimeWindow(JsonElement element) + { + Optional timeZone = default; + DateTimeOffset start = default; + DateTimeOffset end = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeZone")) + { + timeZone = property.Value.GetString(); + continue; + } + if (property.NameEquals("start")) + { + start = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("end")) + { + end = property.Value.GetDateTimeOffset("O"); + continue; + } + } + return new TimeWindow(timeZone.Value, start, end); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeWindow.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeWindow.cs new file mode 100644 index 000000000000..8602e06f20f1 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TimeWindow.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A specific date-time for the profile. + public partial class TimeWindow + { + /// Initializes a new instance of TimeWindow. + /// the start time for the profile in ISO 8601 format. + /// the end time for the profile in ISO 8601 format. + public TimeWindow(DateTimeOffset start, DateTimeOffset end) + { + Start = start; + End = end; + } + + /// Initializes a new instance of TimeWindow. + /// the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. + /// the start time for the profile in ISO 8601 format. + /// the end time for the profile in ISO 8601 format. + internal TimeWindow(string timeZone, DateTimeOffset start, DateTimeOffset end) + { + TimeZone = timeZone; + Start = start; + End = end; + } + + /// the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. + public string TimeZone { get; set; } + /// the start time for the profile in ISO 8601 format. + public DateTimeOffset Start { get; set; } + /// the end time for the profile in ISO 8601 format. + public DateTimeOffset End { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TriggerCondition.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TriggerCondition.Serialization.cs new file mode 100644 index 000000000000..b08676b1047a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TriggerCondition.Serialization.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class TriggerCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("thresholdOperator"); + writer.WriteStringValue(ThresholdOperator.ToString()); + writer.WritePropertyName("threshold"); + writer.WriteNumberValue(Threshold); + if (Optional.IsDefined(MetricTrigger)) + { + writer.WritePropertyName("metricTrigger"); + writer.WriteObjectValue(MetricTrigger); + } + writer.WriteEndObject(); + } + + internal static TriggerCondition DeserializeTriggerCondition(JsonElement element) + { + ConditionalOperator thresholdOperator = default; + double threshold = default; + Optional metricTrigger = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("thresholdOperator")) + { + thresholdOperator = new ConditionalOperator(property.Value.GetString()); + continue; + } + if (property.NameEquals("threshold")) + { + threshold = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("metricTrigger")) + { + metricTrigger = LogMetricTrigger.DeserializeLogMetricTrigger(property.Value); + continue; + } + } + return new TriggerCondition(thresholdOperator, threshold, metricTrigger.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TriggerCondition.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TriggerCondition.cs new file mode 100644 index 000000000000..48ae70e8a4f4 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/TriggerCondition.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// The condition that results in the Log Search rule. + public partial class TriggerCondition + { + /// Initializes a new instance of TriggerCondition. + /// Evaluation operation for rule - 'GreaterThan' or 'LessThan. + /// Result or count threshold based on which rule should be triggered. + public TriggerCondition(ConditionalOperator thresholdOperator, double threshold) + { + ThresholdOperator = thresholdOperator; + Threshold = threshold; + } + + /// Initializes a new instance of TriggerCondition. + /// Evaluation operation for rule - 'GreaterThan' or 'LessThan. + /// Result or count threshold based on which rule should be triggered. + /// Trigger condition for metric query rule. + internal TriggerCondition(ConditionalOperator thresholdOperator, double threshold, LogMetricTrigger metricTrigger) + { + ThresholdOperator = thresholdOperator; + Threshold = threshold; + MetricTrigger = metricTrigger; + } + + /// Evaluation operation for rule - 'GreaterThan' or 'LessThan. + public ConditionalOperator ThresholdOperator { get; set; } + /// Result or count threshold based on which rule should be triggered. + public double Threshold { get; set; } + /// Trigger condition for metric query rule. + public LogMetricTrigger MetricTrigger { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Unit.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Unit.Serialization.cs new file mode 100644 index 000000000000..f0b77a9dd2e8 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Unit.Serialization.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + internal static class UnitExtensions + { + public static string ToSerialString(this Unit value) => value switch + { + Unit.Count => "Count", + Unit.Bytes => "Bytes", + Unit.Seconds => "Seconds", + Unit.CountPerSecond => "CountPerSecond", + Unit.BytesPerSecond => "BytesPerSecond", + Unit.Percent => "Percent", + Unit.MilliSeconds => "MilliSeconds", + Unit.ByteSeconds => "ByteSeconds", + Unit.Unspecified => "Unspecified", + Unit.Cores => "Cores", + Unit.MilliCores => "MilliCores", + Unit.NanoCores => "NanoCores", + Unit.BitsPerSecond => "BitsPerSecond", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown Unit value.") + }; + + public static Unit ToUnit(this string value) + { + if (string.Equals(value, "Count", StringComparison.InvariantCultureIgnoreCase)) return Unit.Count; + if (string.Equals(value, "Bytes", StringComparison.InvariantCultureIgnoreCase)) return Unit.Bytes; + if (string.Equals(value, "Seconds", StringComparison.InvariantCultureIgnoreCase)) return Unit.Seconds; + if (string.Equals(value, "CountPerSecond", StringComparison.InvariantCultureIgnoreCase)) return Unit.CountPerSecond; + if (string.Equals(value, "BytesPerSecond", StringComparison.InvariantCultureIgnoreCase)) return Unit.BytesPerSecond; + if (string.Equals(value, "Percent", StringComparison.InvariantCultureIgnoreCase)) return Unit.Percent; + if (string.Equals(value, "MilliSeconds", StringComparison.InvariantCultureIgnoreCase)) return Unit.MilliSeconds; + if (string.Equals(value, "ByteSeconds", StringComparison.InvariantCultureIgnoreCase)) return Unit.ByteSeconds; + if (string.Equals(value, "Unspecified", StringComparison.InvariantCultureIgnoreCase)) return Unit.Unspecified; + if (string.Equals(value, "Cores", StringComparison.InvariantCultureIgnoreCase)) return Unit.Cores; + if (string.Equals(value, "MilliCores", StringComparison.InvariantCultureIgnoreCase)) return Unit.MilliCores; + if (string.Equals(value, "NanoCores", StringComparison.InvariantCultureIgnoreCase)) return Unit.NanoCores; + if (string.Equals(value, "BitsPerSecond", StringComparison.InvariantCultureIgnoreCase)) return Unit.BitsPerSecond; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown Unit value."); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Unit.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Unit.cs new file mode 100644 index 000000000000..00305f9473de --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/Unit.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Insights.Models +{ + /// the unit of the metric. + public enum Unit + { + /// Count. + Count, + /// Bytes. + Bytes, + /// Seconds. + Seconds, + /// CountPerSecond. + CountPerSecond, + /// BytesPerSecond. + BytesPerSecond, + /// Percent. + Percent, + /// MilliSeconds. + MilliSeconds, + /// ByteSeconds. + ByteSeconds, + /// Unspecified. + Unspecified, + /// Cores. + Cores, + /// MilliCores. + MilliCores, + /// NanoCores. + NanoCores, + /// BitsPerSecond. + BitsPerSecond + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VMInsightsOnboardingStatus.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VMInsightsOnboardingStatus.Serialization.cs new file mode 100644 index 000000000000..a5fe386ef8c2 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VMInsightsOnboardingStatus.Serialization.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class VMInsightsOnboardingStatus + { + internal static VMInsightsOnboardingStatus DeserializeVMInsightsOnboardingStatus(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional type = default; + Optional resourceId = default; + Optional onboardingStatus = default; + Optional dataStatus = default; + Optional> data = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("resourceId")) + { + resourceId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("onboardingStatus")) + { + onboardingStatus = new OnboardingStatus(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("dataStatus")) + { + dataStatus = new DataStatus(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("data")) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(DataContainer.DeserializeDataContainer(item)); + } + data = array; + continue; + } + } + continue; + } + } + return new VMInsightsOnboardingStatus(id.Value, name.Value, type.Value, resourceId.Value, Optional.ToNullable(onboardingStatus), Optional.ToNullable(dataStatus), Optional.ToList(data)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VMInsightsOnboardingStatus.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VMInsightsOnboardingStatus.cs new file mode 100644 index 000000000000..286a2aec4353 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VMInsightsOnboardingStatus.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// VM Insights onboarding status for a resource. + public partial class VMInsightsOnboardingStatus : ProxyResource + { + /// Initializes a new instance of VMInsightsOnboardingStatus. + internal VMInsightsOnboardingStatus() + { + Data = new ChangeTrackingList(); + } + + /// Initializes a new instance of VMInsightsOnboardingStatus. + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + /// Azure Resource Manager identifier of the resource whose onboarding status is being represented. + /// The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. + /// The status of VM Insights data from the resource. When reported as `present` the data array will contain information about the data containers to which data for the specified resource is being routed. + /// Containers that currently store VM Insights data for the specified resource. + internal VMInsightsOnboardingStatus(string id, string name, string type, string resourceId, OnboardingStatus? onboardingStatus, DataStatus? dataStatus, IReadOnlyList data) : base(id, name, type) + { + ResourceId = resourceId; + OnboardingStatus = onboardingStatus; + DataStatus = dataStatus; + Data = data; + } + + /// Azure Resource Manager identifier of the resource whose onboarding status is being represented. + public string ResourceId { get; } + /// The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. + public OnboardingStatus? OnboardingStatus { get; } + /// The status of VM Insights data from the resource. When reported as `present` the data array will contain information about the data containers to which data for the specified resource is being routed. + public DataStatus? DataStatus { get; } + /// Containers that currently store VM Insights data for the specified resource. + public IReadOnlyList Data { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VoiceReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VoiceReceiver.Serialization.cs new file mode 100644 index 000000000000..0dc77407a09d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VoiceReceiver.Serialization.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class VoiceReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("countryCode"); + writer.WriteStringValue(CountryCode); + writer.WritePropertyName("phoneNumber"); + writer.WriteStringValue(PhoneNumber); + writer.WriteEndObject(); + } + + internal static VoiceReceiver DeserializeVoiceReceiver(JsonElement element) + { + string name = default; + string countryCode = default; + string phoneNumber = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("countryCode")) + { + countryCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("phoneNumber")) + { + phoneNumber = property.Value.GetString(); + continue; + } + } + return new VoiceReceiver(name, countryCode, phoneNumber); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VoiceReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VoiceReceiver.cs new file mode 100644 index 000000000000..14ff9e46e2dc --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/VoiceReceiver.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A voice receiver. + public partial class VoiceReceiver + { + /// Initializes a new instance of VoiceReceiver. + /// The name of the voice receiver. Names must be unique across all receivers within an action group. + /// The country code of the voice receiver. + /// The phone number of the voice receiver. + /// , , or is null. + public VoiceReceiver(string name, string countryCode, string phoneNumber) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (countryCode == null) + { + throw new ArgumentNullException(nameof(countryCode)); + } + if (phoneNumber == null) + { + throw new ArgumentNullException(nameof(phoneNumber)); + } + + Name = name; + CountryCode = countryCode; + PhoneNumber = phoneNumber; + } + + /// The name of the voice receiver. Names must be unique across all receivers within an action group. + public string Name { get; set; } + /// The country code of the voice receiver. + public string CountryCode { get; set; } + /// The phone number of the voice receiver. + public string PhoneNumber { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookNotification.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookNotification.Serialization.cs new file mode 100644 index 000000000000..bc001f22a089 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookNotification.Serialization.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class WebhookNotification : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ServiceUri)) + { + writer.WritePropertyName("serviceUri"); + writer.WriteStringValue(ServiceUri); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WriteEndObject(); + } + + internal static WebhookNotification DeserializeWebhookNotification(JsonElement element) + { + Optional serviceUri = default; + Optional> properties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("serviceUri")) + { + serviceUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + properties = dictionary; + continue; + } + } + return new WebhookNotification(serviceUri.Value, Optional.ToDictionary(properties)); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookNotification.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookNotification.cs new file mode 100644 index 000000000000..55c74cc773a9 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookNotification.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Webhook notification of an autoscale event. + public partial class WebhookNotification + { + /// Initializes a new instance of WebhookNotification. + public WebhookNotification() + { + Properties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of WebhookNotification. + /// the service address to receive the notification. + /// a property bag of settings. This value can be empty. + internal WebhookNotification(string serviceUri, IDictionary properties) + { + ServiceUri = serviceUri; + Properties = properties; + } + + /// the service address to receive the notification. + public string ServiceUri { get; set; } + /// a property bag of settings. This value can be empty. + public IDictionary Properties { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookReceiver.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookReceiver.Serialization.cs new file mode 100644 index 000000000000..57d5005f3856 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookReceiver.Serialization.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class WebhookReceiver : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + writer.WritePropertyName("serviceUri"); + writer.WriteStringValue(ServiceUri); + writer.WritePropertyName("useCommonAlertSchema"); + writer.WriteBooleanValue(UseCommonAlertSchema); + if (Optional.IsDefined(UseAadAuth)) + { + writer.WritePropertyName("useAadAuth"); + writer.WriteBooleanValue(UseAadAuth.Value); + } + if (Optional.IsDefined(ObjectId)) + { + writer.WritePropertyName("objectId"); + writer.WriteStringValue(ObjectId); + } + if (Optional.IsDefined(IdentifierUri)) + { + writer.WritePropertyName("identifierUri"); + writer.WriteStringValue(IdentifierUri); + } + if (Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"); + writer.WriteStringValue(TenantId); + } + writer.WriteEndObject(); + } + + internal static WebhookReceiver DeserializeWebhookReceiver(JsonElement element) + { + string name = default; + string serviceUri = default; + bool useCommonAlertSchema = default; + Optional useAadAuth = default; + Optional objectId = default; + Optional identifierUri = default; + Optional tenantId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("serviceUri")) + { + serviceUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("useCommonAlertSchema")) + { + useCommonAlertSchema = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("useAadAuth")) + { + useAadAuth = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("objectId")) + { + objectId = property.Value.GetString(); + continue; + } + if (property.NameEquals("identifierUri")) + { + identifierUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("tenantId")) + { + tenantId = property.Value.GetString(); + continue; + } + } + return new WebhookReceiver(name, serviceUri, useCommonAlertSchema, Optional.ToNullable(useAadAuth), objectId.Value, identifierUri.Value, tenantId.Value); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookReceiver.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookReceiver.cs new file mode 100644 index 000000000000..8bfe54de83a3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebhookReceiver.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// A webhook receiver. + public partial class WebhookReceiver + { + /// Initializes a new instance of WebhookReceiver. + /// The name of the webhook receiver. Names must be unique across all receivers within an action group. + /// The URI where webhooks should be sent. + /// Indicates whether to use common alert schema. + /// or is null. + public WebhookReceiver(string name, string serviceUri, bool useCommonAlertSchema) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (serviceUri == null) + { + throw new ArgumentNullException(nameof(serviceUri)); + } + + Name = name; + ServiceUri = serviceUri; + UseCommonAlertSchema = useCommonAlertSchema; + } + + /// Initializes a new instance of WebhookReceiver. + /// The name of the webhook receiver. Names must be unique across all receivers within an action group. + /// The URI where webhooks should be sent. + /// Indicates whether to use common alert schema. + /// Indicates whether or not use AAD authentication. + /// Indicates the webhook app object Id for aad auth. + /// Indicates the identifier uri for aad auth. + /// Indicates the tenant id for aad auth. + internal WebhookReceiver(string name, string serviceUri, bool useCommonAlertSchema, bool? useAadAuth, string objectId, string identifierUri, string tenantId) + { + Name = name; + ServiceUri = serviceUri; + UseCommonAlertSchema = useCommonAlertSchema; + UseAadAuth = useAadAuth; + ObjectId = objectId; + IdentifierUri = identifierUri; + TenantId = tenantId; + } + + /// The name of the webhook receiver. Names must be unique across all receivers within an action group. + public string Name { get; set; } + /// The URI where webhooks should be sent. + public string ServiceUri { get; set; } + /// Indicates whether to use common alert schema. + public bool UseCommonAlertSchema { get; set; } + /// Indicates whether or not use AAD authentication. + public bool? UseAadAuth { get; set; } + /// Indicates the webhook app object Id for aad auth. + public string ObjectId { get; set; } + /// Indicates the identifier uri for aad auth. + public string IdentifierUri { get; set; } + /// Indicates the tenant id for aad auth. + public string TenantId { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebtestLocationAvailabilityCriteria.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebtestLocationAvailabilityCriteria.Serialization.cs new file mode 100644 index 000000000000..9eb0daf5657a --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebtestLocationAvailabilityCriteria.Serialization.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class WebtestLocationAvailabilityCriteria : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("webTestId"); + writer.WriteStringValue(WebTestId); + writer.WritePropertyName("componentId"); + writer.WriteStringValue(ComponentId); + writer.WritePropertyName("failedLocationCount"); + writer.WriteNumberValue(FailedLocationCount); + writer.WritePropertyName("odata.type"); + writer.WriteStringValue(OdataType.ToString()); + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value); + } + writer.WriteEndObject(); + } + + internal static WebtestLocationAvailabilityCriteria DeserializeWebtestLocationAvailabilityCriteria(JsonElement element) + { + string webTestId = default; + string componentId = default; + float failedLocationCount = default; + Odatatype odataType = default; + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("webTestId")) + { + webTestId = property.Value.GetString(); + continue; + } + if (property.NameEquals("componentId")) + { + componentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("failedLocationCount")) + { + failedLocationCount = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("odata.type")) + { + odataType = new Odatatype(property.Value.GetString()); + continue; + } + additionalPropertiesDictionary ??= new Dictionary(); + additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); + } + additionalProperties = additionalPropertiesDictionary; + return new WebtestLocationAvailabilityCriteria(odataType, additionalProperties, webTestId, componentId, failedLocationCount); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebtestLocationAvailabilityCriteria.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebtestLocationAvailabilityCriteria.cs new file mode 100644 index 000000000000..aa53dcc6671d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WebtestLocationAvailabilityCriteria.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Specifies the metric alert rule criteria for a web test resource. + public partial class WebtestLocationAvailabilityCriteria : MetricAlertCriteria + { + /// Initializes a new instance of WebtestLocationAvailabilityCriteria. + /// The Application Insights web test Id. + /// The Application Insights resource Id. + /// The number of failed locations. + /// or is null. + public WebtestLocationAvailabilityCriteria(string webTestId, string componentId, float failedLocationCount) + { + if (webTestId == null) + { + throw new ArgumentNullException(nameof(webTestId)); + } + if (componentId == null) + { + throw new ArgumentNullException(nameof(componentId)); + } + + WebTestId = webTestId; + ComponentId = componentId; + FailedLocationCount = failedLocationCount; + OdataType = Odatatype.MicrosoftAzureMonitorWebtestLocationAvailabilityCriteria; + } + + /// Initializes a new instance of WebtestLocationAvailabilityCriteria. + /// specifies the type of the alert criteria. + /// . + /// The Application Insights web test Id. + /// The Application Insights resource Id. + /// The number of failed locations. + internal WebtestLocationAvailabilityCriteria(Odatatype odataType, IDictionary additionalProperties, string webTestId, string componentId, float failedLocationCount) : base(odataType, additionalProperties) + { + WebTestId = webTestId; + ComponentId = componentId; + FailedLocationCount = failedLocationCount; + OdataType = odataType; + } + + /// The Application Insights web test Id. + public string WebTestId { get; set; } + /// The Application Insights resource Id. + public string ComponentId { get; set; } + /// The number of failed locations. + public float FailedLocationCount { get; set; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WorkspaceInfo.Serialization.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WorkspaceInfo.Serialization.cs new file mode 100644 index 000000000000..b2bf052b9aed --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WorkspaceInfo.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Insights.Models +{ + public partial class WorkspaceInfo + { + internal static WorkspaceInfo DeserializeWorkspaceInfo(JsonElement element) + { + string id = default; + string location = default; + string customerId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("location")) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("customerId")) + { + customerId = property0.Value.GetString(); + continue; + } + } + continue; + } + } + return new WorkspaceInfo(id, location, customerId); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WorkspaceInfo.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WorkspaceInfo.cs new file mode 100644 index 000000000000..fb2312be24af --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Models/WorkspaceInfo.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Insights.Models +{ + /// Information about a Log Analytics Workspace. + public partial class WorkspaceInfo + { + /// Initializes a new instance of WorkspaceInfo. + /// Azure Resource Manager identifier of the Log Analytics Workspace. + /// Location of the Log Analytics workspace. + /// Log Analytics workspace identifier. + /// , , or is null. + internal WorkspaceInfo(string id, string location, string customerId) + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + if (location == null) + { + throw new ArgumentNullException(nameof(location)); + } + if (customerId == null) + { + throw new ArgumentNullException(nameof(customerId)); + } + + Id = id; + Location = location; + CustomerId = customerId; + } + + /// Azure Resource Manager identifier of the Log Analytics Workspace. + public string Id { get; } + /// Location of the Log Analytics workspace. + public string Location { get; } + /// Log Analytics workspace identifier. + public string CustomerId { get; } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Operations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Operations.cs new file mode 100644 index 000000000000..be7bed34f6d7 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/Operations.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The service client. + public partial class Operations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal RestOperations RestClient { get; } + /// Initializes a new instance of Operations for mocking. + protected Operations() + { + } + /// Initializes a new instance of Operations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal Operations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new RestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Lists all of the available operations from Microsoft.Insights provider. + /// The cancellation token to use. + public virtual async Task> ListAsync(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("Operations.List"); + scope.Start(); + try + { + return await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists all of the available operations from Microsoft.Insights provider. + /// The cancellation token to use. + public virtual Response List(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("Operations.List"); + scope.Start(); + try + { + return RestClient.List(cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/RestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/RestOperations.cs new file mode 100644 index 000000000000..a0c89fcdf8f7 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/RestOperations.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class RestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of RestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public RestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/providers/microsoft.insights/operations", false); + uri.AppendQuery("api-version", "2015-04-01", true); + request.Uri = uri; + return message; + } + + /// Lists all of the available operations from Microsoft.Insights provider. + /// The cancellation token to use. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Lists all of the available operations from Microsoft.Insights provider. + /// The cancellation token to use. + public Response List(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ScheduledQueryRulesOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ScheduledQueryRulesOperations.cs new file mode 100644 index 000000000000..0a63ad5ac399 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ScheduledQueryRulesOperations.cs @@ -0,0 +1,302 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The ScheduledQueryRules service client. + public partial class ScheduledQueryRulesOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal ScheduledQueryRulesRestOperations RestClient { get; } + /// Initializes a new instance of ScheduledQueryRulesOperations for mocking. + protected ScheduledQueryRulesOperations() + { + } + /// Initializes a new instance of ScheduledQueryRulesOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + internal ScheduledQueryRulesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + RestClient = new ScheduledQueryRulesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Creates or updates an log search rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateAsync(string resourceGroupName, string ruleName, LogSearchRuleResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.CreateOrUpdate"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateAsync(resourceGroupName, ruleName, parameters, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates or updates an log search rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + public virtual Response CreateOrUpdate(string resourceGroupName, string ruleName, LogSearchRuleResource parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.CreateOrUpdate"); + scope.Start(); + try + { + return RestClient.CreateOrUpdate(resourceGroupName, ruleName, parameters, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets an Log Search rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual async Task> GetAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(resourceGroupName, ruleName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets an Log Search rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual Response Get(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.Get"); + scope.Start(); + try + { + return RestClient.Get(resourceGroupName, ruleName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Update log search Rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to update. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(string resourceGroupName, string ruleName, LogSearchRuleResourcePatch parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.Update"); + scope.Start(); + try + { + return await RestClient.UpdateAsync(resourceGroupName, ruleName, parameters, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Update log search Rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to update. + /// The cancellation token to use. + public virtual Response Update(string resourceGroupName, string ruleName, LogSearchRuleResourcePatch parameters, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.Update"); + scope.Start(); + try + { + return RestClient.Update(resourceGroupName, ruleName, parameters, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a Log Search rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual async Task DeleteAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.Delete"); + scope.Start(); + try + { + return await RestClient.DeleteAsync(resourceGroupName, ruleName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a Log Search rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + public virtual Response Delete(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.Delete"); + scope.Start(); + try + { + return RestClient.Delete(resourceGroupName, ruleName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the Log Search rules within a subscription group. + /// The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + /// The cancellation token to use. + public virtual AsyncPageable ListBySubscriptionAsync(string filter = null, CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.ListBySubscription"); + scope.Start(); + try + { + var response = await RestClient.ListBySubscriptionAsync(filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// List the Log Search rules within a subscription group. + /// The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + /// The cancellation token to use. + public virtual Pageable ListBySubscription(string filter = null, CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.ListBySubscription"); + scope.Start(); + try + { + var response = RestClient.ListBySubscription(filter, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + + /// List the Log Search rules within a resource group. + /// The name of the resource group. + /// The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListByResourceGroupAsync(string resourceGroupName, string filter = null, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); + } + + /// List the Log Search rules within a resource group. + /// The name of the resource group. + /// The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + /// The cancellation token to use. + /// is null. + public virtual Pageable ListByResourceGroup(string resourceGroupName, string filter = null, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ScheduledQueryRulesOperations.ListByResourceGroup"); + scope.Start(); + try + { + var response = RestClient.ListByResourceGroup(resourceGroupName, filter, cancellationToken); + return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, null); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ScheduledQueryRulesRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ScheduledQueryRulesRestOperations.cs new file mode 100644 index 000000000000..4d0d8cf4d9f3 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/ScheduledQueryRulesRestOperations.cs @@ -0,0 +1,534 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class ScheduledQueryRulesRestOperations + { + private string subscriptionId; + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of ScheduledQueryRulesRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The Azure subscription Id. + /// server parameter. + /// is null. + public ScheduledQueryRulesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + endpoint ??= new Uri("https://management.azure.com"); + + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string ruleName, LogSearchRuleResource parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/scheduledQueryRules/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2018-04-16", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + return message; + } + + /// Creates or updates an log search rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + /// , , or is null. + public async Task> CreateOrUpdateAsync(string resourceGroupName, string ruleName, LogSearchRuleResource parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, ruleName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + LogSearchRuleResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogSearchRuleResource.DeserializeLogSearchRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Creates or updates an log search rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to create or update. + /// The cancellation token to use. + /// , , or is null. + public Response CreateOrUpdate(string resourceGroupName, string ruleName, LogSearchRuleResource parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(resourceGroupName, ruleName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + LogSearchRuleResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogSearchRuleResource.DeserializeLogSearchRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string resourceGroupName, string ruleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/scheduledQueryRules/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2018-04-16", true); + request.Uri = uri; + return message; + } + + /// Gets an Log Search rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public async Task> GetAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateGetRequest(resourceGroupName, ruleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogSearchRuleResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogSearchRuleResource.DeserializeLogSearchRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets an Log Search rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public Response Get(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateGetRequest(resourceGroupName, ruleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogSearchRuleResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogSearchRuleResource.DeserializeLogSearchRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string resourceGroupName, string ruleName, LogSearchRuleResourcePatch parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/scheduledQueryRules/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2018-04-16", true); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + return message; + } + + /// Update log search Rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to update. + /// The cancellation token to use. + /// , , or is null. + public async Task> UpdateAsync(string resourceGroupName, string ruleName, LogSearchRuleResourcePatch parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateUpdateRequest(resourceGroupName, ruleName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogSearchRuleResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogSearchRuleResource.DeserializeLogSearchRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Update log search Rule. + /// The name of the resource group. + /// The name of the rule. + /// The parameters of the rule to update. + /// The cancellation token to use. + /// , , or is null. + public Response Update(string resourceGroupName, string ruleName, LogSearchRuleResourcePatch parameters, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateUpdateRequest(resourceGroupName, ruleName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogSearchRuleResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogSearchRuleResource.DeserializeLogSearchRuleResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string resourceGroupName, string ruleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/scheduledQueryRules/", false); + uri.AppendPath(ruleName, true); + uri.AppendQuery("api-version", "2018-04-16", true); + request.Uri = uri; + return message; + } + + /// Deletes a Log Search rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public async Task DeleteAsync(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, ruleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Deletes a Log Search rule. + /// The name of the resource group. + /// The name of the rule. + /// The cancellation token to use. + /// or is null. + public Response Delete(string resourceGroupName, string ruleName, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (ruleName == null) + { + throw new ArgumentNullException(nameof(ruleName)); + } + + using var message = CreateDeleteRequest(resourceGroupName, ruleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionRequest(string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/microsoft.insights/scheduledQueryRules", false); + uri.AppendQuery("api-version", "2018-04-16", true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + request.Uri = uri; + return message; + } + + /// List the Log Search rules within a subscription group. + /// The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + /// The cancellation token to use. + public async Task> ListBySubscriptionAsync(string filter = null, CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionRequest(filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogSearchRuleResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogSearchRuleResourceCollection.DeserializeLogSearchRuleResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// List the Log Search rules within a subscription group. + /// The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + /// The cancellation token to use. + public Response ListBySubscription(string filter = null, CancellationToken cancellationToken = default) + { + using var message = CreateListBySubscriptionRequest(filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogSearchRuleResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogSearchRuleResourceCollection.DeserializeLogSearchRuleResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourcegroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/microsoft.insights/scheduledQueryRules", false); + uri.AppendQuery("api-version", "2018-04-16", true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + request.Uri = uri; + return message; + } + + /// List the Log Search rules within a resource group. + /// The name of the resource group. + /// The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + /// The cancellation token to use. + /// is null. + public async Task> ListByResourceGroupAsync(string resourceGroupName, string filter = null, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogSearchRuleResourceCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogSearchRuleResourceCollection.DeserializeLogSearchRuleResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// List the Log Search rules within a resource group. + /// The name of the resource group. + /// The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + /// The cancellation token to use. + /// is null. + public Response ListByResourceGroup(string resourceGroupName, string filter = null, CancellationToken cancellationToken = default) + { + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + + using var message = CreateListByResourceGroupRequest(resourceGroupName, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogSearchRuleResourceCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogSearchRuleResourceCollection.DeserializeLogSearchRuleResourceCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/TenantActivityLogsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/TenantActivityLogsOperations.cs new file mode 100644 index 000000000000..a6effdbe8464 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/TenantActivityLogsOperations.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The TenantActivityLogs service client. + public partial class TenantActivityLogsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal TenantActivityLogsRestOperations RestClient { get; } + /// Initializes a new instance of TenantActivityLogsOperations for mocking. + protected TenantActivityLogsOperations() + { + } + /// Initializes a new instance of TenantActivityLogsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal TenantActivityLogsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new TenantActivityLogsRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Gets the Activity Logs for the Tenant.<br>Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).<br>One thing to point out here is that this API does *not* retrieve the logs at the individual subscription of the tenant but only surfaces the logs that were generated at the tenant level. + /// Reduces the set of data collected. <br>The **$filter** is very restricted and allows only the following patterns.<br>- List events for a resource group: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- List events for resource: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceUri eq '<ResourceURI>'.<br>- List events for a subscription: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation'.<br>- List events for a resource provider: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceProvider eq '<ResourceProviderName>'.<br>- List events for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq '<CorrelationID>'.<br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + public virtual AsyncPageable ListAsync(string filter = null, string select = null, CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("TenantActivityLogsOperations.List"); + scope.Start(); + try + { + var response = await RestClient.ListAsync(filter, select, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("TenantActivityLogsOperations.List"); + scope.Start(); + try + { + var response = await RestClient.ListNextPageAsync(nextLink, filter, select, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets the Activity Logs for the Tenant.<br>Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).<br>One thing to point out here is that this API does *not* retrieve the logs at the individual subscription of the tenant but only surfaces the logs that were generated at the tenant level. + /// Reduces the set of data collected. <br>The **$filter** is very restricted and allows only the following patterns.<br>- List events for a resource group: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- List events for resource: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceUri eq '<ResourceURI>'.<br>- List events for a subscription: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation'.<br>- List events for a resource provider: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceProvider eq '<ResourceProviderName>'.<br>- List events for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq '<CorrelationID>'.<br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + public virtual Pageable List(string filter = null, string select = null, CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("TenantActivityLogsOperations.List"); + scope.Start(); + try + { + var response = RestClient.List(filter, select, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("TenantActivityLogsOperations.List"); + scope.Start(); + try + { + var response = RestClient.ListNextPage(nextLink, filter, select, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/TenantActivityLogsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/TenantActivityLogsRestOperations.cs new file mode 100644 index 000000000000..b16fc0fb24bf --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/TenantActivityLogsRestOperations.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class TenantActivityLogsRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of TenantActivityLogsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public TenantActivityLogsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListRequest(string filter, string select) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/providers/microsoft.insights/eventtypes/management/values", false); + uri.AppendQuery("api-version", "2015-04-01", true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + request.Uri = uri; + return message; + } + + /// Gets the Activity Logs for the Tenant.<br>Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).<br>One thing to point out here is that this API does *not* retrieve the logs at the individual subscription of the tenant but only surfaces the logs that were generated at the tenant level. + /// Reduces the set of data collected. <br>The **$filter** is very restricted and allows only the following patterns.<br>- List events for a resource group: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- List events for resource: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceUri eq '<ResourceURI>'.<br>- List events for a subscription: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation'.<br>- List events for a resource provider: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceProvider eq '<ResourceProviderName>'.<br>- List events for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq '<CorrelationID>'.<br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + public async Task> ListAsync(string filter = null, string select = null, CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(filter, select); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EventDataCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EventDataCollection.DeserializeEventDataCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the Activity Logs for the Tenant.<br>Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).<br>One thing to point out here is that this API does *not* retrieve the logs at the individual subscription of the tenant but only surfaces the logs that were generated at the tenant level. + /// Reduces the set of data collected. <br>The **$filter** is very restricted and allows only the following patterns.<br>- List events for a resource group: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- List events for resource: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceUri eq '<ResourceURI>'.<br>- List events for a subscription: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation'.<br>- List events for a resource provider: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceProvider eq '<ResourceProviderName>'.<br>- List events for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq '<CorrelationID>'.<br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + public Response List(string filter = null, string select = null, CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(filter, select); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EventDataCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EventDataCollection.DeserializeEventDataCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string filter, string select) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + return message; + } + + /// Gets the Activity Logs for the Tenant.<br>Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).<br>One thing to point out here is that this API does *not* retrieve the logs at the individual subscription of the tenant but only surfaces the logs that were generated at the tenant level. + /// The URL to the next page of results. + /// Reduces the set of data collected. <br>The **$filter** is very restricted and allows only the following patterns.<br>- List events for a resource group: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- List events for resource: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceUri eq '<ResourceURI>'.<br>- List events for a subscription: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation'.<br>- List events for a resource provider: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceProvider eq '<ResourceProviderName>'.<br>- List events for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq '<CorrelationID>'.<br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + /// is null. + public async Task> ListNextPageAsync(string nextLink, string filter = null, string select = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListNextPageRequest(nextLink, filter, select); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EventDataCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EventDataCollection.DeserializeEventDataCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the Activity Logs for the Tenant.<br>Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).<br>One thing to point out here is that this API does *not* retrieve the logs at the individual subscription of the tenant but only surfaces the logs that were generated at the tenant level. + /// The URL to the next page of results. + /// Reduces the set of data collected. <br>The **$filter** is very restricted and allows only the following patterns.<br>- List events for a resource group: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- List events for resource: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceUri eq '<ResourceURI>'.<br>- List events for a subscription: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation'.<br>- List events for a resource provider: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceProvider eq '<ResourceProviderName>'.<br>- List events for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq '<CorrelationID>'.<br>**NOTE**: No other syntax is allowed. + /// Used to fetch events with only the given properties.<br>The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, *subStatus*, *subscriptionId*. + /// The cancellation token to use. + /// is null. + public Response ListNextPage(string nextLink, string filter = null, string select = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListNextPageRequest(nextLink, filter, select); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EventDataCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EventDataCollection.DeserializeEventDataCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/VMInsightsOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/VMInsightsOperations.cs new file mode 100644 index 000000000000..76781dc110ba --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/VMInsightsOperations.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + /// The VMInsights service client. + public partial class VMInsightsOperations + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal VMInsightsRestOperations RestClient { get; } + /// Initializes a new instance of VMInsightsOperations for mocking. + protected VMInsightsOperations() + { + } + /// Initializes a new instance of VMInsightsOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + internal VMInsightsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + RestClient = new VMInsightsRestOperations(clientDiagnostics, pipeline, endpoint); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Retrieves the VM Insights onboarding status for the specified resource or resource scope. + /// The fully qualified Azure Resource manager identifier of the resource, or scope, whose status to retrieve. + /// The cancellation token to use. + public virtual async Task> GetOnboardingStatusAsync(string resourceUri, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("VMInsightsOperations.GetOnboardingStatus"); + scope.Start(); + try + { + return await RestClient.GetOnboardingStatusAsync(resourceUri, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves the VM Insights onboarding status for the specified resource or resource scope. + /// The fully qualified Azure Resource manager identifier of the resource, or scope, whose status to retrieve. + /// The cancellation token to use. + public virtual Response GetOnboardingStatus(string resourceUri, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("VMInsightsOperations.GetOnboardingStatus"); + scope.Start(); + try + { + return RestClient.GetOnboardingStatus(resourceUri, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Generated/VMInsightsRestOperations.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/VMInsightsRestOperations.cs new file mode 100644 index 000000000000..52568415625e --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Generated/VMInsightsRestOperations.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Insights.Models; + +namespace Azure.ResourceManager.Insights +{ + internal partial class VMInsightsRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of VMInsightsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// server parameter. + public VMInsightsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) + { + endpoint ??= new Uri("https://management.azure.com"); + + this.endpoint = endpoint; + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateGetOnboardingStatusRequest(string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default", false); + uri.AppendQuery("api-version", "2018-11-27-preview", true); + request.Uri = uri; + return message; + } + + /// Retrieves the VM Insights onboarding status for the specified resource or resource scope. + /// The fully qualified Azure Resource manager identifier of the resource, or scope, whose status to retrieve. + /// The cancellation token to use. + /// is null. + public async Task> GetOnboardingStatusAsync(string resourceUri, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateGetOnboardingStatusRequest(resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + VMInsightsOnboardingStatus value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = VMInsightsOnboardingStatus.DeserializeVMInsightsOnboardingStatus(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Retrieves the VM Insights onboarding status for the specified resource or resource scope. + /// The fully qualified Azure Resource manager identifier of the resource, or scope, whose status to retrieve. + /// The cancellation token to use. + /// is null. + public Response GetOnboardingStatus(string resourceUri, CancellationToken cancellationToken = default) + { + if (resourceUri == null) + { + throw new ArgumentNullException(nameof(resourceUri)); + } + + using var message = CreateGetOnboardingStatusRequest(resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + VMInsightsOnboardingStatus value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = VMInsightsOnboardingStatus.DeserializeVMInsightsOnboardingStatus(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/Properties/AssemblyInfo.cs b/sdk/insights/Azure.ResourceManager.Insights/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..5ec953b79f4c --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/Properties/AssemblyInfo.cs @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Insights")] + +[assembly: InternalsVisibleTo("Azure.ResourceManager.Insights.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/insights/Azure.ResourceManager.Insights/src/autorest.md b/sdk/insights/Azure.ResourceManager.Insights/src/autorest.md new file mode 100644 index 000000000000..f49de0cdb39d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/src/autorest.md @@ -0,0 +1,11 @@ +# Generated code configuration + +Run `dotnet msbuild /t:GenerateCode` to generate code. + +``` yaml + +azure-arm: true +require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/861e6b8288b22ad3505a58f62c23e3209cbc5a35/specification/monitor/resource-manager/readme.md + + +``` \ No newline at end of file diff --git a/sdk/insights/Azure.ResourceManager.Insights/tests/Azure.ResourceManager.Insights.Tests.csproj b/sdk/insights/Azure.ResourceManager.Insights/tests/Azure.ResourceManager.Insights.Tests.csproj new file mode 100644 index 000000000000..0e34c6bb646d --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/tests/Azure.ResourceManager.Insights.Tests.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/insights/Azure.ResourceManager.Insights/tests/InsightsManagementTestEnvironment.cs b/sdk/insights/Azure.ResourceManager.Insights/tests/InsightsManagementTestEnvironment.cs new file mode 100644 index 000000000000..a26b32702067 --- /dev/null +++ b/sdk/insights/Azure.ResourceManager.Insights/tests/InsightsManagementTestEnvironment.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Insights.Tests +{ + public class InsightsManagementTestEnvironment : TestEnvironment + { + public InsightsManagementTestEnvironment() : base("insightsmgmt") + { + } + } +} \ No newline at end of file diff --git a/sdk/insights/ci.yml b/sdk/insights/ci.yml new file mode 100644 index 000000000000..1cfc0486e073 --- /dev/null +++ b/sdk/insights/ci.yml @@ -0,0 +1,32 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - master + - hotfix/* + - release/* + paths: + include: + - sdk/insights/ + +pr: + branches: + include: + - master + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/insights/ + +stages: +- template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: insights + ArtifactName: packages + Artifacts: + - name: Azure.Management.Template + safeName: AzureResourceManagerInsights diff --git a/sdk/insights/test-resources.json b/sdk/insights/test-resources.json new file mode 100644 index 000000000000..a837d5a0f2b8 --- /dev/null +++ b/sdk/insights/test-resources.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + ] +}