diff --git a/eng/mgmt/mgmtmetadata/datadog_resource-manager.txt b/eng/mgmt/mgmtmetadata/datadog_resource-manager.txt new file mode 100644 index 0000000000000..257f0550fb77a --- /dev/null +++ b/eng/mgmt/mgmtmetadata/datadog_resource-manager.txt @@ -0,0 +1,14 @@ +Installing AutoRest version: v2 +AutoRest installed successfully. +Commencing code generation +Generating CSharp code +Executing AutoRest command +cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/datadog/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=C:\work\azure-sdk-for-net\sdk +2020-10-09 01:08:52 UTC +Azure-rest-api-specs repository information +GitHub fork: Azure +Branch: master +Commit: 183db615e7e870d12668972c874897f095fe256c +AutoRest information +Requested version: v2 +Bootstrapper version: autorest@2.0.4413 diff --git a/eng/pipelines/mgmt.yml b/eng/pipelines/mgmt.yml index 33e4a415a57eb..e2fdbdf5ec4af 100644 --- a/eng/pipelines/mgmt.yml +++ b/eng/pipelines/mgmt.yml @@ -49,6 +49,7 @@ pr: - sdk/customproviders/Microsoft.Azure.Management.CustomProviders - sdk/databox/Microsoft.Azure.Management.DataBox - sdk/databoxedge/Microsoft.Azure.Management.DataBoxEdge + - sdk/datadog/Microsoft.Azure.Management.Datadog - sdk/datafactory/Microsoft.Azure.Management.DataFactory - sdk/datalake-analytics/Microsoft.Azure.Management.DataLake.Analytics - sdk/datalake-store/Microsoft.Azure.Management.DataLake.Store diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/AzSdk.RP.props b/sdk/datadog/Microsoft.Azure.Management.Datadog/AzSdk.RP.props new file mode 100644 index 0000000000000..e76727bfc708c --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/AzSdk.RP.props @@ -0,0 +1,7 @@ + + + + Datadog_2020-02-01-preview; + $(PackageTags);$(CommonTags);$(AzureApiTag); + + \ No newline at end of file diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/Microsoft.Azure.Management.Datadog.sln b/sdk/datadog/Microsoft.Azure.Management.Datadog/Microsoft.Azure.Management.Datadog.sln new file mode 100644 index 0000000000000..04caeaddb6401 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/Microsoft.Azure.Management.Datadog.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.Datadog.Tests", "tests\Microsoft.Azure.Management.Datadog.Tests.csproj", "{CCDAE481-FF4A-4018-88EF-C3FE4AEB4C8B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.Datadog", "src\Microsoft.Azure.Management.Datadog.csproj", "{18EFDFC3-523F-4AA2-BD40-21CB366C83EF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CCDAE481-FF4A-4018-88EF-C3FE4AEB4C8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CCDAE481-FF4A-4018-88EF-C3FE4AEB4C8B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CCDAE481-FF4A-4018-88EF-C3FE4AEB4C8B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CCDAE481-FF4A-4018-88EF-C3FE4AEB4C8B}.Release|Any CPU.Build.0 = Release|Any CPU + {18EFDFC3-523F-4AA2-BD40-21CB366C83EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18EFDFC3-523F-4AA2-BD40-21CB366C83EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18EFDFC3-523F-4AA2-BD40-21CB366C83EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18EFDFC3-523F-4AA2-BD40-21CB366C83EF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ApiKeysOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ApiKeysOperations.cs new file mode 100644 index 0000000000000..769079fd90606 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ApiKeysOperations.cs @@ -0,0 +1,808 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ApiKeysOperations operations. + /// + internal partial class ApiKeysOperations : IServiceOperations, IApiKeysOperations + { + /// + /// Initializes a new instance of the ApiKeysOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ApiKeysOperations(MicrosoftDatadogClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MicrosoftDatadogClient + /// + public MicrosoftDatadogClient Client { get; private set; } + + /// + /// List the api keys for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listApiKeys").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the default api key. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetDefaultKeyWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetDefaultKey", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/getDefaultKey").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Set the default api key. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task SetDefaultKeyWithHttpMessagesAsync(string resourceGroupName, string monitorName, DatadogApiKey body = default(DatadogApiKey), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (body != null) + { + body.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "SetDefaultKey", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/setDefaultKey").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the api keys for a given monitor resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ApiKeysOperationsExtensions.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ApiKeysOperationsExtensions.cs new file mode 100644 index 0000000000000..81015b2c1588c --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ApiKeysOperationsExtensions.cs @@ -0,0 +1,180 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ApiKeysOperations. + /// + public static partial class ApiKeysOperationsExtensions + { + /// + /// List the api keys for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static IPage List(this IApiKeysOperations operations, string resourceGroupName, string monitorName) + { + return operations.ListAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// List the api keys for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IApiKeysOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the default api key. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static DatadogApiKey GetDefaultKey(this IApiKeysOperations operations, string resourceGroupName, string monitorName) + { + return operations.GetDefaultKeyAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// Get the default api key. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task GetDefaultKeyAsync(this IApiKeysOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetDefaultKeyWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Set the default api key. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + public static void SetDefaultKey(this IApiKeysOperations operations, string resourceGroupName, string monitorName, DatadogApiKey body = default(DatadogApiKey)) + { + operations.SetDefaultKeyAsync(resourceGroupName, monitorName, body).GetAwaiter().GetResult(); + } + + /// + /// Set the default api key. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task SetDefaultKeyAsync(this IApiKeysOperations operations, string resourceGroupName, string monitorName, DatadogApiKey body = default(DatadogApiKey), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.SetDefaultKeyWithHttpMessagesAsync(resourceGroupName, monitorName, body, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List the api keys for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IApiKeysOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List the api keys for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IApiKeysOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/HostsOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/HostsOperations.cs new file mode 100644 index 0000000000000..ed1219877a563 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/HostsOperations.cs @@ -0,0 +1,420 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// HostsOperations operations. + /// + internal partial class HostsOperations : IServiceOperations, IHostsOperations + { + /// + /// Initializes a new instance of the HostsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal HostsOperations(MicrosoftDatadogClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MicrosoftDatadogClient + /// + public MicrosoftDatadogClient Client { get; private set; } + + /// + /// List the hosts for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listHosts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the hosts for a given monitor resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/HostsOperationsExtensions.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/HostsOperationsExtensions.cs new file mode 100644 index 0000000000000..44029db154e8a --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/HostsOperationsExtensions.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for HostsOperations. + /// + public static partial class HostsOperationsExtensions + { + /// + /// List the hosts for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static IPage List(this IHostsOperations operations, string resourceGroupName, string monitorName) + { + return operations.ListAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// List the hosts for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IHostsOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List the hosts for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IHostsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List the hosts for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IHostsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IApiKeysOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IApiKeysOperations.cs new file mode 100644 index 0000000000000..f41c56a87efe0 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IApiKeysOperations.cs @@ -0,0 +1,126 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ApiKeysOperations operations. + /// + public partial interface IApiKeysOperations + { + /// + /// List the api keys for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the default api key. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetDefaultKeyWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Set the default api key. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task SetDefaultKeyWithHttpMessagesAsync(string resourceGroupName, string monitorName, DatadogApiKey body = default(DatadogApiKey), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the api keys for a given monitor resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IHostsOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IHostsOperations.cs new file mode 100644 index 0000000000000..c715ef29b2e45 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IHostsOperations.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// HostsOperations operations. + /// + public partial interface IHostsOperations + { + /// + /// List the hosts for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the hosts for a given monitor resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ILinkedResourcesOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ILinkedResourcesOperations.cs new file mode 100644 index 0000000000000..4db15d26a5c1c --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ILinkedResourcesOperations.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LinkedResourcesOperations operations. + /// + public partial interface ILinkedResourcesOperations + { + /// + /// List all Azure resources associated to the same Datadog + /// organization as the target resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all Azure resources associated to the same Datadog + /// organization as the target resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IMicrosoftDatadogClient.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IMicrosoftDatadogClient.cs new file mode 100644 index 0000000000000..c545fa3335702 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IMicrosoftDatadogClient.cs @@ -0,0 +1,117 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// + public partial interface IMicrosoftDatadogClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// The Microsoft Azure subscription ID. + /// + string SubscriptionId { get; set; } + + /// + /// The API version to use for this operation. + /// + string ApiVersion { get; } + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IApiKeysOperations. + /// + IApiKeysOperations ApiKeys { get; } + + /// + /// Gets the IHostsOperations. + /// + IHostsOperations Hosts { get; } + + /// + /// Gets the ILinkedResourcesOperations. + /// + ILinkedResourcesOperations LinkedResources { get; } + + /// + /// Gets the IMonitoredResourcesOperations. + /// + IMonitoredResourcesOperations MonitoredResources { get; } + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IMonitorsOperations. + /// + IMonitorsOperations Monitors { get; } + + /// + /// Gets the IRefreshSetPasswordOperations. + /// + IRefreshSetPasswordOperations RefreshSetPassword { get; } + + /// + /// Gets the ITagRulesOperations. + /// + ITagRulesOperations TagRules { get; } + + /// + /// Gets the ISingleSignOnConfigurationsOperations. + /// + ISingleSignOnConfigurationsOperations SingleSignOnConfigurations { get; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IMonitoredResourcesOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IMonitoredResourcesOperations.cs new file mode 100644 index 0000000000000..1f10b2a0bc604 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IMonitoredResourcesOperations.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MonitoredResourcesOperations operations. + /// + public partial interface IMonitoredResourcesOperations + { + /// + /// List the resources currently being monitored by the Datadog monitor + /// resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the resources currently being monitored by the Datadog monitor + /// resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IMonitorsOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IMonitorsOperations.cs new file mode 100644 index 0000000000000..5b573323c75ed --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IMonitorsOperations.cs @@ -0,0 +1,269 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MonitorsOperations operations. + /// + public partial interface IMonitorsOperations + { + /// + /// List all monitors under the specified subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all monitors under the specified resource group. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the properties of a specific monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string monitorName, DatadogMonitorResource body = default(DatadogMonitorResource), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string monitorName, DatadogMonitorResourceUpdateParameters body = default(DatadogMonitorResourceUpdateParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string monitorName, DatadogMonitorResource body = default(DatadogMonitorResource), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all monitors under the specified subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all monitors under the specified resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IOperations.cs new file mode 100644 index 0000000000000..e5846ca36703a --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IOperations.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + public partial interface IOperations + { + /// + /// List all operations provided by Microsoft.Datadog for the + /// 2020-02-01-preview api version. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all operations provided by Microsoft.Datadog for the + /// 2020-02-01-preview api version. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IRefreshSetPasswordOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IRefreshSetPasswordOperations.cs new file mode 100644 index 0000000000000..c95070e8df9bc --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/IRefreshSetPasswordOperations.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RefreshSetPasswordOperations operations. + /// + public partial interface IRefreshSetPasswordOperations + { + /// + /// Refresh the set password link and return a latest one. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ISingleSignOnConfigurationsOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ISingleSignOnConfigurationsOperations.cs new file mode 100644 index 0000000000000..176d2bc8cd65e --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ISingleSignOnConfigurationsOperations.cs @@ -0,0 +1,165 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SingleSignOnConfigurationsOperations operations. + /// + public partial interface ISingleSignOnConfigurationsOperations + { + /// + /// List the single sign-on configurations for a given monitor + /// resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Configures single-sign-on for this resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string monitorName, string configurationName, DatadogSingleSignOnProperties properties = default(DatadogSingleSignOnProperties), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the datadog single sign-on resource for the given Monitor. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string monitorName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Configures single-sign-on for this resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string monitorName, string configurationName, DatadogSingleSignOnProperties properties = default(DatadogSingleSignOnProperties), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the single sign-on configurations for a given monitor + /// resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ITagRulesOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ITagRulesOperations.cs new file mode 100644 index 0000000000000..0befb5e6db1d7 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/ITagRulesOperations.cs @@ -0,0 +1,133 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TagRulesOperations operations. + /// + public partial interface ITagRulesOperations + { + /// + /// List the tag rules for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a tag rule set for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string monitorName, string ruleSetName, MonitoringTagRulesProperties properties = default(MonitoringTagRulesProperties), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a tag rule set for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource + /// belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string monitorName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the tag rules for a given monitor resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/LinkedResourcesOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/LinkedResourcesOperations.cs new file mode 100644 index 0000000000000..895cfe9333317 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/LinkedResourcesOperations.cs @@ -0,0 +1,422 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LinkedResourcesOperations operations. + /// + internal partial class LinkedResourcesOperations : IServiceOperations, ILinkedResourcesOperations + { + /// + /// Initializes a new instance of the LinkedResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LinkedResourcesOperations(MicrosoftDatadogClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MicrosoftDatadogClient + /// + public MicrosoftDatadogClient Client { get; private set; } + + /// + /// List all Azure resources associated to the same Datadog organization as the + /// target resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listLinkedResources").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all Azure resources associated to the same Datadog organization as the + /// target resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/LinkedResourcesOperationsExtensions.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/LinkedResourcesOperationsExtensions.cs new file mode 100644 index 0000000000000..befe4e89caefe --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/LinkedResourcesOperationsExtensions.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LinkedResourcesOperations. + /// + public static partial class LinkedResourcesOperationsExtensions + { + /// + /// List all Azure resources associated to the same Datadog organization as the + /// target resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static IPage List(this ILinkedResourcesOperations operations, string resourceGroupName, string monitorName) + { + return operations.ListAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// List all Azure resources associated to the same Datadog organization as the + /// target resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ILinkedResourcesOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all Azure resources associated to the same Datadog organization as the + /// target resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ILinkedResourcesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all Azure resources associated to the same Datadog organization as the + /// target resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this ILinkedResourcesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MicrosoftDatadogClient.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MicrosoftDatadogClient.cs new file mode 100644 index 0000000000000..bbbac3388bcd5 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MicrosoftDatadogClient.cs @@ -0,0 +1,403 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + + public partial class MicrosoftDatadogClient : ServiceClient, IMicrosoftDatadogClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// The Microsoft Azure subscription ID. + /// + public string SubscriptionId { get; set; } + + /// + /// The API version to use for this operation. + /// + public string ApiVersion { get; private set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When set to + /// true a unique x-ms-client-request-id value is generated and included in + /// each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IApiKeysOperations. + /// + public virtual IApiKeysOperations ApiKeys { get; private set; } + + /// + /// Gets the IHostsOperations. + /// + public virtual IHostsOperations Hosts { get; private set; } + + /// + /// Gets the ILinkedResourcesOperations. + /// + public virtual ILinkedResourcesOperations LinkedResources { get; private set; } + + /// + /// Gets the IMonitoredResourcesOperations. + /// + public virtual IMonitoredResourcesOperations MonitoredResources { get; private set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IMonitorsOperations. + /// + public virtual IMonitorsOperations Monitors { get; private set; } + + /// + /// Gets the IRefreshSetPasswordOperations. + /// + public virtual IRefreshSetPasswordOperations RefreshSetPassword { get; private set; } + + /// + /// Gets the ITagRulesOperations. + /// + public virtual ITagRulesOperations TagRules { get; private set; } + + /// + /// Gets the ISingleSignOnConfigurationsOperations. + /// + public virtual ISingleSignOnConfigurationsOperations SingleSignOnConfigurations { get; private set; } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling MicrosoftDatadogClient.Dispose(). False: will not dispose provided httpClient + protected MicrosoftDatadogClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected MicrosoftDatadogClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected MicrosoftDatadogClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected MicrosoftDatadogClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected MicrosoftDatadogClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MicrosoftDatadogClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling MicrosoftDatadogClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public MicrosoftDatadogClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MicrosoftDatadogClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MicrosoftDatadogClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MicrosoftDatadogClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MicrosoftDatadogClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + ApiKeys = new ApiKeysOperations(this); + Hosts = new HostsOperations(this); + LinkedResources = new LinkedResourcesOperations(this); + MonitoredResources = new MonitoredResourcesOperations(this); + Operations = new Operations(this); + Monitors = new MonitorsOperations(this); + RefreshSetPassword = new RefreshSetPasswordOperations(this); + TagRules = new TagRulesOperations(this); + SingleSignOnConfigurations = new SingleSignOnConfigurationsOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2020-02-01-preview"; + AcceptLanguage = "en-US"; + LongRunningOperationRetryTimeout = 30; + GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogApiKey.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogApiKey.cs new file mode 100644 index 0000000000000..05c6ca54d6072 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogApiKey.cs @@ -0,0 +1,86 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class DatadogApiKey + { + /// + /// Initializes a new instance of the DatadogApiKey class. + /// + public DatadogApiKey() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogApiKey class. + /// + /// The value of the API key. + /// The user that created the API key. + /// The name of the API key. + /// The time of creation of the API key. + public DatadogApiKey(string key, string createdBy = default(string), string name = default(string), string created = default(string)) + { + CreatedBy = createdBy; + Name = name; + Key = key; + Created = created; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the user that created the API key. + /// + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets the name of the API key. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the value of the API key. + /// + [JsonProperty(PropertyName = "key")] + public string Key { get; set; } + + /// + /// Gets or sets the time of creation of the API key. + /// + [JsonProperty(PropertyName = "created")] + public string Created { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Key == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Key"); + } + } + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogHost.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogHost.cs new file mode 100644 index 0000000000000..b21a035e64557 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogHost.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class DatadogHost + { + /// + /// Initializes a new instance of the DatadogHost class. + /// + public DatadogHost() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogHost class. + /// + /// The name of the host. + /// The aliases for the host. + /// The Datadog integrations reporting metrics for + /// the host. + public DatadogHost(string name = default(string), IList aliases = default(IList), IList apps = default(IList), DatadogHostMetadata meta = default(DatadogHostMetadata)) + { + Name = name; + Aliases = aliases; + Apps = apps; + Meta = meta; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the host. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the aliases for the host. + /// + [JsonProperty(PropertyName = "aliases")] + public IList Aliases { get; set; } + + /// + /// Gets or sets the Datadog integrations reporting metrics for the + /// host. + /// + [JsonProperty(PropertyName = "apps")] + public IList Apps { get; set; } + + /// + /// + [JsonProperty(PropertyName = "meta")] + public DatadogHostMetadata Meta { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogHostMetadata.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogHostMetadata.cs new file mode 100644 index 0000000000000..803143063431b --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogHostMetadata.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class DatadogHostMetadata + { + /// + /// Initializes a new instance of the DatadogHostMetadata class. + /// + public DatadogHostMetadata() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogHostMetadata class. + /// + /// The agent version. + public DatadogHostMetadata(string agentVersion = default(string), DatadogInstallMethod installMethod = default(DatadogInstallMethod), DatadogLogsAgent logsAgent = default(DatadogLogsAgent)) + { + AgentVersion = agentVersion; + InstallMethod = installMethod; + LogsAgent = logsAgent; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the agent version. + /// + [JsonProperty(PropertyName = "agentVersion")] + public string AgentVersion { get; set; } + + /// + /// + [JsonProperty(PropertyName = "installMethod")] + public DatadogInstallMethod InstallMethod { get; set; } + + /// + /// + [JsonProperty(PropertyName = "logsAgent")] + public DatadogLogsAgent LogsAgent { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogInstallMethod.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogInstallMethod.cs new file mode 100644 index 0000000000000..15d8d90821cd6 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogInstallMethod.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class DatadogInstallMethod + { + /// + /// Initializes a new instance of the DatadogInstallMethod class. + /// + public DatadogInstallMethod() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogInstallMethod class. + /// + /// The tool. + /// The tool version. + /// The installer version. + public DatadogInstallMethod(string tool = default(string), string toolVersion = default(string), string installerVersion = default(string)) + { + Tool = tool; + ToolVersion = toolVersion; + InstallerVersion = installerVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the tool. + /// + [JsonProperty(PropertyName = "tool")] + public string Tool { get; set; } + + /// + /// Gets or sets the tool version. + /// + [JsonProperty(PropertyName = "toolVersion")] + public string ToolVersion { get; set; } + + /// + /// Gets or sets the installer version. + /// + [JsonProperty(PropertyName = "installerVersion")] + public string InstallerVersion { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogLogsAgent.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogLogsAgent.cs new file mode 100644 index 0000000000000..73e14d1f319c3 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogLogsAgent.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class DatadogLogsAgent + { + /// + /// Initializes a new instance of the DatadogLogsAgent class. + /// + public DatadogLogsAgent() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogLogsAgent class. + /// + /// The transport. + public DatadogLogsAgent(string transport = default(string)) + { + Transport = transport; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the transport. + /// + [JsonProperty(PropertyName = "transport")] + public string Transport { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogMonitorResource.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogMonitorResource.cs new file mode 100644 index 0000000000000..d779b00507b45 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogMonitorResource.cs @@ -0,0 +1,119 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class DatadogMonitorResource : IResource + { + /// + /// Initializes a new instance of the DatadogMonitorResource class. + /// + public DatadogMonitorResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogMonitorResource class. + /// + /// ARM id of the monitor resource. + /// Name of the monitor resource. + /// The type of the monitor resource. + public DatadogMonitorResource(string location, string id = default(string), string name = default(string), string type = default(string), ResourceSku sku = default(ResourceSku), MonitorProperties properties = default(MonitorProperties), IdentityProperties identity = default(IdentityProperties), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Sku = sku; + Properties = properties; + Identity = identity; + Tags = tags; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets ARM id of the monitor resource. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets name of the monitor resource. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the monitor resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "sku")] + public ResourceSku Sku { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties")] + public MonitorProperties Properties { get; set; } + + /// + /// + [JsonProperty(PropertyName = "identity")] + public IdentityProperties Identity { get; set; } + + /// + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + if (Sku != null) + { + Sku.Validate(); + } + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogMonitorResourceUpdateParameters.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogMonitorResourceUpdateParameters.cs new file mode 100644 index 0000000000000..cccfd4d63c7ae --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogMonitorResourceUpdateParameters.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The parameters for a PATCH request to a monitor resource. + /// + public partial class DatadogMonitorResourceUpdateParameters + { + /// + /// Initializes a new instance of the + /// DatadogMonitorResourceUpdateParameters class. + /// + public DatadogMonitorResourceUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DatadogMonitorResourceUpdateParameters class. + /// + /// The new tags of the monitor resource. + public DatadogMonitorResourceUpdateParameters(MonitorUpdateProperties properties = default(MonitorUpdateProperties), IDictionary tags = default(IDictionary)) + { + Properties = properties; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties")] + public MonitorUpdateProperties Properties { get; set; } + + /// + /// Gets or sets the new tags of the monitor resource. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogOrganizationProperties.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogOrganizationProperties.cs new file mode 100644 index 0000000000000..461996f98473d --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogOrganizationProperties.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class DatadogOrganizationProperties + { + /// + /// Initializes a new instance of the DatadogOrganizationProperties + /// class. + /// + public DatadogOrganizationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogOrganizationProperties + /// class. + /// + /// Name of the Datadog organization. + /// Id of the Datadog organization. + /// The auth code used to linking to an + /// existing datadog organization. + /// The client_id from an existing in + /// exchange for an auth token to link organization. + /// The Id of the Enterprise App used for + /// Single sign on. + public DatadogOrganizationProperties(string name = default(string), string id = default(string), string linkingAuthCode = default(string), string linkingClientId = default(string), string enterpriseAppId = default(string)) + { + Name = name; + Id = id; + LinkingAuthCode = linkingAuthCode; + LinkingClientId = linkingClientId; + EnterpriseAppId = enterpriseAppId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets name of the Datadog organization. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets id of the Datadog organization. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the auth code used to linking to an existing datadog + /// organization. + /// + [JsonProperty(PropertyName = "linkingAuthCode")] + public string LinkingAuthCode { get; set; } + + /// + /// Gets or sets the client_id from an existing in exchange for an auth + /// token to link organization. + /// + [JsonProperty(PropertyName = "linkingClientId")] + public string LinkingClientId { get; set; } + + /// + /// Gets or sets the Id of the Enterprise App used for Single sign on. + /// + [JsonProperty(PropertyName = "enterpriseAppId")] + public string EnterpriseAppId { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogSetPasswordLink.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogSetPasswordLink.cs new file mode 100644 index 0000000000000..901692f7f040c --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogSetPasswordLink.cs @@ -0,0 +1,46 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class DatadogSetPasswordLink + { + /// + /// Initializes a new instance of the DatadogSetPasswordLink class. + /// + public DatadogSetPasswordLink() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogSetPasswordLink class. + /// + public DatadogSetPasswordLink(string setPasswordLink = default(string)) + { + SetPasswordLink = setPasswordLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "setPasswordLink")] + public string SetPasswordLink { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogSingleSignOnProperties.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogSingleSignOnProperties.cs new file mode 100644 index 0000000000000..d61ed71857eae --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogSingleSignOnProperties.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class DatadogSingleSignOnProperties + { + /// + /// Initializes a new instance of the DatadogSingleSignOnProperties + /// class. + /// + public DatadogSingleSignOnProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogSingleSignOnProperties + /// class. + /// + /// Possible values include: 'Initial', + /// 'Enable', 'Disable', 'Existing' + /// The Id of the Enterprise App used for + /// Single sign-on. + /// The login URL specific to this + /// Datadog Organization. + public DatadogSingleSignOnProperties(string singleSignOnState = default(string), string enterpriseAppId = default(string), string singleSignOnUrl = default(string)) + { + SingleSignOnState = singleSignOnState; + EnterpriseAppId = enterpriseAppId; + SingleSignOnUrl = singleSignOnUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets possible values include: 'Initial', 'Enable', + /// 'Disable', 'Existing' + /// + [JsonProperty(PropertyName = "singleSignOnState")] + public string SingleSignOnState { get; set; } + + /// + /// Gets or sets the Id of the Enterprise App used for Single sign-on. + /// + [JsonProperty(PropertyName = "enterpriseAppId")] + public string EnterpriseAppId { get; set; } + + /// + /// Gets or sets the login URL specific to this Datadog Organization. + /// + [JsonProperty(PropertyName = "singleSignOnUrl")] + public string SingleSignOnUrl { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogSingleSignOnResource.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogSingleSignOnResource.cs new file mode 100644 index 0000000000000..f18d9af0b5d69 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/DatadogSingleSignOnResource.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + public partial class DatadogSingleSignOnResource : IResource + { + /// + /// Initializes a new instance of the DatadogSingleSignOnResource + /// class. + /// + public DatadogSingleSignOnResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatadogSingleSignOnResource + /// class. + /// + /// ARM id of the resource. + /// Name of the configuration. + /// The type of the resource. + public DatadogSingleSignOnResource(string id = default(string), string name = default(string), string type = default(string), DatadogSingleSignOnProperties properties = default(DatadogSingleSignOnProperties)) + { + Id = id; + Name = name; + Type = type; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets ARM id of the resource. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets name of the configuration. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "properties")] + public DatadogSingleSignOnProperties Properties { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ErrorResponseBody.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ErrorResponseBody.cs new file mode 100644 index 0000000000000..6bc9344ead5d9 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ErrorResponseBody.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class ErrorResponseBody + { + /// + /// Initializes a new instance of the ErrorResponseBody class. + /// + public ErrorResponseBody() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponseBody class. + /// + public ErrorResponseBody(string code = default(string), string message = default(string), string target = default(string), IList details = default(IList)) + { + Code = code; + Message = message; + Target = target; + Details = details; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// + [JsonProperty(PropertyName = "target")] + public string Target { get; set; } + + /// + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/FilteringTag.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/FilteringTag.cs new file mode 100644 index 0000000000000..c114f88cbbcab --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/FilteringTag.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The definition of a filtering tag. Filtering tags are used for + /// capturing resources and include/exclude them from being monitored. + /// + public partial class FilteringTag + { + /// + /// Initializes a new instance of the FilteringTag class. + /// + public FilteringTag() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FilteringTag class. + /// + /// The name (also known as the key) of the + /// tag. + /// The value of the tag. + /// Possible values include: 'Include', + /// 'Exclude' + public FilteringTag(string name = default(string), string value = default(string), string action = default(string)) + { + Name = name; + Value = value; + Action = action; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name (also known as the key) of the tag. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the value of the tag. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Gets or sets possible values include: 'Include', 'Exclude' + /// + [JsonProperty(PropertyName = "action")] + public string Action { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/IdentityProperties.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/IdentityProperties.cs new file mode 100644 index 0000000000000..649e00dfcdad7 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/IdentityProperties.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class IdentityProperties + { + /// + /// Initializes a new instance of the IdentityProperties class. + /// + public IdentityProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IdentityProperties class. + /// + /// The identity ID. + /// The tenant ID of resource. + /// Possible values include: 'SystemAssigned', + /// 'UserAssigned' + public IdentityProperties(string principalId = default(string), string tenantId = default(string), string type = default(string)) + { + PrincipalId = principalId; + TenantId = tenantId; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the identity ID. + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; private set; } + + /// + /// Gets the tenant ID of resource. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets or sets possible values include: 'SystemAssigned', + /// 'UserAssigned' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/LiftrResourceCategories.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/LiftrResourceCategories.cs new file mode 100644 index 0000000000000..1ffbd9a0fd60f --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/LiftrResourceCategories.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + + /// + /// Defines values for LiftrResourceCategories. + /// + public static class LiftrResourceCategories + { + public const string Unknown = "Unknown"; + public const string MonitorLogs = "MonitorLogs"; + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/LinkedResource.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/LinkedResource.cs new file mode 100644 index 0000000000000..3463829a55ee5 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/LinkedResource.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The definition of a linked resource. + /// + public partial class LinkedResource + { + /// + /// Initializes a new instance of the LinkedResource class. + /// + public LinkedResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LinkedResource class. + /// + /// The ARM id of the linked resource. + public LinkedResource(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ARM id of the linked resource. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/LogRules.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/LogRules.cs new file mode 100644 index 0000000000000..6eff70a787a96 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/LogRules.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Set of rules for sending logs for the Monitor resource. + /// + public partial class LogRules + { + /// + /// Initializes a new instance of the LogRules class. + /// + public LogRules() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogRules class. + /// + /// Flag specifying if AAD logs should be + /// sent for the Monitor resource. + /// Flag specifying if Azure + /// subscription logs should be sent for the Monitor resource. + /// Flag specifying if Azure resource + /// logs should be sent for the Monitor resource. + /// List of filtering tags to be used for + /// capturing logs. This only takes effect if SendResourceLogs flag is + /// enabled. If empty, all resources will be captured. If only Exclude + /// action is specified, the rules will apply to the list of all + /// available resources. If Include actions are specified, the rules + /// will only include resources with the associated tags. + public LogRules(bool? sendAadLogs = default(bool?), bool? sendSubscriptionLogs = default(bool?), bool? sendResourceLogs = default(bool?), IList filteringTags = default(IList)) + { + SendAadLogs = sendAadLogs; + SendSubscriptionLogs = sendSubscriptionLogs; + SendResourceLogs = sendResourceLogs; + FilteringTags = filteringTags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets flag specifying if AAD logs should be sent for the + /// Monitor resource. + /// + [JsonProperty(PropertyName = "sendAadLogs")] + public bool? SendAadLogs { get; set; } + + /// + /// Gets or sets flag specifying if Azure subscription logs should be + /// sent for the Monitor resource. + /// + [JsonProperty(PropertyName = "sendSubscriptionLogs")] + public bool? SendSubscriptionLogs { get; set; } + + /// + /// Gets or sets flag specifying if Azure resource logs should be sent + /// for the Monitor resource. + /// + [JsonProperty(PropertyName = "sendResourceLogs")] + public bool? SendResourceLogs { get; set; } + + /// + /// Gets or sets list of filtering tags to be used for capturing logs. + /// This only takes effect if SendResourceLogs flag is enabled. If + /// empty, all resources will be captured. If only Exclude action is + /// specified, the rules will apply to the list of all available + /// resources. If Include actions are specified, the rules will only + /// include resources with the associated tags. + /// + [JsonProperty(PropertyName = "filteringTags")] + public IList FilteringTags { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ManagedIdentityTypes.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ManagedIdentityTypes.cs new file mode 100644 index 0000000000000..e6626ef4c6b69 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ManagedIdentityTypes.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + + /// + /// Defines values for ManagedIdentityTypes. + /// + public static class ManagedIdentityTypes + { + public const string SystemAssigned = "SystemAssigned"; + public const string UserAssigned = "UserAssigned"; + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MarketplaceSubscriptionStatus.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MarketplaceSubscriptionStatus.cs new file mode 100644 index 0000000000000..7ca947d6e37a8 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MarketplaceSubscriptionStatus.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + + /// + /// Defines values for MarketplaceSubscriptionStatus. + /// + public static class MarketplaceSubscriptionStatus + { + public const string Active = "Active"; + public const string Suspended = "Suspended"; + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MetricRules.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MetricRules.cs new file mode 100644 index 0000000000000..32b90a585d5ec --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MetricRules.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Set of rules for sending metrics for the Monitor resource. + /// + public partial class MetricRules + { + /// + /// Initializes a new instance of the MetricRules class. + /// + public MetricRules() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricRules class. + /// + /// List of filtering tags to be used for + /// capturing metrics. If empty, all resources will be captured. If + /// only Exclude action is specified, the rules will apply to the list + /// of all available resources. If Include actions are specified, the + /// rules will only include resources with the associated tags. + public MetricRules(IList filteringTags = default(IList)) + { + FilteringTags = filteringTags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of filtering tags to be used for capturing + /// metrics. If empty, all resources will be captured. If only Exclude + /// action is specified, the rules will apply to the list of all + /// available resources. If Include actions are specified, the rules + /// will only include resources with the associated tags. + /// + [JsonProperty(PropertyName = "filteringTags")] + public IList FilteringTags { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitorProperties.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitorProperties.cs new file mode 100644 index 0000000000000..7f124a490d6b2 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitorProperties.cs @@ -0,0 +1,116 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Properties specific to the monitor resource. + /// + public partial class MonitorProperties + { + /// + /// Initializes a new instance of the MonitorProperties class. + /// + public MonitorProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MonitorProperties class. + /// + /// Possible values include: + /// 'Accepted', 'Creating', 'Updating', 'Deleting', 'Succeeded', + /// 'Failed', 'Canceled', 'Deleted', 'NotSpecified' + /// Possible values include: 'Enabled', + /// 'Disabled' + /// Possible values + /// include: 'Active', 'Suspended' + /// Possible values include: + /// 'Unknown', 'MonitorLogs' + /// The priority of the + /// resource. + public MonitorProperties(string provisioningState = default(string), string monitoringStatus = default(string), string marketplaceSubscriptionStatus = default(string), DatadogOrganizationProperties datadogOrganizationProperties = default(DatadogOrganizationProperties), UserInfo userInfo = default(UserInfo), string liftrResourceCategory = default(string), int? liftrResourcePreference = default(int?)) + { + ProvisioningState = provisioningState; + MonitoringStatus = monitoringStatus; + MarketplaceSubscriptionStatus = marketplaceSubscriptionStatus; + DatadogOrganizationProperties = datadogOrganizationProperties; + UserInfo = userInfo; + LiftrResourceCategory = liftrResourceCategory; + LiftrResourcePreference = liftrResourcePreference; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets possible values include: 'Accepted', 'Creating', + /// 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled', + /// 'Deleted', 'NotSpecified' + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "monitoringStatus")] + public string MonitoringStatus { get; set; } + + /// + /// Gets or sets possible values include: 'Active', 'Suspended' + /// + [JsonProperty(PropertyName = "marketplaceSubscriptionStatus")] + public string MarketplaceSubscriptionStatus { get; set; } + + /// + /// + [JsonProperty(PropertyName = "datadogOrganizationProperties")] + public DatadogOrganizationProperties DatadogOrganizationProperties { get; set; } + + /// + /// + [JsonProperty(PropertyName = "userInfo")] + public UserInfo UserInfo { get; set; } + + /// + /// Gets or sets possible values include: 'Unknown', 'MonitorLogs' + /// + [JsonProperty(PropertyName = "liftrResourceCategory")] + public string LiftrResourceCategory { get; set; } + + /// + /// Gets the priority of the resource. + /// + [JsonProperty(PropertyName = "liftrResourcePreference")] + public int? LiftrResourcePreference { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (UserInfo != null) + { + UserInfo.Validate(); + } + } + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitorUpdateProperties.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitorUpdateProperties.cs new file mode 100644 index 0000000000000..3ecb045c2166e --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitorUpdateProperties.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The set of properties that can be update in a PATCH request to a + /// monitor resource. + /// + public partial class MonitorUpdateProperties + { + /// + /// Initializes a new instance of the MonitorUpdateProperties class. + /// + public MonitorUpdateProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MonitorUpdateProperties class. + /// + /// Possible values include: 'Enabled', + /// 'Disabled' + public MonitorUpdateProperties(string monitoringStatus = default(string)) + { + MonitoringStatus = monitoringStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "monitoringStatus")] + public string MonitoringStatus { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoredResource.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoredResource.cs new file mode 100644 index 0000000000000..028d9ed16aa8d --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoredResource.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of a resource currently being monitored by the Datadog + /// monitor resource. + /// + public partial class MonitoredResource + { + /// + /// Initializes a new instance of the MonitoredResource class. + /// + public MonitoredResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MonitoredResource class. + /// + /// The ARM id of the resource. + /// Flag indicating if resource is sending + /// metrics to Datadog. + /// Reason for why the resource is + /// sending metrics (or why it is not sending). + /// Flag indicating if resource is sending + /// logs to Datadog. + /// Reason for why the resource is + /// sending logs (or why it is not sending). + public MonitoredResource(string id = default(string), bool? sendingMetrics = default(bool?), string reasonForMetricsStatus = default(string), bool? sendingLogs = default(bool?), string reasonForLogsStatus = default(string)) + { + Id = id; + SendingMetrics = sendingMetrics; + ReasonForMetricsStatus = reasonForMetricsStatus; + SendingLogs = sendingLogs; + ReasonForLogsStatus = reasonForLogsStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ARM id of the resource. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets flag indicating if resource is sending metrics to + /// Datadog. + /// + [JsonProperty(PropertyName = "sendingMetrics")] + public bool? SendingMetrics { get; set; } + + /// + /// Gets or sets reason for why the resource is sending metrics (or why + /// it is not sending). + /// + [JsonProperty(PropertyName = "reasonForMetricsStatus")] + public string ReasonForMetricsStatus { get; set; } + + /// + /// Gets or sets flag indicating if resource is sending logs to + /// Datadog. + /// + [JsonProperty(PropertyName = "sendingLogs")] + public bool? SendingLogs { get; set; } + + /// + /// Gets or sets reason for why the resource is sending logs (or why it + /// is not sending). + /// + [JsonProperty(PropertyName = "reasonForLogsStatus")] + public string ReasonForLogsStatus { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoringStatus.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoringStatus.cs new file mode 100644 index 0000000000000..15668e0b3857c --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoringStatus.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + + /// + /// Defines values for MonitoringStatus. + /// + public static class MonitoringStatus + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoringTagRules.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoringTagRules.cs new file mode 100644 index 0000000000000..8d9088b8cf24a --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoringTagRules.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Capture logs and metrics of Azure resources based on ARM tags. + /// + public partial class MonitoringTagRules : IResource + { + /// + /// Initializes a new instance of the MonitoringTagRules class. + /// + public MonitoringTagRules() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MonitoringTagRules class. + /// + /// Name of the rule set. + /// The id of the rule set. + /// The type of the rule set. + public MonitoringTagRules(string name = default(string), string id = default(string), string type = default(string), MonitoringTagRulesProperties properties = default(MonitoringTagRulesProperties)) + { + Name = name; + Id = id; + Type = type; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets name of the rule set. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the id of the rule set. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the rule set. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "properties")] + public MonitoringTagRulesProperties Properties { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoringTagRulesProperties.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoringTagRulesProperties.cs new file mode 100644 index 0000000000000..5cf27df24b697 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/MonitoringTagRulesProperties.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Definition of the properties for a TagRules resource. + /// + public partial class MonitoringTagRulesProperties + { + /// + /// Initializes a new instance of the MonitoringTagRulesProperties + /// class. + /// + public MonitoringTagRulesProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MonitoringTagRulesProperties + /// class. + /// + public MonitoringTagRulesProperties(LogRules logRules = default(LogRules), MetricRules metricRules = default(MetricRules)) + { + LogRules = logRules; + MetricRules = metricRules; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "logRules")] + public LogRules LogRules { get; set; } + + /// + /// + [JsonProperty(PropertyName = "metricRules")] + public MetricRules MetricRules { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/OperationDisplay.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 0000000000000..0c1b6d0cb648f --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/OperationDisplay.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The object that represents the operation. + /// + public partial class OperationDisplay + { + /// + /// Initializes a new instance of the OperationDisplay class. + /// + public OperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplay class. + /// + /// Service provider, i.e., + /// Microsoft.Datadog. + /// Type on which the operation is performed, + /// e.g., 'monitors'. + /// Operation type, e.g., read, write, delete, + /// etc. + /// Description of the operation, e.g., + /// 'Write monitors'. + public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string)) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets service provider, i.e., Microsoft.Datadog. + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; set; } + + /// + /// Gets or sets type on which the operation is performed, e.g., + /// 'monitors'. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; set; } + + /// + /// Gets or sets operation type, e.g., read, write, delete, etc. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets description of the operation, e.g., 'Write monitors'. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/OperationResult.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/OperationResult.cs new file mode 100644 index 0000000000000..c773585163462 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/OperationResult.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A Microsoft.Datadog REST API operation. + /// + public partial class OperationResult + { + /// + /// Initializes a new instance of the OperationResult class. + /// + public OperationResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationResult class. + /// + /// Operation name, i.e., + /// {provider}/{resource}/{operation}. + /// Indicates whether the operation is a + /// data action + public OperationResult(string name = default(string), OperationDisplay display = default(OperationDisplay), bool? isDataAction = default(bool?)) + { + Name = name; + Display = display; + IsDataAction = isDataAction; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets operation name, i.e., + /// {provider}/{resource}/{operation}. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; set; } + + /// + /// Gets or sets indicates whether the operation is a data action + /// + [JsonProperty(PropertyName = "isDataAction")] + public bool? IsDataAction { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/Page.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/Page.cs new file mode 100644 index 0000000000000..c2d0c32eadd01 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/Page.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ProvisioningState.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 0000000000000..4f0f988f49192 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + + /// + /// Defines values for ProvisioningState. + /// + public static class ProvisioningState + { + public const string Accepted = "Accepted"; + public const string Creating = "Creating"; + public const string Updating = "Updating"; + public const string Deleting = "Deleting"; + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + public const string Canceled = "Canceled"; + public const string Deleted = "Deleted"; + public const string NotSpecified = "NotSpecified"; + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ResourceProviderDefaultErrorResponse.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ResourceProviderDefaultErrorResponse.cs new file mode 100644 index 0000000000000..52bccfa4645cf --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ResourceProviderDefaultErrorResponse.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ResourceProviderDefaultErrorResponse + { + /// + /// Initializes a new instance of the + /// ResourceProviderDefaultErrorResponse class. + /// + public ResourceProviderDefaultErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ResourceProviderDefaultErrorResponse class. + /// + public ResourceProviderDefaultErrorResponse(ErrorResponseBody error = default(ErrorResponseBody)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponseBody Error { get; set; } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ResourceProviderDefaultErrorResponseException.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ResourceProviderDefaultErrorResponseException.cs new file mode 100644 index 0000000000000..1f7bc4d63fb9b --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ResourceProviderDefaultErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with + /// ResourceProviderDefaultErrorResponse information. + /// + public partial class ResourceProviderDefaultErrorResponseException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ResourceProviderDefaultErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the ResourceProviderDefaultErrorResponseException class. + /// + public ResourceProviderDefaultErrorResponseException() + { + } + + /// + /// Initializes a new instance of the ResourceProviderDefaultErrorResponseException class. + /// + /// The exception message. + public ResourceProviderDefaultErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ResourceProviderDefaultErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public ResourceProviderDefaultErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ResourceSku.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ResourceSku.cs new file mode 100644 index 0000000000000..1da1837d4e9fe --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/ResourceSku.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class ResourceSku + { + /// + /// Initializes a new instance of the ResourceSku class. + /// + public ResourceSku() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceSku class. + /// + /// Name of the SKU. + public ResourceSku(string name) + { + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the SKU. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/SingleSignOnStates.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/SingleSignOnStates.cs new file mode 100644 index 0000000000000..d947c26e33261 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/SingleSignOnStates.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + + /// + /// Defines values for SingleSignOnStates. + /// + public static class SingleSignOnStates + { + public const string Initial = "Initial"; + public const string Enable = "Enable"; + public const string Disable = "Disable"; + public const string Existing = "Existing"; + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/TagAction.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/TagAction.cs new file mode 100644 index 0000000000000..3e067599da305 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/TagAction.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + + /// + /// Defines values for TagAction. + /// + public static class TagAction + { + public const string Include = "Include"; + public const string Exclude = "Exclude"; + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/UserInfo.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/UserInfo.cs new file mode 100644 index 0000000000000..3f5d83619f355 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Models/UserInfo.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class UserInfo + { + /// + /// Initializes a new instance of the UserInfo class. + /// + public UserInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UserInfo class. + /// + /// Name of the user + /// Email of the user used by Datadog for + /// contacting them if needed + /// Phone number of the user used by Datadog + /// for contacting them if needed + public UserInfo(string name = default(string), string emailAddress = default(string), string phoneNumber = default(string)) + { + Name = name; + EmailAddress = emailAddress; + PhoneNumber = phoneNumber; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the user + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets email of the user used by Datadog for contacting them + /// if needed + /// + [JsonProperty(PropertyName = "emailAddress")] + public string EmailAddress { get; set; } + + /// + /// Gets or sets phone number of the user used by Datadog for + /// contacting them if needed + /// + [JsonProperty(PropertyName = "phoneNumber")] + public string PhoneNumber { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name != null) + { + if (Name.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "Name", 50); + } + } + if (EmailAddress != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(EmailAddress, "^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,}$")) + { + throw new ValidationException(ValidationRules.Pattern, "EmailAddress", "^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,}$"); + } + } + if (PhoneNumber != null) + { + if (PhoneNumber.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "PhoneNumber", 40); + } + } + } + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitoredResourcesOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitoredResourcesOperations.cs new file mode 100644 index 0000000000000..386c7b53818ac --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitoredResourcesOperations.cs @@ -0,0 +1,422 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MonitoredResourcesOperations operations. + /// + internal partial class MonitoredResourcesOperations : IServiceOperations, IMonitoredResourcesOperations + { + /// + /// Initializes a new instance of the MonitoredResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MonitoredResourcesOperations(MicrosoftDatadogClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MicrosoftDatadogClient + /// + public MicrosoftDatadogClient Client { get; private set; } + + /// + /// List the resources currently being monitored by the Datadog monitor + /// resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listMonitoredResources").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the resources currently being monitored by the Datadog monitor + /// resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitoredResourcesOperationsExtensions.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitoredResourcesOperationsExtensions.cs new file mode 100644 index 0000000000000..0cb64a4ac5b80 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitoredResourcesOperationsExtensions.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MonitoredResourcesOperations. + /// + public static partial class MonitoredResourcesOperationsExtensions + { + /// + /// List the resources currently being monitored by the Datadog monitor + /// resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static IPage List(this IMonitoredResourcesOperations operations, string resourceGroupName, string monitorName) + { + return operations.ListAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// List the resources currently being monitored by the Datadog monitor + /// resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IMonitoredResourcesOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List the resources currently being monitored by the Datadog monitor + /// resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IMonitoredResourcesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List the resources currently being monitored by the Datadog monitor + /// resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IMonitoredResourcesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitorsOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitorsOperations.cs new file mode 100644 index 0000000000000..a9909dde73aed --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitorsOperations.cs @@ -0,0 +1,1616 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MonitorsOperations operations. + /// + internal partial class MonitorsOperations : IServiceOperations, IMonitorsOperations + { + /// + /// Initializes a new instance of the MonitorsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MonitorsOperations(MicrosoftDatadogClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MicrosoftDatadogClient + /// + public MicrosoftDatadogClient Client { get; private set; } + + /// + /// List all monitors under the specified subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Datadog/monitors").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all monitors under the specified resource group. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the properties of a specific monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string monitorName, DatadogMonitorResource body = default(DatadogMonitorResource), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, monitorName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string monitorName, DatadogMonitorResourceUpdateParameters body = default(DatadogMonitorResourceUpdateParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, monitorName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string monitorName, DatadogMonitorResource body = default(DatadogMonitorResource), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (body != null) + { + body.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all monitors under the specified subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all monitors under the specified resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitorsOperationsExtensions.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitorsOperationsExtensions.cs new file mode 100644 index 0000000000000..60553e63e0562 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/MonitorsOperationsExtensions.cs @@ -0,0 +1,401 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MonitorsOperations. + /// + public static partial class MonitorsOperationsExtensions + { + /// + /// List all monitors under the specified subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IMonitorsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// List all monitors under the specified subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IMonitorsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all monitors under the specified resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + public static IPage ListByResourceGroup(this IMonitorsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// List all monitors under the specified resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IMonitorsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the properties of a specific monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static DatadogMonitorResource Get(this IMonitorsOperations operations, string resourceGroupName, string monitorName) + { + return operations.GetAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// Get the properties of a specific monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IMonitorsOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + public static DatadogMonitorResource Create(this IMonitorsOperations operations, string resourceGroupName, string monitorName, DatadogMonitorResource body = default(DatadogMonitorResource)) + { + return operations.CreateAsync(resourceGroupName, monitorName, body).GetAwaiter().GetResult(); + } + + /// + /// Create a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IMonitorsOperations operations, string resourceGroupName, string monitorName, DatadogMonitorResource body = default(DatadogMonitorResource), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, monitorName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + public static DatadogMonitorResource Update(this IMonitorsOperations operations, string resourceGroupName, string monitorName, DatadogMonitorResourceUpdateParameters body = default(DatadogMonitorResourceUpdateParameters)) + { + return operations.UpdateAsync(resourceGroupName, monitorName, body).GetAwaiter().GetResult(); + } + + /// + /// Update a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IMonitorsOperations operations, string resourceGroupName, string monitorName, DatadogMonitorResourceUpdateParameters body = default(DatadogMonitorResourceUpdateParameters), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, monitorName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static void Delete(this IMonitorsOperations operations, string resourceGroupName, string monitorName) + { + operations.DeleteAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// Delete a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IMonitorsOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + public static DatadogMonitorResource BeginCreate(this IMonitorsOperations operations, string resourceGroupName, string monitorName, DatadogMonitorResource body = default(DatadogMonitorResource)) + { + return operations.BeginCreateAsync(resourceGroupName, monitorName, body).GetAwaiter().GetResult(); + } + + /// + /// Create a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IMonitorsOperations operations, string resourceGroupName, string monitorName, DatadogMonitorResource body = default(DatadogMonitorResource), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, monitorName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static void BeginDelete(this IMonitorsOperations operations, string resourceGroupName, string monitorName) + { + operations.BeginDeleteAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// Delete a monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IMonitorsOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List all monitors under the specified subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IMonitorsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all monitors under the specified subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IMonitorsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all monitors under the specified resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IMonitorsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all monitors under the specified resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IMonitorsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Operations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Operations.cs new file mode 100644 index 0000000000000..0f5d727a60191 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/Operations.cs @@ -0,0 +1,399 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + internal partial class Operations : IServiceOperations, IOperations + { + /// + /// Initializes a new instance of the Operations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal Operations(MicrosoftDatadogClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MicrosoftDatadogClient + /// + public MicrosoftDatadogClient Client { get; private set; } + + /// + /// List all operations provided by Microsoft.Datadog for the + /// 2020-02-01-preview api version. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Datadog/operations").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all operations provided by Microsoft.Datadog for the + /// 2020-02-01-preview api version. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/OperationsExtensions.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/OperationsExtensions.cs new file mode 100644 index 0000000000000..cd3077a3dabf1 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/OperationsExtensions.cs @@ -0,0 +1,91 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// List all operations provided by Microsoft.Datadog for the + /// 2020-02-01-preview api version. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// List all operations provided by Microsoft.Datadog for the + /// 2020-02-01-preview api version. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all operations provided by Microsoft.Datadog for the + /// 2020-02-01-preview api version. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all operations provided by Microsoft.Datadog for the + /// 2020-02-01-preview api version. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/RefreshSetPasswordOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/RefreshSetPasswordOperations.cs new file mode 100644 index 0000000000000..f185c8186e969 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/RefreshSetPasswordOperations.cs @@ -0,0 +1,252 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RefreshSetPasswordOperations operations. + /// + internal partial class RefreshSetPasswordOperations : IServiceOperations, IRefreshSetPasswordOperations + { + /// + /// Initializes a new instance of the RefreshSetPasswordOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal RefreshSetPasswordOperations(MicrosoftDatadogClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MicrosoftDatadogClient + /// + public MicrosoftDatadogClient Client { get; private set; } + + /// + /// Refresh the set password link and return a latest one. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/refreshSetPasswordLink").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/RefreshSetPasswordOperationsExtensions.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/RefreshSetPasswordOperationsExtensions.cs new file mode 100644 index 0000000000000..9e0867d27fc0e --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/RefreshSetPasswordOperationsExtensions.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for RefreshSetPasswordOperations. + /// + public static partial class RefreshSetPasswordOperationsExtensions + { + /// + /// Refresh the set password link and return a latest one. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static DatadogSetPasswordLink Get(this IRefreshSetPasswordOperations operations, string resourceGroupName, string monitorName) + { + return operations.GetAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// Refresh the set password link and return a latest one. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IRefreshSetPasswordOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/SdkInfo_MicrosoftDatadogClient.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/SdkInfo_MicrosoftDatadogClient.cs new file mode 100644 index 0000000000000..8a14d17a5ea0e --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/SdkInfo_MicrosoftDatadogClient.cs @@ -0,0 +1,46 @@ + +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_MicrosoftDatadogClient + { + get + { + return new Tuple[] + { + new Tuple("Datadog", "ApiKeys", "2020-02-01-preview"), + new Tuple("Datadog", "Hosts", "2020-02-01-preview"), + new Tuple("Datadog", "LinkedResources", "2020-02-01-preview"), + new Tuple("Datadog", "MonitoredResources", "2020-02-01-preview"), + new Tuple("Datadog", "Monitors", "2020-02-01-preview"), + new Tuple("Datadog", "Operations", "2020-02-01-preview"), + new Tuple("Datadog", "RefreshSetPassword", "2020-02-01-preview"), + new Tuple("Datadog", "SingleSignOnConfigurations", "2020-02-01-preview"), + new Tuple("Datadog", "TagRules", "2020-02-01-preview"), + }.AsEnumerable(); + } + } + // BEGIN: Code Generation Metadata Section + public static readonly String AutoRestVersion = "v2"; + public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413"; + public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/datadog/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=C:\\work\\azure-sdk-for-net\\sdk"; + public static readonly String GithubForkName = "Azure"; + public static readonly String GithubBranchName = "master"; + public static readonly String GithubCommidId = "183db615e7e870d12668972c874897f095fe256c"; + public static readonly String CodeGenerationErrors = ""; + public static readonly String GithubRepoName = "azure-rest-api-specs"; + // END: Code Generation Metadata Section + } +} + diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/SingleSignOnConfigurationsOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/SingleSignOnConfigurationsOperations.cs new file mode 100644 index 0000000000000..b3d98f639e9b5 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/SingleSignOnConfigurationsOperations.cs @@ -0,0 +1,891 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SingleSignOnConfigurationsOperations operations. + /// + internal partial class SingleSignOnConfigurationsOperations : IServiceOperations, ISingleSignOnConfigurationsOperations + { + /// + /// Initializes a new instance of the SingleSignOnConfigurationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SingleSignOnConfigurationsOperations(MicrosoftDatadogClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MicrosoftDatadogClient + /// + public MicrosoftDatadogClient Client { get; private set; } + + /// + /// List the single sign-on configurations for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Configures single-sign-on for this resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string monitorName, string configurationName, DatadogSingleSignOnProperties properties = default(DatadogSingleSignOnProperties), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, monitorName, configurationName, properties, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the datadog single sign-on resource for the given Monitor. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string monitorName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Configures single-sign-on for this resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string monitorName, string configurationName, DatadogSingleSignOnProperties properties = default(DatadogSingleSignOnProperties), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + DatadogSingleSignOnResource body = default(DatadogSingleSignOnResource); + if (properties != null) + { + body = new DatadogSingleSignOnResource(); + body.Properties = properties; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the single sign-on configurations for a given monitor resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/SingleSignOnConfigurationsOperationsExtensions.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/SingleSignOnConfigurationsOperationsExtensions.cs new file mode 100644 index 0000000000000..b68a85fbf3a02 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/SingleSignOnConfigurationsOperationsExtensions.cs @@ -0,0 +1,239 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SingleSignOnConfigurationsOperations. + /// + public static partial class SingleSignOnConfigurationsOperationsExtensions + { + /// + /// List the single sign-on configurations for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static IPage List(this ISingleSignOnConfigurationsOperations operations, string resourceGroupName, string monitorName) + { + return operations.ListAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// List the single sign-on configurations for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ISingleSignOnConfigurationsOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Configures single-sign-on for this resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + public static DatadogSingleSignOnResource CreateOrUpdate(this ISingleSignOnConfigurationsOperations operations, string resourceGroupName, string monitorName, string configurationName, DatadogSingleSignOnProperties properties = default(DatadogSingleSignOnProperties)) + { + return operations.CreateOrUpdateAsync(resourceGroupName, monitorName, configurationName, properties).GetAwaiter().GetResult(); + } + + /// + /// Configures single-sign-on for this resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ISingleSignOnConfigurationsOperations operations, string resourceGroupName, string monitorName, string configurationName, DatadogSingleSignOnProperties properties = default(DatadogSingleSignOnProperties), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, monitorName, configurationName, properties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the datadog single sign-on resource for the given Monitor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + public static DatadogSingleSignOnResource Get(this ISingleSignOnConfigurationsOperations operations, string resourceGroupName, string monitorName, string configurationName) + { + return operations.GetAsync(resourceGroupName, monitorName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Gets the datadog single sign-on resource for the given Monitor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISingleSignOnConfigurationsOperations operations, string resourceGroupName, string monitorName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, monitorName, configurationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Configures single-sign-on for this resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + public static DatadogSingleSignOnResource BeginCreateOrUpdate(this ISingleSignOnConfigurationsOperations operations, string resourceGroupName, string monitorName, string configurationName, DatadogSingleSignOnProperties properties = default(DatadogSingleSignOnProperties)) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, monitorName, configurationName, properties).GetAwaiter().GetResult(); + } + + /// + /// Configures single-sign-on for this resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this ISingleSignOnConfigurationsOperations operations, string resourceGroupName, string monitorName, string configurationName, DatadogSingleSignOnProperties properties = default(DatadogSingleSignOnProperties), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, monitorName, configurationName, properties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List the single sign-on configurations for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ISingleSignOnConfigurationsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List the single sign-on configurations for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this ISingleSignOnConfigurationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/TagRulesOperations.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/TagRulesOperations.cs new file mode 100644 index 0000000000000..46f53070713f5 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/TagRulesOperations.cs @@ -0,0 +1,847 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TagRulesOperations operations. + /// + internal partial class TagRulesOperations : IServiceOperations, ITagRulesOperations + { + /// + /// Initializes a new instance of the TagRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TagRulesOperations(MicrosoftDatadogClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MicrosoftDatadogClient + /// + public MicrosoftDatadogClient Client { get; private set; } + + /// + /// List the tag rules for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string monitorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update a tag rule set for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string monitorName, string ruleSetName, MonitoringTagRulesProperties properties = default(MonitoringTagRulesProperties), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + MonitoringTagRules body = default(MonitoringTagRules); + if (properties != null) + { + body = new MonitoringTagRules(); + body.Properties = properties; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules/{ruleSetName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get a tag rule set for a given monitor resource. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string monitorName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (monitorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("monitorName", monitorName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules/{ruleSetName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{monitorName}", System.Uri.EscapeDataString(monitorName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the tag rules for a given monitor resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ResourceProviderDefaultErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ResourceProviderDefaultErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/TagRulesOperationsExtensions.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/TagRulesOperationsExtensions.cs new file mode 100644 index 0000000000000..28aa217815bec --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Generated/TagRulesOperationsExtensions.cs @@ -0,0 +1,191 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Datadog +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TagRulesOperations. + /// + public static partial class TagRulesOperationsExtensions + { + /// + /// List the tag rules for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + public static IPage List(this ITagRulesOperations operations, string resourceGroupName, string monitorName) + { + return operations.ListAsync(resourceGroupName, monitorName).GetAwaiter().GetResult(); + } + + /// + /// List the tag rules for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ITagRulesOperations operations, string resourceGroupName, string monitorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, monitorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a tag rule set for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + public static MonitoringTagRules CreateOrUpdate(this ITagRulesOperations operations, string resourceGroupName, string monitorName, string ruleSetName, MonitoringTagRulesProperties properties = default(MonitoringTagRulesProperties)) + { + return operations.CreateOrUpdateAsync(resourceGroupName, monitorName, ruleSetName, properties).GetAwaiter().GetResult(); + } + + /// + /// Create or update a tag rule set for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ITagRulesOperations operations, string resourceGroupName, string monitorName, string ruleSetName, MonitoringTagRulesProperties properties = default(MonitoringTagRulesProperties), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, monitorName, ruleSetName, properties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get a tag rule set for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + public static MonitoringTagRules Get(this ITagRulesOperations operations, string resourceGroupName, string monitorName, string ruleSetName) + { + return operations.GetAsync(resourceGroupName, monitorName, ruleSetName).GetAwaiter().GetResult(); + } + + /// + /// Get a tag rule set for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the Datadog resource belongs. + /// + /// + /// Monitor resource name + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ITagRulesOperations operations, string resourceGroupName, string monitorName, string ruleSetName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, monitorName, ruleSetName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List the tag rules for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ITagRulesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List the tag rules for a given monitor resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this ITagRulesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Microsoft.Azure.Management.Datadog.csproj b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Microsoft.Azure.Management.Datadog.csproj new file mode 100644 index 0000000000000..b28c1b2d871cc --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Microsoft.Azure.Management.Datadog.csproj @@ -0,0 +1,25 @@ + + + + + + + Microsoft.Azure.Management.Datadog + Microsoft Azure Management Datadog library + 0.1.0 + Microsoft.Azure.Management.Datadog + management;datadog; + + + + + + $(SdkTargetFx) + + + + + + diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Properties/AssemblyInfo.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..3c5efa9f9be48 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.Reflection; +using System.Resources; + +[assembly: AssemblyTitle("Microsoft Azure Datadog Management Library")] +[assembly: AssemblyDescription("Provides Microsoft Azure Datadog management functions for managing the Microsoft Azure Datadog service.")] + +[assembly: AssemblyVersion("0.1.0")] +[assembly: AssemblyFileVersion("0.1.0")] + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Microsoft Azure .NET SDK")] +[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/src/generate.ps1 b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/generate.ps1 new file mode 100644 index 0000000000000..5f8f8165ad631 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/src/generate.ps1 @@ -0,0 +1 @@ +Start-AutoRestCodeGeneration -ResourceProvider "datadog/resource-manager" -AutoRestVersion "v2" diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/tests/Microsoft.Azure.Management.Datadog.Tests.csproj b/sdk/datadog/Microsoft.Azure.Management.Datadog/tests/Microsoft.Azure.Management.Datadog.Tests.csproj new file mode 100644 index 0000000000000..4b90c5d658f51 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/tests/Microsoft.Azure.Management.Datadog.Tests.csproj @@ -0,0 +1,19 @@ + + + + Datadog.Tests + Datadog.Tests Class Library + Datadog.Tests + 1.0.0-preview + + + + + + + + + PreserveNewest + + + \ No newline at end of file diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/tests/SessionRecords/DatadogTests/TestResourceLifeCycle.json b/sdk/datadog/Microsoft.Azure.Management.Datadog/tests/SessionRecords/DatadogTests/TestResourceLifeCycle.json new file mode 100644 index 0000000000000..8d1a098156c34 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/tests/SessionRecords/DatadogTests/TestResourceLifeCycle.json @@ -0,0 +1,1107 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourcegroups/datadog-sdk-test-rg1630?api-version=2015-11-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL3Jlc291cmNlZ3JvdXBzL2RhdGFkb2ctc2RrLXRlc3QtcmcxNjMwP2FwaS12ZXJzaW9uPTIwMTUtMTEtMDE=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"westus2\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "dd127b46-e0c6-45c7-b981-b9906f73f752" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Resources.ResourceManagementClient/1.0.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "29" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:30:57 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-request-id": [ + "f881d9ad-9e11-44ee-9486-ffbf6930961d" + ], + "x-ms-correlation-request-id": [ + "f881d9ad-9e11-44ee-9486-ffbf6930961d" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193058Z:f881d9ad-9e11-44ee-9486-ffbf6930961d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "200" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630\",\r\n \"name\": \"datadog-sdk-test-rg1630\",\r\n \"location\": \"westus2\",\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL3Jlc291cmNlR3JvdXBzL2RhdGFkb2ctc2RrLXRlc3QtcmcxNjMwL3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9tb25pdG9ycy9kYXRhZG9nLXNkay10ZXN0LXJlc291cmNlODM1MD9hcGktdmVyc2lvbj0yMDIwLTAyLTAxLXByZXZpZXc=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"sku\": {\r\n \"name\": \"drawdown_testing_20200904_Monthly\"\r\n },\r\n \"properties\": {\r\n \"userInfo\": {\r\n \"name\": \"Mama Baba\",\r\n \"emailAddress\": \"liftrdevredmond@microsoft.com\",\r\n \"phoneNumber\": \"+1 (425) 5381111\"\r\n }\r\n },\r\n \"identity\": {\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"location\": \"westus2\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "b227cba2-336e-4120-b7b7-dd379a1cea84" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "325" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:31:02 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"1b000acf-0000-0800-0000-5f84aef60000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "Azure-AsyncOperation": [ + "https://management.azure.com/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2?api-version=2020-02-01-preview" + ], + "x-ms-request-id": [ + "c1c0202e-cc8c-4103-9303-c28b02fd88c2" + ], + "x-ms-correlation-request-id": [ + "1007ee64-8047-4988-8595-d39234ab2258" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193102Z:1007ee64-8047-4988-8595-d39234ab2258" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "803" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"name\": \"datadog-sdk-test-resource8350\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"drawdown_testing_20200904_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"identity\": {\r\n \"principalId\": \"09875460-2a9c-4043-b6a7-f26a36c402f9\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Accepted\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"marketplaceSubscriptionStatus\": \"Active\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"datadog-sdk-test-resource8350\",\r\n \"id\": null,\r\n \"linkingAuthCode\": null,\r\n \"linkingClientId\": null,\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9sb2NhdGlvbnMvV0VTVFVTMi9vcGVyYXRpb25TdGF0dXNlcy9jMWMwMjAyZS1jYzhjLTQxMDMtOTMwMy1jMjhiMDJmZDg4YzI/YXBpLXZlcnNpb249MjAyMC0wMi0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:31:32 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"00005832-0000-0800-0000-5f84aef50000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11999" + ], + "x-ms-request-id": [ + "e8950c26-585d-499f-970c-8ca8775ea3a1" + ], + "x-ms-correlation-request-id": [ + "14b57dcb-c2fa-45df-81b6-d0c9d8aecca6" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193132Z:14b57dcb-c2fa-45df-81b6-d0c9d8aecca6" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "392" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"name\": \"c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"resourceId\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"status\": \"Accepted\",\r\n \"startTime\": \"2020-10-12T19:31:01.2831719Z\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9sb2NhdGlvbnMvV0VTVFVTMi9vcGVyYXRpb25TdGF0dXNlcy9jMWMwMjAyZS1jYzhjLTQxMDMtOTMwMy1jMjhiMDJmZDg4YzI/YXBpLXZlcnNpb249MjAyMC0wMi0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:32:02 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"00005832-0000-0800-0000-5f84aef50000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11998" + ], + "x-ms-request-id": [ + "e53d581e-95e4-4670-987c-fdfb5723bf2f" + ], + "x-ms-correlation-request-id": [ + "5083d008-98a5-4b63-a710-8d087859469b" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193202Z:5083d008-98a5-4b63-a710-8d087859469b" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "392" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"name\": \"c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"resourceId\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"status\": \"Accepted\",\r\n \"startTime\": \"2020-10-12T19:31:01.2831719Z\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9sb2NhdGlvbnMvV0VTVFVTMi9vcGVyYXRpb25TdGF0dXNlcy9jMWMwMjAyZS1jYzhjLTQxMDMtOTMwMy1jMjhiMDJmZDg4YzI/YXBpLXZlcnNpb249MjAyMC0wMi0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:32:31 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"00005832-0000-0800-0000-5f84aef50000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11997" + ], + "x-ms-request-id": [ + "72c3a3df-9764-4860-b4c6-081244ff2157" + ], + "x-ms-correlation-request-id": [ + "69e3a09e-c05b-4e48-809d-fb43bdfc80a2" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193232Z:69e3a09e-c05b-4e48-809d-fb43bdfc80a2" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "392" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"name\": \"c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"resourceId\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"status\": \"Accepted\",\r\n \"startTime\": \"2020-10-12T19:31:01.2831719Z\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9sb2NhdGlvbnMvV0VTVFVTMi9vcGVyYXRpb25TdGF0dXNlcy9jMWMwMjAyZS1jYzhjLTQxMDMtOTMwMy1jMjhiMDJmZDg4YzI/YXBpLXZlcnNpb249MjAyMC0wMi0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:33:01 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"00005832-0000-0800-0000-5f84aef50000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11996" + ], + "x-ms-request-id": [ + "afa94d2b-49f6-41fb-8668-9f797f9d6c59" + ], + "x-ms-correlation-request-id": [ + "4822d18e-e360-4e74-b1e1-21aee79eb339" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193302Z:4822d18e-e360-4e74-b1e1-21aee79eb339" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "392" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"name\": \"c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"resourceId\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"status\": \"Accepted\",\r\n \"startTime\": \"2020-10-12T19:31:01.2831719Z\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9sb2NhdGlvbnMvV0VTVFVTMi9vcGVyYXRpb25TdGF0dXNlcy9jMWMwMjAyZS1jYzhjLTQxMDMtOTMwMy1jMjhiMDJmZDg4YzI/YXBpLXZlcnNpb249MjAyMC0wMi0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:33:32 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"00005832-0000-0800-0000-5f84aef50000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11995" + ], + "x-ms-request-id": [ + "a0da0c4d-2d18-4dd8-af3e-1d5a6f649144" + ], + "x-ms-correlation-request-id": [ + "0fb70e98-1fd5-411e-bb65-c2174601c4e6" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193332Z:0fb70e98-1fd5-411e-bb65-c2174601c4e6" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "392" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"name\": \"c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"resourceId\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"status\": \"Accepted\",\r\n \"startTime\": \"2020-10-12T19:31:01.2831719Z\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9sb2NhdGlvbnMvV0VTVFVTMi9vcGVyYXRpb25TdGF0dXNlcy9jMWMwMjAyZS1jYzhjLTQxMDMtOTMwMy1jMjhiMDJmZDg4YzI/YXBpLXZlcnNpb249MjAyMC0wMi0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:34:02 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"0000ce32-0000-0800-0000-5f84af990000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11994" + ], + "x-ms-request-id": [ + "7290112b-e3bd-4490-a934-a4745e940bef" + ], + "x-ms-correlation-request-id": [ + "34116b62-5056-46ca-9387-8eaece12fa6e" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193402Z:34116b62-5056-46ca-9387-8eaece12fa6e" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "422" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"name\": \"c1c0202e-cc8c-4103-9303-c28b02fd88c2\",\r\n \"resourceId\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"status\": \"Succeeded\",\r\n \"startTime\": \"2020-10-12T19:31:01.2831719Z\",\r\n \"error\": {},\r\n \"properties\": null\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL3Jlc291cmNlR3JvdXBzL2RhdGFkb2ctc2RrLXRlc3QtcmcxNjMwL3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9tb25pdG9ycy9kYXRhZG9nLXNkay10ZXN0LXJlc291cmNlODM1MD9hcGktdmVyc2lvbj0yMDIwLTAyLTAxLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:34:02 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"1b00a0d5-0000-0800-0000-5f84af990000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "c78a4d5c-79a9-4009-879d-bcffb381db0c" + ], + "x-ms-correlation-request-id": [ + "0468c9fc-d307-4005-8eab-d5475d132a33" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193403Z:0468c9fc-d307-4005-8eab-d5475d132a33" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "818" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"name\": \"datadog-sdk-test-resource8350\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"drawdown_testing_20200904_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"identity\": {\r\n \"principalId\": \"09875460-2a9c-4043-b6a7-f26a36c402f9\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"marketplaceSubscriptionStatus\": \"Active\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"datadog-sdk-test-resource8350\",\r\n \"id\": \"nyzb6bc67wtnmvjx\",\r\n \"linkingAuthCode\": null,\r\n \"linkingClientId\": null,\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL3Jlc291cmNlR3JvdXBzL2RhdGFkb2ctc2RrLXRlc3QtcmcxNjMwL3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9tb25pdG9ycy9kYXRhZG9nLXNkay10ZXN0LXJlc291cmNlODM1MD9hcGktdmVyc2lvbj0yMDIwLTAyLTAxLXByZXZpZXc=", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "f75699ff-2dcc-48fc-a006-64a3e1eb2955" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:34:03 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"1b0062d6-0000-0800-0000-5f84afac0000\"" + ], + "Location": [ + "https://management.azure.com/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/52819f24-c42b-4411-bc82-e518a4a994b1?api-version=2020-02-01-preview" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-deletes": [ + "14999" + ], + "x-ms-request-id": [ + "52819f24-c42b-4411-bc82-e518a4a994b1" + ], + "x-ms-correlation-request-id": [ + "dd7ed76f-ef3d-421e-9d77-7b88cef604fa" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193404Z:dd7ed76f-ef3d-421e-9d77-7b88cef604fa" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "817" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"name\": \"datadog-sdk-test-resource8350\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"drawdown_testing_20200904_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"identity\": {\r\n \"principalId\": \"09875460-2a9c-4043-b6a7-f26a36c402f9\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Deleting\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"marketplaceSubscriptionStatus\": \"Active\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"datadog-sdk-test-resource8350\",\r\n \"id\": \"nyzb6bc67wtnmvjx\",\r\n \"linkingAuthCode\": null,\r\n \"linkingClientId\": null,\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n}", + "StatusCode": 202 + }, + { + "RequestUri": "/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/52819f24-c42b-4411-bc82-e518a4a994b1?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9sb2NhdGlvbnMvV0VTVFVTMi9vcGVyYXRpb25TdGF0dXNlcy81MjgxOWYyNC1jNDJiLTQ0MTEtYmM4Mi1lNTE4YTRhOTk0YjE/YXBpLXZlcnNpb249MjAyMC0wMi0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:34:33 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"0000d332-0000-0800-0000-5f84afaf0000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11999" + ], + "x-ms-request-id": [ + "85fe7fef-5532-48df-8e99-0bec2a7ef1cb" + ], + "x-ms-correlation-request-id": [ + "62ea5233-9184-46a3-918e-fa5c6c2d15d9" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193434Z:62ea5233-9184-46a3-918e-fa5c6c2d15d9" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "422" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/52819f24-c42b-4411-bc82-e518a4a994b1\",\r\n \"name\": \"52819f24-c42b-4411-bc82-e518a4a994b1\",\r\n \"resourceId\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"status\": \"Succeeded\",\r\n \"startTime\": \"2020-10-12T19:34:03.6944091Z\",\r\n \"error\": {},\r\n \"properties\": null\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/52819f24-c42b-4411-bc82-e518a4a994b1?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9sb2NhdGlvbnMvV0VTVFVTMi9vcGVyYXRpb25TdGF0dXNlcy81MjgxOWYyNC1jNDJiLTQ0MTEtYmM4Mi1lNTE4YTRhOTk0YjE/YXBpLXZlcnNpb249MjAyMC0wMi0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:34:33 GMT" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"0000d332-0000-0800-0000-5f84afaf0000\"" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11998" + ], + "x-ms-request-id": [ + "086be8b7-e8bb-4bde-9b4a-6268e85f852e" + ], + "x-ms-correlation-request-id": [ + "568d44f8-ecb7-48bf-a820-a87a80be31db" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193434Z:568d44f8-ecb7-48bf-a820-a87a80be31db" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "422" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Datadog/locations/WESTUS2/operationStatuses/52819f24-c42b-4411-bc82-e518a4a994b1\",\r\n \"name\": \"52819f24-c42b-4411-bc82-e518a4a994b1\",\r\n \"resourceId\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg1630/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8350\",\r\n \"status\": \"Succeeded\",\r\n \"startTime\": \"2020-10-12T19:34:03.6944091Z\",\r\n \"error\": {},\r\n \"properties\": null\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/providers/Microsoft.Datadog/monitors?api-version=2020-02-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YWRvZy9tb25pdG9ycz9hcGktdmVyc2lvbj0yMDIwLTAyLTAxLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "56a71007-37a2-4b26-bfdd-c065af6c4e69" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Datadog.MicrosoftDatadogClient/0.1.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:34:34 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-original-request-ids": [ + "50533848-6d63-4161-852b-a32c73c19d05", + "53f8392c-d36d-4a4f-8305-86ad14d4c9d3" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "11b0ee3f-e469-46d0-be80-e8b1b5a8d3a7" + ], + "x-ms-correlation-request-id": [ + "11b0ee3f-e469-46d0-be80-e8b1b5a8d3a7" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193435Z:11b0ee3f-e469-46d0-be80-e8b1b5a8d3a7" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "8659" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/DatadogTest/providers/Microsoft.Datadog/monitors/test82420\",\r\n \"name\": \"test82420\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"datadog_private_preview_Monthly\"\r\n },\r\n \"location\": \"eastus2euap\",\r\n \"tags\": {},\r\n \"identity\": {\r\n \"principalId\": \"35f9ad10-10d8-47f7-ac99-817829e0fcca\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"test82420\",\r\n \"id\": \"t2xm9xdnl2gljgdd\",\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/DatadogTest/providers/Microsoft.Datadog/monitors/tset91720\",\r\n \"name\": \"tset91720\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"datadog_private_preview_Monthly\"\r\n },\r\n \"location\": \"eastus2euap\",\r\n \"tags\": {},\r\n \"identity\": {\r\n \"principalId\": \"4d2f5cef-0eed-46de-a683-2f8ae72bd51b\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"marketplaceSubscriptionStatus\": \"Active\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"tset91720\",\r\n \"id\": \"pln57qxyyloc10yb\",\r\n \"linkingAuthCode\": null,\r\n \"linkingClientId\": null,\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/DatadogTest/providers/Microsoft.Datadog/monitors/test82120\",\r\n \"name\": \"test82120\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"datadog_private_preview_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"tags\": {},\r\n \"identity\": {\r\n \"principalId\": \"2d5125d1-4418-41e6-89c6-b30c2b3c42e4\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"test82120\",\r\n \"id\": \"nqhi51axmaipfg4w\",\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/DatadogTest/providers/Microsoft.Datadog/monitors/test8212020\",\r\n \"name\": \"test8212020\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"datadog_private_preview_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"tags\": {},\r\n \"identity\": {\r\n \"principalId\": \"c878a4d7-af57-45fd-a46d-b31e9ef254ba\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"test8212020\",\r\n \"id\": \"1dynaa01tf0mlnd2\",\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/DatadogTest/providers/Microsoft.Datadog/monitors/t82120\",\r\n \"name\": \"t82120\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"datadog_private_preview_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"tags\": {},\r\n \"identity\": {\r\n \"principalId\": \"db562b9e-9a05-4e12-91c7-e021d474a554\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"t82120\",\r\n \"id\": \"etpprizmh7mz4tm1\",\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/DatadogTest/providers/Microsoft.Datadog/monitors/test81120\",\r\n \"name\": \"test81120\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"datadog_private_preview_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"tags\": {},\r\n \"identity\": {\r\n \"principalId\": \"c75a89f2-0373-48e8-ad9f-408fe89875a7\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"test81120\",\r\n \"id\": \"1lrvipm3p9efawth\",\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/DatadogTest/providers/Microsoft.Datadog/monitors/test826\",\r\n \"name\": \"test826\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"datadog_private_preview_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"tags\": {},\r\n \"identity\": {\r\n \"principalId\": \"2a40da6d-19a0-464a-a54d-ed31eb7b480d\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"test826\",\r\n \"id\": \"x6vm8qgp5jwombdg\",\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg152/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8168\",\r\n \"name\": \"datadog-sdk-test-resource8168\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"free_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"identity\": {\r\n \"principalId\": \"4894fc04-af06-4d75-b268-50cfe2e3ebe8\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"marketplaceSubscriptionStatus\": \"Active\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"datadog-sdk-test-resource8168\",\r\n \"id\": null,\r\n \"linkingAuthCode\": null,\r\n \"linkingClientId\": null,\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg6135/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource6165\",\r\n \"name\": \"datadog-sdk-test-resource6165\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"free_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"identity\": {\r\n \"principalId\": \"df3a34ba-909c-4e31-b563-46e4a4bd0955\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"marketplaceSubscriptionStatus\": \"Active\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"datadog-sdk-test-resource6165\",\r\n \"id\": null,\r\n \"linkingAuthCode\": null,\r\n \"linkingClientId\": null,\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg8604/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource7232\",\r\n \"name\": \"datadog-sdk-test-resource7232\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"free_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"identity\": {\r\n \"principalId\": \"8a23aba3-07a9-4c62-aa98-3b077f3336d1\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"marketplaceSubscriptionStatus\": \"Active\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"datadog-sdk-test-resource7232\",\r\n \"id\": null,\r\n \"linkingAuthCode\": null,\r\n \"linkingClientId\": null,\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg3946/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource8831\",\r\n \"name\": \"datadog-sdk-test-resource8831\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"Free_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"identity\": {\r\n \"principalId\": \"c79c0bad-edd2-4873-b0c9-7a3a8be14762\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"marketplaceSubscriptionStatus\": \"Active\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"datadog-sdk-test-resource8831\",\r\n \"id\": null,\r\n \"linkingAuthCode\": null,\r\n \"linkingClientId\": null,\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourceGroups/datadog-sdk-test-rg5851/providers/Microsoft.Datadog/monitors/datadog-sdk-test-resource3277\",\r\n \"name\": \"datadog-sdk-test-resource3277\",\r\n \"type\": \"Microsoft.Datadog/monitors\",\r\n \"sku\": {\r\n \"name\": \"Free_Monthly\"\r\n },\r\n \"location\": \"westus2\",\r\n \"identity\": {\r\n \"principalId\": \"d7105810-bbb7-4a39-90ae-4e2b718e2143\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"type\": \"SystemAssigned\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Failed\",\r\n \"monitoringStatus\": \"Enabled\",\r\n \"marketplaceSubscriptionStatus\": \"Active\",\r\n \"datadogOrganizationProperties\": {\r\n \"name\": \"datadog-sdk-test-resource3277\",\r\n \"id\": null,\r\n \"linkingAuthCode\": null,\r\n \"linkingClientId\": null,\r\n \"enterpriseAppId\": null\r\n },\r\n \"userInfo\": null,\r\n \"liftrResourceCategory\": \"MonitorLogs\",\r\n \"liftrResourcePreference\": 0\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/resourcegroups/datadog-sdk-test-rg1630?api-version=2015-11-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL3Jlc291cmNlZ3JvdXBzL2RhdGFkb2ctc2RrLXRlc3QtcmcxNjMwP2FwaS12ZXJzaW9uPTIwMTUtMTEtMDE=", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "756949b0-3972-4b12-b2ae-655d0de5e5d7" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Resources.ResourceManagementClient/1.0.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:34:35 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1EQVRBRE9HOjJEU0RLOjJEVEVTVDoyRFJHMTYzMC1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2015-11-01" + ], + "Retry-After": [ + "15" + ], + "x-ms-ratelimit-remaining-subscription-deletes": [ + "14999" + ], + "x-ms-request-id": [ + "6c2e9fe4-bde8-4d60-8fbb-a14414116677" + ], + "x-ms-correlation-request-id": [ + "6c2e9fe4-bde8-4d60-8fbb-a14414116677" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193436Z:6c2e9fe4-bde8-4d60-8fbb-a14414116677" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 202 + }, + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1EQVRBRE9HOjJEU0RLOjJEVEVTVDoyRFJHMTYzMC1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2015-11-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFFUVZSQlJFOUhPakpFVTBSTE9qSkVWRVZUVkRveVJGSkhNVFl6TUMxWFJWTlVWVk15SWl3aWFtOWlURzlqWVhScGIyNGlPaUozWlhOMGRYTXlJbjA/YXBpLXZlcnNpb249MjAxNS0xMS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Resources.ResourceManagementClient/1.0.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:34:50 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1EQVRBRE9HOjJEU0RLOjJEVEVTVDoyRFJHMTYzMC1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2015-11-01" + ], + "Retry-After": [ + "15" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "76e66806-4205-45ad-9d93-c354b3b7bb10" + ], + "x-ms-correlation-request-id": [ + "76e66806-4205-45ad-9d93-c354b3b7bb10" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193451Z:76e66806-4205-45ad-9d93-c354b3b7bb10" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 202 + }, + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1EQVRBRE9HOjJEU0RLOjJEVEVTVDoyRFJHMTYzMC1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2015-11-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFFUVZSQlJFOUhPakpFVTBSTE9qSkVWRVZUVkRveVJGSkhNVFl6TUMxWFJWTlVWVk15SWl3aWFtOWlURzlqWVhScGIyNGlPaUozWlhOMGRYTXlJbjA/YXBpLXZlcnNpb249MjAxNS0xMS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Resources.ResourceManagementClient/1.0.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:35:05 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1EQVRBRE9HOjJEU0RLOjJEVEVTVDoyRFJHMTYzMC1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2015-11-01" + ], + "Retry-After": [ + "15" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-request-id": [ + "51f0b984-1ec5-4fb0-8d84-0f2980e643a9" + ], + "x-ms-correlation-request-id": [ + "51f0b984-1ec5-4fb0-8d84-0f2980e643a9" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193506Z:51f0b984-1ec5-4fb0-8d84-0f2980e643a9" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 202 + }, + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1EQVRBRE9HOjJEU0RLOjJEVEVTVDoyRFJHMTYzMC1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2015-11-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFFUVZSQlJFOUhPakpFVTBSTE9qSkVWRVZUVkRveVJGSkhNVFl6TUMxWFJWTlVWVk15SWl3aWFtOWlURzlqWVhScGIyNGlPaUozWlhOMGRYTXlJbjA/YXBpLXZlcnNpb249MjAxNS0xMS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Resources.ResourceManagementClient/1.0.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:35:20 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11997" + ], + "x-ms-request-id": [ + "3ed7a9c5-a003-4c6d-b2db-39d92b010ee2" + ], + "x-ms-correlation-request-id": [ + "3ed7a9c5-a003-4c6d-b2db-39d92b010ee2" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193521Z:3ed7a9c5-a003-4c6d-b2db-39d92b010ee2" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/38916dd1-dbdc-4e79-8262-cc5727a8e96b/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1EQVRBRE9HOjJEU0RLOjJEVEVTVDoyRFJHMTYzMC1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2015-11-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMzg5MTZkZDEtZGJkYy00ZTc5LTgyNjItY2M1NzI3YThlOTZiL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFFUVZSQlJFOUhPakpFVTBSTE9qSkVWRVZUVkRveVJGSkhNVFl6TUMxWFJWTlVWVk15SWl3aWFtOWlURzlqWVhScGIyNGlPaUozWlhOMGRYTXlJbjA/YXBpLXZlcnNpb249MjAxNS0xMS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Resources.ResourceManagementClient/1.0.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 12 Oct 2020 19:35:20 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11996" + ], + "x-ms-request-id": [ + "b68ad2b9-7c54-4c84-824c-0f964e257963" + ], + "x-ms-correlation-request-id": [ + "b68ad2b9-7c54-4c84-824c-0f964e257963" + ], + "x-ms-routing-request-id": [ + "WESTUS:20201012T193521Z:b68ad2b9-7c54-4c84-824c-0f964e257963" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 200 + } + ], + "Names": { + "CreateName": [ + "datadog-sdk-test-rg1630", + "datadog-sdk-test-resource8350", + "default9152" + ] + }, + "Variables": { + "SubscriptionId": "38916dd1-dbdc-4e79-8262-cc5727a8e96b" + } +} \ No newline at end of file diff --git a/sdk/datadog/Microsoft.Azure.Management.Datadog/tests/Tests/DatadogTest.cs b/sdk/datadog/Microsoft.Azure.Management.Datadog/tests/Tests/DatadogTest.cs new file mode 100644 index 0000000000000..0503dc382a779 --- /dev/null +++ b/sdk/datadog/Microsoft.Azure.Management.Datadog/tests/Tests/DatadogTest.cs @@ -0,0 +1,96 @@ + +using Microsoft.Azure.Management.Datadog.Models; +using Microsoft.Azure.Management.Resources; +using Microsoft.Azure.Management.Resources.Models; +using Microsoft.Rest.Azure; +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; +using System; +using Xunit; + +namespace Microsoft.Azure.Management.Datadog.Tests +{ + public class DatadogTests + { + [Fact] + public void TestResourceLifeCycle() + { + using (var context = MockContext.Start(GetType())) + { + string rgName = CreateName("datadog-sdk-test-rg"); + string resourceName = CreateName("datadog-sdk-test-resource"); + + CreateResourceGroup(context, rgName); + DatadogMonitorResource rp = CreateResource(context, rgName, resourceName); + Assert.NotNull(rp); + + DeleteResource(context, rgName, resourceName); + AssertNoResource(context, rgName); + + DeleteResourceGroup(context, rgName); + } + } + + private ResourceGroup CreateResourceGroup(MockContext context, string rgName) + { + ResourceManagementClient client = GetResourceManagementClient(context); + return client.ResourceGroups.CreateOrUpdate( + rgName, + new ResourceGroup + { + Location = "westus2" + }); + } + + private void DeleteResourceGroup(MockContext context, string rgName) + { + ResourceManagementClient client = GetResourceManagementClient(context); + client.ResourceGroups.Delete(rgName); + } + + private DatadogMonitorResource CreateResource(MockContext context, string rgName, string resourceName) + { + MicrosoftDatadogClient client = GetDatadogManagementClient(context); + return client.Monitors.Create( + rgName, + resourceName, + new DatadogMonitorResource( + type: "Microsoft.Datadog/monitors", + location: "westus2", + sku: new ResourceSku("drawdown_testing_20200904_Monthly"), + identity: new IdentityProperties(type: "SystemAssigned"), + properties: new MonitorProperties(userInfo: new UserInfo(name: "Mama Baba", emailAddress: "liftrdevredmond@microsoft.com", phoneNumber: "+1 (425) 5381111")) + ) + ); + } + + private void DeleteResource(MockContext context, string rgName, string resourceName) + { + MicrosoftDatadogClient client = GetDatadogManagementClient(context); + client.Monitors.Delete(rgName, resourceName); + } + + private void AssertNoResource(MockContext context, string rgName) + { + IPage resources = ListResources(context, rgName); + Assert.Null(resources.GetEnumerator().Current); + } + + private IPage ListResources(MockContext context, string rgName) + { + MicrosoftDatadogClient client = GetDatadogManagementClient(context); + return client.Monitors.List(); + } + + private string CreateName(string prefix) => TestUtilities.GenerateName(prefix); + + private ResourceManagementClient GetResourceManagementClient(MockContext context) + { + return context.GetServiceClient(); + } + + private MicrosoftDatadogClient GetDatadogManagementClient(MockContext context) + { + return context.GetServiceClient(); + } + } +}