diff --git a/eng/mgmt/mgmtmetadata/automanage_resource-manager.txt b/eng/mgmt/mgmtmetadata/automanage_resource-manager.txt new file mode 100644 index 000000000000..5b9aa34f8314 --- /dev/null +++ b/eng/mgmt/mgmtmetadata/automanage_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 C:\Users\Stephen\AppData\Roaming\npm\autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/automanage/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=C:\git\stowen\azure-sdk-for-net\sdk +2020-09-03 04:30:29 UTC +Azure-rest-api-specs repository information +GitHub fork: Azure +Branch: master +Commit: 9ab0b5d07464e0235fb66832c24f31f1602f21b7 +AutoRest information +Requested version: v2 +Bootstrapper version: autorest@2.0.4413 diff --git a/eng/mgmt/mgmtmetadata/automation_resource-manager.txt b/eng/mgmt/mgmtmetadata/automation_resource-manager.txt new file mode 100644 index 000000000000..f2328b9d1995 --- /dev/null +++ b/eng/mgmt/mgmtmetadata/automation_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 C:\Users\Stephen\AppData\Roaming\npm\autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/automation/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=C:\git\stowen\azure-sdk-for-net\sdk +2020-08-27 17:25:35 UTC +Azure-rest-api-specs repository information +GitHub fork: Azure +Branch: master +Commit: bc1d3e6f1d19840375907101b30579c16c8a5d76 +AutoRest information +Requested version: v2 +Bootstrapper version: autorest@2.0.4413 diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/Microsoft.Azure.Management.AutoManage.sln b/sdk/automanage/Microsoft.Azure.Management.AutoManage/Microsoft.Azure.Management.AutoManage.sln new file mode 100644 index 000000000000..86eb7532b5a6 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/Microsoft.Azure.Management.AutoManage.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30225.117 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.AutoManage", "src\Microsoft.Azure.Management.AutoManage.csproj", "{729E0304-87FD-499C-A0EB-A9339D91A3FF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.AutoManage.Tests", "tests\Microsoft.Azure.Management.AutoManage.Tests.csproj", "{BF6E0BED-7C6B-47FF-82C1-AD40FE0350EA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {729E0304-87FD-499C-A0EB-A9339D91A3FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {729E0304-87FD-499C-A0EB-A9339D91A3FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {729E0304-87FD-499C-A0EB-A9339D91A3FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {729E0304-87FD-499C-A0EB-A9339D91A3FF}.Release|Any CPU.Build.0 = Release|Any CPU + {BF6E0BED-7C6B-47FF-82C1-AD40FE0350EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BF6E0BED-7C6B-47FF-82C1-AD40FE0350EA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BF6E0BED-7C6B-47FF-82C1-AD40FE0350EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BF6E0BED-7C6B-47FF-82C1-AD40FE0350EA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A29B8186-E93D-41BD-B5DB-55FCC7BCAB27} + EndGlobalSection +EndGlobal diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/AzSdk.RP.props b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/AzSdk.RP.props new file mode 100644 index 000000000000..49c92de420e0 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/AzSdk.RP.props @@ -0,0 +1,7 @@ + + + + AutoManage_0_1_0-preview;AutoManage_06_30_2020-preview; + $(PackageTags);$(CommonTags);$(AzureApiTag); + + \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/CHANGELOG.md b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/CHANGELOG.md new file mode 100644 index 000000000000..1e82b3895abf --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/CHANGELOG.md @@ -0,0 +1,11 @@ +# Microsoft.Azure.Management.Automanage release notes + +## Changes in 0.1.0-preview +### Features +Provides Microsoft Azure Automanage management operations including the ability to create, update and get Automanaged profile assignments, compliance statuses, automation accounts, and other related artifacts. + +### Bug fixes +None + +### REST API version +This version of the Automanage .NET client library targets version 2020-06-30-preview of the Azure Automanage REST API. \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/AccountsOperations.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/AccountsOperations.cs new file mode 100644 index 000000000000..0eb436d0d960 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/AccountsOperations.cs @@ -0,0 +1,1233 @@ +// +// 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.AutoManage +{ + 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; + + /// + /// AccountsOperations operations. + /// + internal partial class AccountsOperations : IServiceOperations, IAccountsOperations + { + /// + /// Initializes a new instance of the AccountsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AccountsOperations(AutomanageClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AutomanageClient + /// + public AutomanageClient Client { get; private set; } + + /// + /// Creates an Automanage Account + /// + /// + /// Name of the Automanage account. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update Automanage account. + /// + /// + /// 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 accountName, string resourceGroupName, Account parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + 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.Automanage/accounts/{accountName}").ToString(); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _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("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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Get information about a Automanage account + /// + /// + /// The Automanage account name. + /// + /// + /// The resource group 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 accountName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + 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.Automanage/accounts/{accountName}").ToString(); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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 Automanage account + /// + /// + /// The resource group name. + /// + /// + /// Name of the Automanage account + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", 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.Automanage/accounts/{accountName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _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("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 != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Updates an Automanage Account + /// + /// + /// Name of the Automanage account. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to update Automanage account. + /// + /// + /// 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 accountName, string resourceGroupName, Account parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + 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.Automanage/accounts/{accountName}").ToString(); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _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("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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Retrieve a list of Automanage accounts within a given resource group + /// + /// + /// The resource group 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>> 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 (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // 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.Automanage/accounts").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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Retrieve a list of Automanage accounts within a 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>> ListBySubscriptionWithHttpMessagesAsync(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"); + } + // 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, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Automanage/accounts").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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/AccountsOperationsExtensions.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/AccountsOperationsExtensions.cs new file mode 100644 index 000000000000..62d3491a58df --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/AccountsOperationsExtensions.cs @@ -0,0 +1,258 @@ +// +// 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.AutoManage +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AccountsOperations. + /// + public static partial class AccountsOperationsExtensions + { + /// + /// Creates an Automanage Account + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Automanage account. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update Automanage account. + /// + public static Account CreateOrUpdate(this IAccountsOperations operations, string accountName, string resourceGroupName, Account parameters) + { + return operations.CreateOrUpdateAsync(accountName, resourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates an Automanage Account + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Automanage account. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update Automanage account. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IAccountsOperations operations, string accountName, string resourceGroupName, Account parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(accountName, resourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get information about a Automanage account + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Automanage account name. + /// + /// + /// The resource group name. + /// + public static Account Get(this IAccountsOperations operations, string accountName, string resourceGroupName) + { + return operations.GetAsync(accountName, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get information about a Automanage account + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Automanage account name. + /// + /// + /// The resource group name. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAccountsOperations operations, string accountName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(accountName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a Automanage account + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// Name of the Automanage account + /// + public static void Delete(this IAccountsOperations operations, string resourceGroupName, string accountName) + { + operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Delete a Automanage account + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// Name of the Automanage account + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates an Automanage Account + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Automanage account. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to update Automanage account. + /// + public static Account Update(this IAccountsOperations operations, string accountName, string resourceGroupName, Account parameters) + { + return operations.UpdateAsync(accountName, resourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an Automanage Account + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Automanage account. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to update Automanage account. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAccountsOperations operations, string accountName, string resourceGroupName, Account parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(accountName, resourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve a list of Automanage accounts within a given resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + public static IEnumerable ListByResourceGroup(this IAccountsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve a list of Automanage accounts within a given resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IAccountsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve a list of Automanage accounts within a subscription + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable ListBySubscription(this IAccountsOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Retrieve a list of Automanage accounts within a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IAccountsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/AutomanageClient.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/AutomanageClient.cs new file mode 100644 index 000000000000..e0a3862134b6 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/AutomanageClient.cs @@ -0,0 +1,379 @@ +// +// 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.AutoManage +{ + 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; + + /// + /// Automanage Client + /// + public partial class AutomanageClient : ServiceClient, IAutomanageClient, 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; } + + /// + /// Client Api Version. + /// + public string ApiVersion { get; private set; } + + /// + /// Subscription ID which uniquely identify Microsoft Azure subscription. The + /// subscription ID forms part of the URI for every service call. + /// + public string SubscriptionId { get; 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 IAccountsOperations. + /// + public virtual IAccountsOperations Accounts { get; private set; } + + /// + /// Gets the IConfigurationProfileAssignmentsOperations. + /// + public virtual IConfigurationProfileAssignmentsOperations ConfigurationProfileAssignments { get; private set; } + + /// + /// Gets the IConfigurationProfilePreferencesOperations. + /// + public virtual IConfigurationProfilePreferencesOperations ConfigurationProfilePreferences { get; private set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Initializes a new instance of the AutomanageClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling AutomanageClient.Dispose(). False: will not dispose provided httpClient + protected AutomanageClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the AutomanageClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutomanageClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the AutomanageClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutomanageClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the AutomanageClient 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 AutomanageClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the AutomanageClient 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 AutomanageClient(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 AutomanageClient 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 AutomanageClient(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 AutomanageClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling AutomanageClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public AutomanageClient(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 AutomanageClient 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 AutomanageClient(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 AutomanageClient 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 AutomanageClient(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 AutomanageClient 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 AutomanageClient(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() + { + Accounts = new AccountsOperations(this); + ConfigurationProfileAssignments = new ConfigurationProfileAssignmentsOperations(this); + ConfigurationProfilePreferences = new ConfigurationProfilePreferencesOperations(this); + Operations = new Operations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2020-06-30-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() + } + }; + SerializationSettings.Converters.Add(new TransformationJsonConverter()); + 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 TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfileAssignmentsOperations.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfileAssignmentsOperations.cs new file mode 100644 index 000000000000..910d7cde3d67 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfileAssignmentsOperations.cs @@ -0,0 +1,1078 @@ +// +// 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.AutoManage +{ + 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; + + /// + /// ConfigurationProfileAssignmentsOperations operations. + /// + internal partial class ConfigurationProfileAssignmentsOperations : IServiceOperations, IConfigurationProfileAssignmentsOperations + { + /// + /// Initializes a new instance of the ConfigurationProfileAssignmentsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ConfigurationProfileAssignmentsOperations(AutomanageClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AutomanageClient + /// + public AutomanageClient Client { get; private set; } + + /// + /// Creates an association between a VM and Automanage configuration profile + /// + /// + /// Name of the configuration profile assignment. Only default is supported. + /// + /// + /// Parameters supplied to the create or update configuration profile + /// assignment. + /// + /// + /// The resource group name. + /// + /// + /// The name of the virtual machine. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string configurationProfileAssignmentName, ConfigurationProfileAssignment parameters, string resourceGroupName, string vmName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(configurationProfileAssignmentName, parameters, resourceGroupName, vmName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get information about a configuration profile assignment + /// + /// + /// The resource group name. + /// + /// + /// The configuration profile assignment name. + /// + /// + /// The name of the virtual machine. + /// + /// + /// 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 configurationProfileAssignmentName, string vmName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (configurationProfileAssignmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationProfileAssignmentName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (vmName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vmName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("configurationProfileAssignmentName", configurationProfileAssignmentName); + tracingParameters.Add("vmName", vmName); + 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.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{configurationProfileAssignmentName}", System.Uri.EscapeDataString(configurationProfileAssignmentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{vmName}", System.Uri.EscapeDataString(vmName)); + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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 configuration profile assignment + /// + /// + /// The resource group name. + /// + /// + /// Name of the configuration profile assignment + /// + /// + /// The name of the virtual machine. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string resourceGroupName, string configurationProfileAssignmentName, string vmName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (configurationProfileAssignmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationProfileAssignmentName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (vmName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vmName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("configurationProfileAssignmentName", configurationProfileAssignmentName); + tracingParameters.Add("vmName", vmName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", 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.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{configurationProfileAssignmentName}", System.Uri.EscapeDataString(configurationProfileAssignmentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{vmName}", System.Uri.EscapeDataString(vmName)); + 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 != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Get list of configuration profile assignments + /// + /// + /// The resource group 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, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // 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, "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.Automanage/configurationProfileAssignments").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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 list of configuration profile assignments under a given 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>> ListBySubscriptionWithHttpMessagesAsync(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"); + } + // 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, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments").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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Creates an association between a VM and Automanage configuration profile + /// + /// + /// Name of the configuration profile assignment. Only default is supported. + /// + /// + /// Parameters supplied to the create or update configuration profile + /// assignment. + /// + /// + /// The resource group name. + /// + /// + /// The name of the virtual machine. + /// + /// + /// 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 configurationProfileAssignmentName, ConfigurationProfileAssignment parameters, string resourceGroupName, string vmName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (configurationProfileAssignmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationProfileAssignmentName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (vmName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vmName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("configurationProfileAssignmentName", configurationProfileAssignmentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("vmName", vmName); + 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.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}").ToString(); + _url = _url.Replace("{configurationProfileAssignmentName}", System.Uri.EscapeDataString(configurationProfileAssignmentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{vmName}", System.Uri.EscapeDataString(vmName)); + 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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfileAssignmentsOperationsExtensions.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfileAssignmentsOperationsExtensions.cs new file mode 100644 index 000000000000..70e2ac4b6c6d --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfileAssignmentsOperationsExtensions.cs @@ -0,0 +1,286 @@ +// +// 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.AutoManage +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ConfigurationProfileAssignmentsOperations. + /// + public static partial class ConfigurationProfileAssignmentsOperationsExtensions + { + /// + /// Creates an association between a VM and Automanage configuration profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the configuration profile assignment. Only default is supported. + /// + /// + /// Parameters supplied to the create or update configuration profile + /// assignment. + /// + /// + /// The resource group name. + /// + /// + /// The name of the virtual machine. + /// + public static ConfigurationProfileAssignment CreateOrUpdate(this IConfigurationProfileAssignmentsOperations operations, string configurationProfileAssignmentName, ConfigurationProfileAssignment parameters, string resourceGroupName, string vmName) + { + return operations.CreateOrUpdateAsync(configurationProfileAssignmentName, parameters, resourceGroupName, vmName).GetAwaiter().GetResult(); + } + + /// + /// Creates an association between a VM and Automanage configuration profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the configuration profile assignment. Only default is supported. + /// + /// + /// Parameters supplied to the create or update configuration profile + /// assignment. + /// + /// + /// The resource group name. + /// + /// + /// The name of the virtual machine. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IConfigurationProfileAssignmentsOperations operations, string configurationProfileAssignmentName, ConfigurationProfileAssignment parameters, string resourceGroupName, string vmName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(configurationProfileAssignmentName, parameters, resourceGroupName, vmName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get information about a configuration profile assignment + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// The configuration profile assignment name. + /// + /// + /// The name of the virtual machine. + /// + public static ConfigurationProfileAssignment Get(this IConfigurationProfileAssignmentsOperations operations, string resourceGroupName, string configurationProfileAssignmentName, string vmName) + { + return operations.GetAsync(resourceGroupName, configurationProfileAssignmentName, vmName).GetAwaiter().GetResult(); + } + + /// + /// Get information about a configuration profile assignment + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// The configuration profile assignment name. + /// + /// + /// The name of the virtual machine. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IConfigurationProfileAssignmentsOperations operations, string resourceGroupName, string configurationProfileAssignmentName, string vmName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, configurationProfileAssignmentName, vmName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a configuration profile assignment + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// Name of the configuration profile assignment + /// + /// + /// The name of the virtual machine. + /// + public static void Delete(this IConfigurationProfileAssignmentsOperations operations, string resourceGroupName, string configurationProfileAssignmentName, string vmName) + { + operations.DeleteAsync(resourceGroupName, configurationProfileAssignmentName, vmName).GetAwaiter().GetResult(); + } + + /// + /// Delete a configuration profile assignment + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// Name of the configuration profile assignment + /// + /// + /// The name of the virtual machine. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IConfigurationProfileAssignmentsOperations operations, string resourceGroupName, string configurationProfileAssignmentName, string vmName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, configurationProfileAssignmentName, vmName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Get list of configuration profile assignments + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + public static IEnumerable List(this IConfigurationProfileAssignmentsOperations operations, string resourceGroupName) + { + return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get list of configuration profile assignments + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IConfigurationProfileAssignmentsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get list of configuration profile assignments under a given subscription + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable ListBySubscription(this IConfigurationProfileAssignmentsOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Get list of configuration profile assignments under a given subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IConfigurationProfileAssignmentsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates an association between a VM and Automanage configuration profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the configuration profile assignment. Only default is supported. + /// + /// + /// Parameters supplied to the create or update configuration profile + /// assignment. + /// + /// + /// The resource group name. + /// + /// + /// The name of the virtual machine. + /// + public static ConfigurationProfileAssignment BeginCreateOrUpdate(this IConfigurationProfileAssignmentsOperations operations, string configurationProfileAssignmentName, ConfigurationProfileAssignment parameters, string resourceGroupName, string vmName) + { + return operations.BeginCreateOrUpdateAsync(configurationProfileAssignmentName, parameters, resourceGroupName, vmName).GetAwaiter().GetResult(); + } + + /// + /// Creates an association between a VM and Automanage configuration profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the configuration profile assignment. Only default is supported. + /// + /// + /// Parameters supplied to the create or update configuration profile + /// assignment. + /// + /// + /// The resource group name. + /// + /// + /// The name of the virtual machine. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IConfigurationProfileAssignmentsOperations operations, string configurationProfileAssignmentName, ConfigurationProfileAssignment parameters, string resourceGroupName, string vmName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(configurationProfileAssignmentName, parameters, resourceGroupName, vmName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfilePreferencesOperations.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfilePreferencesOperations.cs new file mode 100644 index 000000000000..74f6228a227f --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfilePreferencesOperations.cs @@ -0,0 +1,1234 @@ +// +// 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.AutoManage +{ + 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; + + /// + /// ConfigurationProfilePreferencesOperations operations. + /// + internal partial class ConfigurationProfilePreferencesOperations : IServiceOperations, IConfigurationProfilePreferencesOperations + { + /// + /// Initializes a new instance of the ConfigurationProfilePreferencesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ConfigurationProfilePreferencesOperations(AutomanageClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AutomanageClient + /// + public AutomanageClient Client { get; private set; } + + /// + /// Creates a configuration profile preference + /// + /// + /// Name of the configuration profile preference. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update configuration profile preference. + /// + /// + /// 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 configurationProfilePreferenceName, string resourceGroupName, ConfigurationProfilePreference parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (configurationProfilePreferenceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationProfilePreferenceName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("configurationProfilePreferenceName", configurationProfilePreferenceName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + 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.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}").ToString(); + _url = _url.Replace("{configurationProfilePreferenceName}", System.Uri.EscapeDataString(configurationProfilePreferenceName)); + _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("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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Get information about a configuration profile preference + /// + /// + /// The configuration profile preference name. + /// + /// + /// The resource group 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 configurationProfilePreferenceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (configurationProfilePreferenceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationProfilePreferenceName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("configurationProfilePreferenceName", configurationProfilePreferenceName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + 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.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}").ToString(); + _url = _url.Replace("{configurationProfilePreferenceName}", System.Uri.EscapeDataString(configurationProfilePreferenceName)); + _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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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 configuration profile preference + /// + /// + /// The resource group name. + /// + /// + /// Name of the configuration profile preference + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string resourceGroupName, string configurationProfilePreferenceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (configurationProfilePreferenceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationProfilePreferenceName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("configurationProfilePreferenceName", configurationProfilePreferenceName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", 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.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{configurationProfilePreferenceName}", System.Uri.EscapeDataString(configurationProfilePreferenceName)); + _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("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 != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Updates a configuration profile preference + /// + /// + /// Name of the configuration profile preference. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update configuration profile preference. + /// + /// + /// 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 configurationProfilePreferenceName, string resourceGroupName, ConfigurationProfilePreference parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (configurationProfilePreferenceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationProfilePreferenceName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("configurationProfilePreferenceName", configurationProfilePreferenceName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + 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.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}").ToString(); + _url = _url.Replace("{configurationProfilePreferenceName}", System.Uri.EscapeDataString(configurationProfilePreferenceName)); + _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("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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Retrieve a list of configuration profile preferences within a given + /// resource group + /// + /// + /// The resource group 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>> 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 (resourceGroupName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // 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.Automanage/configurationProfilePreferences").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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Retrieve a list of configuration profile preferences within a 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>> ListBySubscriptionWithHttpMessagesAsync(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"); + } + // 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, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfilePreferences").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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfilePreferencesOperationsExtensions.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfilePreferencesOperationsExtensions.cs new file mode 100644 index 000000000000..08132cc2048c --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/ConfigurationProfilePreferencesOperationsExtensions.cs @@ -0,0 +1,260 @@ +// +// 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.AutoManage +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ConfigurationProfilePreferencesOperations. + /// + public static partial class ConfigurationProfilePreferencesOperationsExtensions + { + /// + /// Creates a configuration profile preference + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the configuration profile preference. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update configuration profile preference. + /// + public static ConfigurationProfilePreference CreateOrUpdate(this IConfigurationProfilePreferencesOperations operations, string configurationProfilePreferenceName, string resourceGroupName, ConfigurationProfilePreference parameters) + { + return operations.CreateOrUpdateAsync(configurationProfilePreferenceName, resourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a configuration profile preference + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the configuration profile preference. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update configuration profile preference. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IConfigurationProfilePreferencesOperations operations, string configurationProfilePreferenceName, string resourceGroupName, ConfigurationProfilePreference parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(configurationProfilePreferenceName, resourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get information about a configuration profile preference + /// + /// + /// The operations group for this extension method. + /// + /// + /// The configuration profile preference name. + /// + /// + /// The resource group name. + /// + public static ConfigurationProfilePreference Get(this IConfigurationProfilePreferencesOperations operations, string configurationProfilePreferenceName, string resourceGroupName) + { + return operations.GetAsync(configurationProfilePreferenceName, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get information about a configuration profile preference + /// + /// + /// The operations group for this extension method. + /// + /// + /// The configuration profile preference name. + /// + /// + /// The resource group name. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IConfigurationProfilePreferencesOperations operations, string configurationProfilePreferenceName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(configurationProfilePreferenceName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a configuration profile preference + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// Name of the configuration profile preference + /// + public static void Delete(this IConfigurationProfilePreferencesOperations operations, string resourceGroupName, string configurationProfilePreferenceName) + { + operations.DeleteAsync(resourceGroupName, configurationProfilePreferenceName).GetAwaiter().GetResult(); + } + + /// + /// Delete a configuration profile preference + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// Name of the configuration profile preference + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IConfigurationProfilePreferencesOperations operations, string resourceGroupName, string configurationProfilePreferenceName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, configurationProfilePreferenceName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates a configuration profile preference + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the configuration profile preference. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update configuration profile preference. + /// + public static ConfigurationProfilePreference Update(this IConfigurationProfilePreferencesOperations operations, string configurationProfilePreferenceName, string resourceGroupName, ConfigurationProfilePreference parameters) + { + return operations.UpdateAsync(configurationProfilePreferenceName, resourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a configuration profile preference + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the configuration profile preference. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update configuration profile preference. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IConfigurationProfilePreferencesOperations operations, string configurationProfilePreferenceName, string resourceGroupName, ConfigurationProfilePreference parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(configurationProfilePreferenceName, resourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve a list of configuration profile preferences within a given + /// resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + public static IEnumerable ListByResourceGroup(this IConfigurationProfilePreferencesOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve a list of configuration profile preferences within a given + /// resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IConfigurationProfilePreferencesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve a list of configuration profile preferences within a subscription + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable ListBySubscription(this IConfigurationProfilePreferencesOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Retrieve a list of configuration profile preferences within a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IConfigurationProfilePreferencesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IAccountsOperations.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IAccountsOperations.cs new file mode 100644 index 000000000000..9e2be4f69360 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IAccountsOperations.cs @@ -0,0 +1,172 @@ +// +// 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.AutoManage +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AccountsOperations operations. + /// + public partial interface IAccountsOperations + { + /// + /// Creates an Automanage Account + /// + /// + /// Name of the Automanage account. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update Automanage account. + /// + /// + /// 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 accountName, string resourceGroupName, Account parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get information about a Automanage account + /// + /// + /// The Automanage account name. + /// + /// + /// The resource group 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 accountName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a Automanage account + /// + /// + /// The resource group name. + /// + /// + /// Name of the Automanage account + /// + /// + /// 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 accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an Automanage Account + /// + /// + /// Name of the Automanage account. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to update Automanage account. + /// + /// + /// 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 accountName, string resourceGroupName, Account parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve a list of Automanage accounts within a given resource + /// group + /// + /// + /// The resource group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve a list of Automanage accounts within a 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>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IAutomanageClient.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IAutomanageClient.cs new file mode 100644 index 000000000000..8673fc530a20 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IAutomanageClient.cs @@ -0,0 +1,95 @@ +// +// 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.AutoManage +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Automanage Client + /// + public partial interface IAutomanageClient : 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; } + + /// + /// Client Api Version. + /// + string ApiVersion { get; } + + /// + /// Subscription ID which uniquely identify Microsoft Azure + /// subscription. The subscription ID forms part of the URI for every + /// service call. + /// + string SubscriptionId { get; set; } + + /// + /// 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 IAccountsOperations. + /// + IAccountsOperations Accounts { get; } + + /// + /// Gets the IConfigurationProfileAssignmentsOperations. + /// + IConfigurationProfileAssignmentsOperations ConfigurationProfileAssignments { get; } + + /// + /// Gets the IConfigurationProfilePreferencesOperations. + /// + IConfigurationProfilePreferencesOperations ConfigurationProfilePreferences { get; } + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IConfigurationProfileAssignmentsOperations.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IConfigurationProfileAssignmentsOperations.cs new file mode 100644 index 000000000000..c6cc880589b4 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IConfigurationProfileAssignmentsOperations.cs @@ -0,0 +1,190 @@ +// +// 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.AutoManage +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ConfigurationProfileAssignmentsOperations operations. + /// + public partial interface IConfigurationProfileAssignmentsOperations + { + /// + /// Creates an association between a VM and Automanage configuration + /// profile + /// + /// + /// Name of the configuration profile assignment. Only default is + /// supported. + /// + /// + /// Parameters supplied to the create or update configuration profile + /// assignment. + /// + /// + /// The resource group name. + /// + /// + /// The name of the virtual machine. + /// + /// + /// 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 configurationProfileAssignmentName, ConfigurationProfileAssignment parameters, string resourceGroupName, string vmName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get information about a configuration profile assignment + /// + /// + /// The resource group name. + /// + /// + /// The configuration profile assignment name. + /// + /// + /// The name of the virtual machine. + /// + /// + /// 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 configurationProfileAssignmentName, string vmName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a configuration profile assignment + /// + /// + /// The resource group name. + /// + /// + /// Name of the configuration profile assignment + /// + /// + /// The name of the virtual machine. + /// + /// + /// 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 configurationProfileAssignmentName, string vmName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get list of configuration profile assignments + /// + /// + /// The resource group 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, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get list of configuration profile assignments under a given + /// 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>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates an association between a VM and Automanage configuration + /// profile + /// + /// + /// Name of the configuration profile assignment. Only default is + /// supported. + /// + /// + /// Parameters supplied to the create or update configuration profile + /// assignment. + /// + /// + /// The resource group name. + /// + /// + /// The name of the virtual machine. + /// + /// + /// 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 configurationProfileAssignmentName, ConfigurationProfileAssignment parameters, string resourceGroupName, string vmName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IConfigurationProfilePreferencesOperations.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IConfigurationProfilePreferencesOperations.cs new file mode 100644 index 000000000000..869dcca17b2d --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IConfigurationProfilePreferencesOperations.cs @@ -0,0 +1,175 @@ +// +// 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.AutoManage +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ConfigurationProfilePreferencesOperations operations. + /// + public partial interface IConfigurationProfilePreferencesOperations + { + /// + /// Creates a configuration profile preference + /// + /// + /// Name of the configuration profile preference. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update configuration profile + /// preference. + /// + /// + /// 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 configurationProfilePreferenceName, string resourceGroupName, ConfigurationProfilePreference parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get information about a configuration profile preference + /// + /// + /// The configuration profile preference name. + /// + /// + /// The resource group 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 configurationProfilePreferenceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a configuration profile preference + /// + /// + /// The resource group name. + /// + /// + /// Name of the configuration profile preference + /// + /// + /// 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 configurationProfilePreferenceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a configuration profile preference + /// + /// + /// Name of the configuration profile preference. + /// + /// + /// The resource group name. + /// + /// + /// Parameters supplied to create or update configuration profile + /// preference. + /// + /// + /// 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 configurationProfilePreferenceName, string resourceGroupName, ConfigurationProfilePreference parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve a list of configuration profile preferences within a given + /// resource group + /// + /// + /// The resource group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve a list of configuration profile preferences within a + /// 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>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IOperations.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IOperations.cs new file mode 100644 index 000000000000..939de59a26d9 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/IOperations.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.AutoManage +{ + 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 + { + /// + /// Lists all of the available Automanage REST API operations. + /// + /// + /// 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)); + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Account.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Account.cs new file mode 100644 index 000000000000..1ed4b721ab22 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Account.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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Definition of the Automanage account. + /// + public partial class Account : TrackedResource + { + /// + /// Initializes a new instance of the Account class. + /// + public Account() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Account class. + /// + /// ARM resource id of the Automanage + /// assignment. + /// Name of the Automanage assignment. + /// Region where the VM is located. + /// The type of the resource. + /// Resource tags. + /// The identity of the Automanage + /// account. + public Account(string id = default(string), string name = default(string), string location = default(string), string type = default(string), IDictionary tags = default(IDictionary), AccountIdentity identity = default(AccountIdentity)) + : base(id, name, location, type, tags) + { + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity of the Automanage account. + /// + [JsonProperty(PropertyName = "identity")] + public AccountIdentity Identity { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/AccountIdentity.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/AccountIdentity.cs new file mode 100644 index 000000000000..720dc3bfa659 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/AccountIdentity.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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Identity for the Automanage account. + /// + public partial class AccountIdentity + { + /// + /// Initializes a new instance of the AccountIdentity class. + /// + public AccountIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AccountIdentity class. + /// + /// The principal id of Automanage account + /// identity. + /// The tenant id associated with the Automanage + /// account. + /// The type of identity used for the Automanage + /// account. Currently, the only supported type is 'SystemAssigned', + /// which implicitly creates an identity. Possible values include: + /// 'SystemAssigned', 'None' + public AccountIdentity(string principalId = default(string), string tenantId = default(string), ResourceIdentityType? type = default(ResourceIdentityType?)) + { + PrincipalId = principalId; + TenantId = tenantId; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the principal id of Automanage account identity. + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; private set; } + + /// + /// Gets the tenant id associated with the Automanage account. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets or sets the type of identity used for the Automanage account. + /// Currently, the only supported type is 'SystemAssigned', which + /// implicitly creates an identity. Possible values include: + /// 'SystemAssigned', 'None' + /// + [JsonProperty(PropertyName = "type")] + public ResourceIdentityType? Type { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfile.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfile.cs new file mode 100644 index 000000000000..0fc309ed5c30 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfile.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.AutoManage.Models +{ + + /// + /// Defines values for ConfigurationProfile. + /// + public static class ConfigurationProfile + { + public const string AzureBestPracticesTestDev = "Azure Best Practices - TestDev"; + public const string AzureBestPracticesProd = "Azure Best Practices - Prod"; + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfileAssignment.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfileAssignment.cs new file mode 100644 index 000000000000..a2fd67eb0c73 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfileAssignment.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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Configuration profile assignment is an association between a VM and + /// automanage profile configuration. + /// + public partial class ConfigurationProfileAssignment : ProxyResource + { + /// + /// Initializes a new instance of the ConfigurationProfileAssignment + /// class. + /// + public ConfigurationProfileAssignment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ConfigurationProfileAssignment + /// class. + /// + /// ARM resource id of the Automanage + /// assignment. + /// Name of the Automanage assignment. + /// Region where the VM is located. + /// The type of the resource. + /// Properties of the configuration profile + /// assignment. + public ConfigurationProfileAssignment(string id = default(string), string name = default(string), string location = default(string), string type = default(string), ConfigurationProfileAssignmentProperties properties = default(ConfigurationProfileAssignmentProperties)) + : base(id, name, location, type) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets properties of the configuration profile assignment. + /// + [JsonProperty(PropertyName = "properties")] + public ConfigurationProfileAssignmentProperties Properties { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfileAssignmentCompliance.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfileAssignmentCompliance.cs new file mode 100644 index 000000000000..2218901daa7c --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfileAssignmentCompliance.cs @@ -0,0 +1,56 @@ +// +// 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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The compliance status for the configuration profile assignment. + /// + public partial class ConfigurationProfileAssignmentCompliance + { + /// + /// Initializes a new instance of the + /// ConfigurationProfileAssignmentCompliance class. + /// + public ConfigurationProfileAssignmentCompliance() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ConfigurationProfileAssignmentCompliance class. + /// + /// The state of compliance, which only + /// appears in the response. Possible values include: 'Succeeded', + /// 'Failed', 'Created' + public ConfigurationProfileAssignmentCompliance(string updateStatus = default(string)) + { + UpdateStatus = updateStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the state of compliance, which only appears in the response. + /// Possible values include: 'Succeeded', 'Failed', 'Created' + /// + [JsonProperty(PropertyName = "updateStatus")] + public string UpdateStatus { get; private set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfileAssignmentProperties.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfileAssignmentProperties.cs new file mode 100644 index 000000000000..d0f436b056c5 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfileAssignmentProperties.cs @@ -0,0 +1,105 @@ +// +// 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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Automanage configuration profile assignment properties. + /// + public partial class ConfigurationProfileAssignmentProperties + { + /// + /// Initializes a new instance of the + /// ConfigurationProfileAssignmentProperties class. + /// + public ConfigurationProfileAssignmentProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ConfigurationProfileAssignmentProperties class. + /// + /// A value indicating configuration + /// profile. Possible values include: 'Azure Best Practices - TestDev', + /// 'Azure Best Practices - Prod' + /// The target VM resource URI + /// The Automanage account ARM Resource + /// URI + /// The configuration + /// profile custom preferences ARM resource URI + /// The state of onboarding, which + /// only appears in the response. Possible values include: 'Succeeded', + /// 'Failed', 'Created' + /// The configuration setting for the + /// configuration profile. + public ConfigurationProfileAssignmentProperties(string configurationProfile = default(string), string targetId = default(string), string accountId = default(string), string configurationProfilePreferenceId = default(string), string provisioningStatus = default(string), ConfigurationProfileAssignmentCompliance compliance = default(ConfigurationProfileAssignmentCompliance)) + { + ConfigurationProfile = configurationProfile; + TargetId = targetId; + AccountId = accountId; + ConfigurationProfilePreferenceId = configurationProfilePreferenceId; + ProvisioningStatus = provisioningStatus; + Compliance = compliance; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a value indicating configuration profile. Possible + /// values include: 'Azure Best Practices - TestDev', 'Azure Best + /// Practices - Prod' + /// + [JsonProperty(PropertyName = "configurationProfile")] + public string ConfigurationProfile { get; set; } + + /// + /// Gets or sets the target VM resource URI + /// + [JsonProperty(PropertyName = "targetId")] + public string TargetId { get; set; } + + /// + /// Gets or sets the Automanage account ARM Resource URI + /// + [JsonProperty(PropertyName = "accountId")] + public string AccountId { get; set; } + + /// + /// Gets or sets the configuration profile custom preferences ARM + /// resource URI + /// + [JsonProperty(PropertyName = "configurationProfilePreferenceId")] + public string ConfigurationProfilePreferenceId { get; set; } + + /// + /// Gets the state of onboarding, which only appears in the response. + /// Possible values include: 'Succeeded', 'Failed', 'Created' + /// + [JsonProperty(PropertyName = "provisioningStatus")] + public string ProvisioningStatus { get; private set; } + + /// + /// Gets or sets the configuration setting for the configuration + /// profile. + /// + [JsonProperty(PropertyName = "compliance")] + public ConfigurationProfileAssignmentCompliance Compliance { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreference.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreference.cs new file mode 100644 index 000000000000..5adfba65333e --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreference.cs @@ -0,0 +1,63 @@ +// +// 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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Definition of the configuration profile preference. + /// + public partial class ConfigurationProfilePreference : TrackedResource + { + /// + /// Initializes a new instance of the ConfigurationProfilePreference + /// class. + /// + public ConfigurationProfilePreference() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ConfigurationProfilePreference + /// class. + /// + /// ARM resource id of the Automanage + /// assignment. + /// Name of the Automanage assignment. + /// Region where the VM is located. + /// The type of the resource. + /// Resource tags. + /// Properties of the configuration profile + /// preference. + public ConfigurationProfilePreference(string id = default(string), string name = default(string), string location = default(string), string type = default(string), IDictionary tags = default(IDictionary), ConfigurationProfilePreferenceProperties properties = default(ConfigurationProfilePreferenceProperties)) + : base(id, name, location, type, tags) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets properties of the configuration profile preference. + /// + [JsonProperty(PropertyName = "properties")] + public ConfigurationProfilePreferenceProperties Properties { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreferenceAntiMalware.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreferenceAntiMalware.cs new file mode 100644 index 000000000000..71e30fe9469a --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreferenceAntiMalware.cs @@ -0,0 +1,101 @@ +// +// 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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Automanage configuration profile Antimalware preferences. + /// + public partial class ConfigurationProfilePreferenceAntiMalware + { + /// + /// Initializes a new instance of the + /// ConfigurationProfilePreferenceAntiMalware class. + /// + public ConfigurationProfilePreferenceAntiMalware() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ConfigurationProfilePreferenceAntiMalware class. + /// + /// Enables or disables Real + /// Time Protection. Possible values include: 'True', 'False' + /// Extensions, Paths and Processes that must + /// be excluded from scan + /// Enables or disables a periodic scan + /// for antimalware. Possible values include: 'True', 'False' + /// Type of scheduled scan. Possible values + /// include: 'Quick', 'Full' + /// Schedule scan settings day + /// Schedule scan settings time + public ConfigurationProfilePreferenceAntiMalware(string enableRealTimeProtection = default(string), object exclusions = default(object), string runScheduledScan = default(string), string scanType = default(string), string scanDay = default(string), string scanTimeInMinutes = default(string)) + { + EnableRealTimeProtection = enableRealTimeProtection; + Exclusions = exclusions; + RunScheduledScan = runScheduledScan; + ScanType = scanType; + ScanDay = scanDay; + ScanTimeInMinutes = scanTimeInMinutes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables or disables Real Time Protection. Possible + /// values include: 'True', 'False' + /// + [JsonProperty(PropertyName = "enableRealTimeProtection")] + public string EnableRealTimeProtection { get; set; } + + /// + /// Gets or sets extensions, Paths and Processes that must be excluded + /// from scan + /// + [JsonProperty(PropertyName = "exclusions")] + public object Exclusions { get; set; } + + /// + /// Gets or sets enables or disables a periodic scan for antimalware. + /// Possible values include: 'True', 'False' + /// + [JsonProperty(PropertyName = "runScheduledScan")] + public string RunScheduledScan { get; set; } + + /// + /// Gets or sets type of scheduled scan. Possible values include: + /// 'Quick', 'Full' + /// + [JsonProperty(PropertyName = "scanType")] + public string ScanType { get; set; } + + /// + /// Gets or sets schedule scan settings day + /// + [JsonProperty(PropertyName = "scanDay")] + public string ScanDay { get; set; } + + /// + /// Gets or sets schedule scan settings time + /// + [JsonProperty(PropertyName = "scanTimeInMinutes")] + public string ScanTimeInMinutes { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreferenceProperties.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreferenceProperties.cs new file mode 100644 index 000000000000..af1f2d7bb7f2 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreferenceProperties.cs @@ -0,0 +1,63 @@ +// +// 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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Automanage configuration profile preference properties. + /// + public partial class ConfigurationProfilePreferenceProperties + { + /// + /// Initializes a new instance of the + /// ConfigurationProfilePreferenceProperties class. + /// + public ConfigurationProfilePreferenceProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ConfigurationProfilePreferenceProperties class. + /// + /// The custom preferences for Azure VM + /// Backup. + /// The custom preferences for Azure + /// Antimalware. + public ConfigurationProfilePreferenceProperties(ConfigurationProfilePreferenceVmBackup vmBackup = default(ConfigurationProfilePreferenceVmBackup), ConfigurationProfilePreferenceAntiMalware antiMalware = default(ConfigurationProfilePreferenceAntiMalware)) + { + VmBackup = vmBackup; + AntiMalware = antiMalware; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the custom preferences for Azure VM Backup. + /// + [JsonProperty(PropertyName = "vmBackup")] + public ConfigurationProfilePreferenceVmBackup VmBackup { get; set; } + + /// + /// Gets or sets the custom preferences for Azure Antimalware. + /// + [JsonProperty(PropertyName = "antiMalware")] + public ConfigurationProfilePreferenceAntiMalware AntiMalware { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreferenceVmBackup.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreferenceVmBackup.cs new file mode 100644 index 000000000000..921c6dcb14d3 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ConfigurationProfilePreferenceVmBackup.cs @@ -0,0 +1,83 @@ +// +// 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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Automanage configuration profile VM Backup preferences. + /// + public partial class ConfigurationProfilePreferenceVmBackup + { + /// + /// Initializes a new instance of the + /// ConfigurationProfilePreferenceVmBackup class. + /// + public ConfigurationProfilePreferenceVmBackup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ConfigurationProfilePreferenceVmBackup class. + /// + /// TimeZone optional input as string. For + /// example: Pacific Standard Time + /// Instant RP retention + /// policy range in days + /// Retention policy with the details on + /// backup copy retention ranges. + /// Backup schedule specified as part of + /// backup policy. + public ConfigurationProfilePreferenceVmBackup(string timeZone = default(string), int? instantRpRetentionRangeInDays = default(int?), string retentionPolicy = default(string), string schedulePolicy = default(string)) + { + TimeZone = timeZone; + InstantRpRetentionRangeInDays = instantRpRetentionRangeInDays; + RetentionPolicy = retentionPolicy; + SchedulePolicy = schedulePolicy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets timeZone optional input as string. For example: + /// Pacific Standard Time + /// + [JsonProperty(PropertyName = "timeZone")] + public string TimeZone { get; set; } + + /// + /// Gets or sets instant RP retention policy range in days + /// + [JsonProperty(PropertyName = "instantRpRetentionRangeInDays")] + public int? InstantRpRetentionRangeInDays { get; set; } + + /// + /// Gets or sets retention policy with the details on backup copy + /// retention ranges. + /// + [JsonProperty(PropertyName = "retentionPolicy")] + public string RetentionPolicy { get; set; } + + /// + /// Gets or sets backup schedule specified as part of backup policy. + /// + [JsonProperty(PropertyName = "schedulePolicy")] + public string SchedulePolicy { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/EnableRealTimeProtection.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/EnableRealTimeProtection.cs new file mode 100644 index 000000000000..880e8f85892c --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/EnableRealTimeProtection.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.AutoManage.Models +{ + + /// + /// Defines values for EnableRealTimeProtection. + /// + public static class EnableRealTimeProtection + { + public const string True = "True"; + public const string False = "False"; + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ErrorResponse.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..34ca49919df4 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ErrorResponse.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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// ARM error response body. + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// Details about the error. + public ErrorResponse(ErrorResponseBody error = default(ErrorResponseBody)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets details about the error. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponseBody Error { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ErrorResponseBody.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ErrorResponseBody.cs new file mode 100644 index 000000000000..ad0a894cdaca --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ErrorResponseBody.cs @@ -0,0 +1,73 @@ +// +// 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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// An error response from the Automanage service. + /// + public partial class ErrorResponseBody + { + /// + /// Initializes a new instance of the ErrorResponseBody class. + /// + public ErrorResponseBody() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponseBody class. + /// + /// An identifier for the error. Codes are invariant + /// and are intended to be consumed programmatically. + /// A message describing the error, intended to + /// be suitable for display in a user interface. + /// The target of the particular error. For + /// example, the name of the property in error. + public ErrorResponseBody(string code = default(string), string message = default(string), string target = default(string)) + { + Code = code; + Message = message; + Target = target; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets an identifier for the error. Codes are invariant and + /// are intended to be consumed programmatically. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets a message describing the error, intended to be + /// suitable for display in a user interface. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets the target of the particular error. For example, the + /// name of the property in error. + /// + [JsonProperty(PropertyName = "target")] + public string Target { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ErrorResponseException.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..c628662bd8f1 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ErrorResponseException.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.AutoManage.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorResponse + /// information. + /// + public partial class ErrorResponseException : 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 ErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + public ErrorResponseException() + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + public ErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Operation.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..ee3f927f2e59 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Operation.cs @@ -0,0 +1,85 @@ +// +// 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.AutoManage.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Automanage REST API operation + /// + [Rest.Serialization.JsonTransformation] + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + /// Operation name: For ex. + /// providers/Microsoft.Automanage/configurationProfileAssignments/write + /// or read + /// Indicates whether the operation is a + /// data action + /// Provider, Resource, Operation and description + /// values. + /// Service provider: + /// Microsoft.Automanage + public Operation(string name = default(string), string isDataAction = default(string), OperationDisplay display = default(OperationDisplay), string statusCode = default(string)) + { + Name = name; + IsDataAction = isDataAction; + Display = display; + StatusCode = statusCode; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets operation name: For ex. + /// providers/Microsoft.Automanage/configurationProfileAssignments/write + /// or read + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets indicates whether the operation is a data action + /// + [JsonProperty(PropertyName = "isDataAction")] + public string IsDataAction { get; set; } + + /// + /// Gets or sets provider, Resource, Operation and description values. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; set; } + + /// + /// Gets or sets service provider: Microsoft.Automanage + /// + [JsonProperty(PropertyName = "properties.statusCode")] + public string StatusCode { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/OperationDisplay.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..76bafe99c9f4 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/OperationDisplay.cs @@ -0,0 +1,78 @@ +// +// 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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Provider, Resource, Operation and description values. + /// + 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: + /// Microsoft.Automanage + /// Resource on which the operation is + /// performed: For ex. + /// Operation type: Read, write, delete, + /// etc. + /// Description about operation. + 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: Microsoft.Automanage + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; set; } + + /// + /// Gets or sets resource on which the operation is performed: For ex. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; set; } + + /// + /// Gets or sets operation type: Read, write, delete, etc. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets description about operation. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Page.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Page.cs new file mode 100644 index 000000000000..0ac8e5b45f4b --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/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.AutoManage.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("")] + 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/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ProvisioningStatus.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ProvisioningStatus.cs new file mode 100644 index 000000000000..44c289ea2b25 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ProvisioningStatus.cs @@ -0,0 +1,23 @@ +// +// 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.AutoManage.Models +{ + + /// + /// Defines values for ProvisioningStatus. + /// + public static class ProvisioningStatus + { + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + public const string Created = "Created"; + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ProxyResource.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ProxyResource.cs new file mode 100644 index 000000000000..5db1da47feed --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ProxyResource.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.AutoManage.Models +{ + using System.Linq; + + /// + /// ARM proxy resource. + /// + public partial class ProxyResource : Resource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// ARM resource id of the Automanage + /// assignment. + /// Name of the Automanage assignment. + /// Region where the VM is located. + /// The type of the resource. + public ProxyResource(string id = default(string), string name = default(string), string location = default(string), string type = default(string)) + : base(id, name, location, type) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Resource.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Resource.cs new file mode 100644 index 000000000000..39feab1dd40a --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/Resource.cs @@ -0,0 +1,78 @@ +// +// 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.AutoManage.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The core properties of ARM resources + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// ARM resource id of the Automanage + /// assignment. + /// Name of the Automanage assignment. + /// Region where the VM is located. + /// The type of the resource. + public Resource(string id = default(string), string name = default(string), string location = default(string), string type = default(string)) + { + Id = id; + Name = name; + Location = location; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets ARM resource id of the Automanage assignment. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets name of the Automanage assignment. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets region where the VM is located. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; private set; } + + /// + /// Gets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ResourceIdentityType.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ResourceIdentityType.cs new file mode 100644 index 000000000000..2637187a6478 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ResourceIdentityType.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.AutoManage.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ResourceIdentityType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ResourceIdentityType + { + [EnumMember(Value = "SystemAssigned")] + SystemAssigned, + [EnumMember(Value = "None")] + None + } + internal static class ResourceIdentityTypeEnumExtension + { + internal static string ToSerializedValue(this ResourceIdentityType? value) + { + return value == null ? null : ((ResourceIdentityType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ResourceIdentityType value) + { + switch( value ) + { + case ResourceIdentityType.SystemAssigned: + return "SystemAssigned"; + case ResourceIdentityType.None: + return "None"; + } + return null; + } + + internal static ResourceIdentityType? ParseResourceIdentityType(this string value) + { + switch( value ) + { + case "SystemAssigned": + return ResourceIdentityType.SystemAssigned; + case "None": + return ResourceIdentityType.None; + } + return null; + } + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/RunScheduledScan.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/RunScheduledScan.cs new file mode 100644 index 000000000000..0ab23b6179ac --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/RunScheduledScan.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.AutoManage.Models +{ + + /// + /// Defines values for RunScheduledScan. + /// + public static class RunScheduledScan + { + public const string True = "True"; + public const string False = "False"; + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ScanType.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ScanType.cs new file mode 100644 index 000000000000..ba25bc1e25b7 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/ScanType.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.AutoManage.Models +{ + + /// + /// Defines values for ScanType. + /// + public static class ScanType + { + public const string Quick = "Quick"; + public const string Full = "Full"; + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/TrackedResource.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/TrackedResource.cs new file mode 100644 index 000000000000..9be20b9448d9 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/TrackedResource.cs @@ -0,0 +1,59 @@ +// +// 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.AutoManage.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The resource model definition for a ARM tracked top level resource + /// + public partial class TrackedResource : Resource + { + /// + /// Initializes a new instance of the TrackedResource class. + /// + public TrackedResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TrackedResource class. + /// + /// ARM resource id of the Automanage + /// assignment. + /// Name of the Automanage assignment. + /// Region where the VM is located. + /// The type of the resource. + /// Resource tags. + public TrackedResource(string id = default(string), string name = default(string), string location = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, location, type) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/UpdateStatus.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/UpdateStatus.cs new file mode 100644 index 000000000000..8c1f511cb6c2 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Models/UpdateStatus.cs @@ -0,0 +1,23 @@ +// +// 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.AutoManage.Models +{ + + /// + /// Defines values for UpdateStatus. + /// + public static class UpdateStatus + { + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + public const string Created = "Created"; + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Operations.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Operations.cs new file mode 100644 index 000000000000..a0a6968470c7 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/Operations.cs @@ -0,0 +1,222 @@ +// +// 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.AutoManage +{ + 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(AutomanageClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AutomanageClient + /// + public AutomanageClient Client { get; private set; } + + /// + /// Lists all of the available Automanage REST API operations. + /// + /// + /// 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"); + } + // 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.Automanage/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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/OperationsExtensions.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..34681f45f35b --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Generated/OperationsExtensions.cs @@ -0,0 +1,55 @@ +// +// 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.AutoManage +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// Lists all of the available Automanage REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Automanage REST API operations. + /// + /// + /// 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; + } + } + + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Microsoft.Azure.Management.AutoManage.csproj b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Microsoft.Azure.Management.AutoManage.csproj new file mode 100644 index 000000000000..4358e59d0751 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Microsoft.Azure.Management.AutoManage.csproj @@ -0,0 +1,20 @@ + + + + + + + $(SdkTargetFx) + + + Microsoft.Azure.Management.AutoManage + Microsoft Azure AutoManage Class Library + 0.1.0-preview + Microsoft.Azure.Management.AutoManage + Microsoft.Azure.Management.AutoManage + AutoManagement;AutoManaged;Automanagement Configuration Profile; Automanagement Account + For detailed release notes, see: https://github.com/Azure/azure-sdk-for-net/blob/psSdkJson6/src/SDKs/Automanage/Management.Automanage/changelog.md + + + + diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Properties/AssemblyInfo.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..d88e25f02aae --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/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 Automanaged Management Library")] +[assembly: AssemblyDescription("Provides Microsoft Azure Automanage management operations including the ability to create, update and get Automanaged profile assignments, compliance statuses, automation accounts, and other related artifacts.")] + +[assembly: AssemblyVersion("0.6.0")] +[assembly: AssemblyFileVersion("0.6.0")] + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Azure .NET SDK")] +[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/generate.ps1 b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/generate.ps1 new file mode 100644 index 000000000000..2d79ffaf190b --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/src/generate.ps1 @@ -0,0 +1 @@ +Start-AutoRestCodeGeneration -ResourceProvider "automanage/resource-manager" -AutoRestVersion "v2" \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/Helpers/RecordedDelegatingHandler.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/Helpers/RecordedDelegatingHandler.cs new file mode 100644 index 000000000000..97384fdf92e6 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/Helpers/RecordedDelegatingHandler.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading.Tasks; +using Microsoft.Azure.Management.AutoManage.Models; + +namespace AutoManage.Tests.Helpers +{ + public class RecordedDelegatingHandler : DelegatingHandler + { + private HttpResponseMessage _response; + + public RecordedDelegatingHandler() + { + StatusCodeToReturn = HttpStatusCode.OK; + SubsequentStatusCodeToReturn = StatusCodeToReturn; + } + + public RecordedDelegatingHandler(HttpResponseMessage response) + { + StatusCodeToReturn = HttpStatusCode.OK; + SubsequentStatusCodeToReturn = StatusCodeToReturn; + _response = response; + } + + public HttpStatusCode StatusCodeToReturn { get; set; } + + public HttpStatusCode SubsequentStatusCodeToReturn { get; set; } + + public string Request { get; private set; } + + public HttpRequestHeaders RequestHeaders { get; private set; } + + public HttpContentHeaders ContentHeaders { get; private set; } + + public HttpMethod Method { get; private set; } + + public Uri Uri { get; private set; } + + public bool IsPassThrough { get; set; } + + private int counter; + + protected override async Task SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) + { + counter++; + // Save request + if (request.Content == null) + { + Request = string.Empty; + } + else + { + Request = await request.Content.ReadAsStringAsync(); + } + RequestHeaders = request.Headers; + if (request.Content != null) + { + ContentHeaders = request.Content.Headers; + } + Method = request.Method; + Uri = request.RequestUri; + + // Prepare response + if (IsPassThrough) + { + return await base.SendAsync(request, cancellationToken); + } + else + { + // Generate mock response for unit tests + if (_response != null && counter == 1) + { + return _response; + } + else + { + var statusCode = StatusCodeToReturn; + if (counter > 1) + statusCode = SubsequentStatusCodeToReturn; + HttpResponseMessage response = new HttpResponseMessage(statusCode); + response.Content = new StringContent(""); + return response; + } + } + } + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/Microsoft.Azure.Management.AutoManage.Tests.csproj b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/Microsoft.Azure.Management.AutoManage.Tests.csproj new file mode 100644 index 000000000000..fdde0e28b5ec --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/Microsoft.Azure.Management.AutoManage.Tests.csproj @@ -0,0 +1,19 @@ + + + + AutoManage.Tests + AutoManage.Tests Class Library + AutoManage.Tests + 0.1.0-preview + Microsoft.Azure.Management.AutoManage.Tests + + + + PreserveNewest + + + + + + + \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/AccountsTests.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/AccountsTests.cs new file mode 100644 index 000000000000..28f8bb2f034e --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/AccountsTests.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +namespace AutoManage.Tests.ScenarioTests +{ + using System; + using System.Collections.Generic; + using System.Net; + using System.Threading.Tasks; + using AutoManage.Tests.Helpers; + using Microsoft.Azure.Management.AutoManage; + using Microsoft.Azure.Management.AutoManage.Models; + using Microsoft.Rest.Azure; + using Microsoft.Rest.ClientRuntime.Azure.TestFramework; + using Xunit; + using Xunit.Abstractions; + + public class AccountsTests : TestBase + { + private RecordedDelegatingHandler handler; + + public AccountsTests() + : base() + { + handler = new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = HttpStatusCode.OK }; + } + + [Fact] + [Trait("Category", "Scenario")] + public void AccountsOperationsGetsExpectedAccount() + { + var thisType = this.GetType(); + using (MockContext context = MockContext.Start(thisType)) + { + var automanageClient = GetAutomanagementClient(context, handler); + var t = automanageClient.Accounts.ListByResourceGroup("myNewAmVm3"); + var actual = automanageClient.Accounts.Get("AMVM-SubLib-017-ABP", "AMVM-SubLib-017_group"); + Assert.NotNull(actual); + } + } + + [Fact] + [Trait("Category", "Scenario")] + public void AccountsOperationsListsReturnsAllAccounts() + { + var thisType = this.GetType(); + using (MockContext context = MockContext.Start(thisType)) + { + var automanageClient = GetAutomanagementClient(context, handler); + var list = automanageClient.Accounts.ListByResourceGroup("myNewAmVm3"); + Assert.NotNull(list); + } + } + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/ConfigurationProfilePreferencesTests.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/ConfigurationProfilePreferencesTests.cs new file mode 100644 index 000000000000..1b23f99d973f --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/ConfigurationProfilePreferencesTests.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. +namespace AutoManage.Tests.ScenarioTests +{ + using System.Net; + using System.Threading; + using System.Threading.Tasks; + using AutoManage.Tests.Helpers; + using Microsoft.Azure.Management.AutoManage; + using Microsoft.Azure.Management.AutoManage.Models; + using Microsoft.Rest.ClientRuntime.Azure.TestFramework; + using Xunit; + using Xunit.Abstractions; + + public class ConfigurationProfilePreferencesTests : TestBase + { + private RecordedDelegatingHandler handler; + private string vmName = "mynewamvmVM2"; + private string vmID = "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/mynewamvmVM_group/providers/Microsoft.Compute/virtualMachines/mynewamvmVM2"; + private string automanageAccountId = "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/accounts/AMVM-SubLib-017-ABP"; + public ConfigurationProfilePreferencesTests() + : base() + { + handler = new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = HttpStatusCode.OK }; + } + + [Fact] + [Trait("Category", "Scenario")] + public void ConfigurationProfilesPreferencesListsPreferences() + { + var thisType = this.GetType(); + using (MockContext context = MockContext.Start(thisType)) + { + var automanageClient = GetAutomanagementClient(context, handler); + var actual = automanageClient.ConfigurationProfilePreferences.ListByResourceGroup("MYNEWAMVM3"); + Assert.NotNull(actual); + } + } + + [Fact] + [Trait("Category", "Scenario")] + public void ConfigurationProfilesPreferencesGetReturnsExpectedPreferences() + { + var thisType = this.GetType(); + using (MockContext context = MockContext.Start(thisType)) + { + var automanageClient = GetAutomanagementClient(context, handler); + var actual = automanageClient.ConfigurationProfilePreferences.Get("MyNewCustomPrefs", "MYNEWAMVM3"); + Assert.NotNull(actual); + } + } + + private ConfigurationProfilePreference GetAConfigurationProfilePreferenceObject() + { + var customAntiMalwareProps = new ConfigurationProfilePreferenceAntiMalware( + enableRealTimeProtection: "True", + exclusions: new[] { "C:\\temp", "notepad.exe" }, + scanType: "Quick", + scanDay: "1", + scanTimeInMinutes: "360"); + var vmBackupProps = new ConfigurationProfilePreferenceVmBackup("Pacific Standard Time", 14, null, null); + + var preferenceProperties = new ConfigurationProfilePreferenceProperties( + vmBackup: vmBackupProps, antiMalware: customAntiMalwareProps); + + var thisAssignment = new ConfigurationProfilePreference( + id: null, + name: "default", + location: "West US 2", + properties: preferenceProperties); + return thisAssignment; + } + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/ConfigurationProfilesAssignmentsTests.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/ConfigurationProfilesAssignmentsTests.cs new file mode 100644 index 000000000000..8027851212c9 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/ConfigurationProfilesAssignmentsTests.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +namespace AutoManage.Tests.ScenarioTests +{ + using System.Net; + using System.Threading; + using System.Threading.Tasks; + using AutoManage.Tests.Helpers; + using Microsoft.Azure.Management.AutoManage; + using Microsoft.Azure.Management.AutoManage.Models; + using Microsoft.Rest.ClientRuntime.Azure.TestFramework; + using Xunit; + using Xunit.Abstractions; + + public class ConfigurationProfilesAssignmentsTests : TestBase + { + private RecordedDelegatingHandler handler; + private string vmName = "mynewamvmVM2"; + private string vmID = "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/mynewamvmVM_group/providers/Microsoft.Compute/virtualMachines/mynewamvmVM2"; + private string automanageAccountId = "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/accounts/AMVM-SubLib-017-ABP"; + public ConfigurationProfilesAssignmentsTests() + : base() + { + handler = new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = HttpStatusCode.OK }; + } + + [Fact] + [Trait("Category", "Scenario")] + public void ConfigurationProfilesListAssignmentsGetsExpectedProfile() + { + var thisType = this.GetType(); + using (MockContext context = MockContext.Start(thisType)) + { + var automanageClient = GetAutomanagementClient(context, handler); + //var actual2 = await automanageClient.ConfigurationProfileAssignments.ListWithHttpMessagesAsync("DeluxeTest"); + var actual = automanageClient.ConfigurationProfileAssignments.List("DeluxeTest"); + Assert.NotNull(actual); + } + } + + [Fact] + //[Trait("Category", "Scenario")] + public void ConfigurationProfilesAssignmentsCreatesProfile() + { + var thisType = this.GetType(); + using (MockContext context = MockContext.Start(thisType)) + { + var automanageClient = GetAutomanagementClient(context, handler); + + //create new ProfileAssignment + var expectedProfile = GetAConfigurationProfileAssignment(); + var actual = automanageClient.ConfigurationProfileAssignments.BeginCreateOrUpdateAsync( + configurationProfileAssignmentName: expectedProfile.Name, + parameters: expectedProfile, + resourceGroupName: "mynewamvmVM_group", + vmName: vmName) ; + + Assert.NotNull(actual); + } + } + + private ConfigurationProfileAssignment GetAConfigurationProfileAssignment() + { + var assignmentProperties = new ConfigurationProfileAssignmentProperties( + configurationProfile: "Azure Best Practices - Prod", + targetId: vmID, + accountId: automanageAccountId, + configurationProfilePreferenceId: null, //change to the ARM id of a preference object to test preference application + provisioningStatus: null, + compliance: null); + + var thisAssignment = new ConfigurationProfileAssignment( + id: null, + name: "default", + location: "East US 2", + properties: assignmentProperties); + return thisAssignment; + } + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/OperationsTests.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/OperationsTests.cs new file mode 100644 index 000000000000..f080128ec36d --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/OperationsTests.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +namespace AutoManage.Tests.ScenarioTests +{ + using System; + using System.Collections.Generic; + using System.Net; + using System.Threading.Tasks; + using AutoManage.Tests.Helpers; + using Microsoft.Azure.Management.AutoManage; + using Microsoft.Azure.Management.AutoManage.Models; + using Microsoft.Rest.Azure; + using Microsoft.Rest.ClientRuntime.Azure.TestFramework; + using Xunit; + using Xunit.Abstractions; + + public class OperationsTests : TestBase + { + private RecordedDelegatingHandler handler; + + public OperationsTests() + : base() + { + handler = new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = HttpStatusCode.OK }; + } + + [Fact] + [Trait("Category", "Scenario")] + public void ListOperationsGetsAllValidOperations() + { + var thisType = this.GetType(); + using (MockContext context = MockContext.Start(thisType)) + { + var automanageClient = GetAutomanagementClient(context, handler); + + var actual = automanageClient.Operations.List(); + + Assert.NotNull(actual); + if (!this.IsRecording) + { + CheckListedOperations(actual); + } + } + } + + private static void CheckListedOperations(IEnumerable operationListResult) + { + List supportedOperations = new List + { + "Microsoft.Automanage/register/Action", + "Microsoft.Automanage/accounts/Delete", + "Microsoft.Automanage/accounts/Read", + "Microsoft.Automanage/accounts/Write", + "Microsoft.Automanage/configurationProfileAssignments/Delete", + "Microsoft.Automanage/configurationProfileAssignments/Read", + "Microsoft.Automanage/configurationProfileAssignments/Write", + + }; + + string expectedProvider = "Microsoft Automanage"; + + var enumerator = operationListResult.GetEnumerator(); + while (enumerator.MoveNext()) + { + Operation current = enumerator.Current; + Assert.Contains(current.Name, supportedOperations); + Assert.Equal(expectedProvider, current.Display.Provider); + } + } + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/TestBase.cs b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/TestBase.cs new file mode 100644 index 000000000000..9e3395de06be --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/ScenarioTests/TestBase.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.Azure.Management.AutoManage; +using Microsoft.Azure.Management.AutoManage.Models; +using Xunit; +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; +using Microsoft.Azure.Test.HttpRecorder; +using System.IO; +using Microsoft.Azure.Management.ResourceManager; +using Microsoft.Azure.Management.ResourceManager.Models; +using AutoManage.Tests.Helpers; + +namespace AutoManage.Tests.ScenarioTests +{ + public class TestBase + { + protected bool IsRecording { get; set; } + + protected ResourceManagementClient ResourceManagementClient { get; private set; } + + public TestBase() + { + //// Set the path to find the recorded session files (only works in VS locally for .net452) + HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords"); + this.IsRecording = false; + } + + protected AutomanageClient GetAutomanagementClient(MockContext context, RecordedDelegatingHandler handler) + { + if (handler != null) + { + handler.IsPassThrough = true; + } + + AutomanageClient client; + string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE", EnvironmentVariableTarget.User); + if (string.Equals(testMode, "record", StringComparison.OrdinalIgnoreCase)) + { + this.IsRecording = true; + string connectionString = Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION", EnvironmentVariableTarget.User); + + TestEnvironment env = new TestEnvironment(connectionString: connectionString); + client = context.GetServiceClient( + currentEnvironment: env, + handlers: handler ?? new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = System.Net.HttpStatusCode.OK }); + + this.SetResourceManagementClient(env: env, context: context, handler: handler); + } + else + { + client = context.GetServiceClient( + handlers: handler ?? new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = System.Net.HttpStatusCode.OK }); + + this.SetResourceManagementClient(env: null, context: context, handler: handler); + } + + return client; + } + + private void SetResourceManagementClient(TestEnvironment env, MockContext context, RecordedDelegatingHandler handler) + { + if (handler != null) + { + handler.IsPassThrough = true; + } + + if (env != null) + { + this.ResourceManagementClient = context.GetServiceClient( + currentEnvironment: env, + handlers: handler ?? new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = System.Net.HttpStatusCode.OK }); + } + else + { + this.ResourceManagementClient = context.GetServiceClient( + handlers: handler ?? new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = System.Net.HttpStatusCode.OK }); + } + } + + protected bool VerifyExistenceOrCreateResourceGroup(string resourceGroupName, string location) + { + if (this.ResourceManagementClient == null) + { + throw new NullReferenceException("ResourceManagementClient not created."); + } + + if (this.ResourceManagementClient.ResourceGroups.CheckExistence(resourceGroupName: resourceGroupName)) + { + return true; + } + + ResourceGroup resourceGroup = new ResourceGroup + { + Location = location, + Name = resourceGroupName + }; + + resourceGroup = this.ResourceManagementClient.ResourceGroups.CreateOrUpdate(resourceGroupName: resourceGroupName, parameters: resourceGroup); + + return true; + } + + protected static void AreEqual(IList exp, IList act) + { + if (exp != null) + { + for (int i = 0; i < exp.Count; i++) + { + Assert.Equal(exp[i], act[i]); + } + } + } + + protected static void AreEqual(IList exp, IList act) + { + if (exp != null) + { + for (int i = 0; i < exp.Count; i++) + { + Assert.Equal(exp[i], act[i]); + } + } + } + + protected static void AreEqual(IDictionary exp, IDictionary act) + { + if (exp != null) + { + Assert.NotNull(act); + Assert.Equal(exp.Count, act.Count); + foreach (var key in exp.Keys) + { + Assert.Equal(exp[key], act[key]); + } + } + } + } +} diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/AccountsTests/AccountsOperationsGetsExpectedAccount.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/AccountsTests/AccountsOperationsGetsExpectedAccount.json new file mode 100644 index 000000000000..7dedb59933f4 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/AccountsTests/AccountsOperationsGetsExpectedAccount.json @@ -0,0 +1,134 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/myNewAmVm3/providers/Microsoft.Automanage/accounts?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL215TmV3QW1WbTMvcHJvdmlkZXJzL01pY3Jvc29mdC5BdXRvbWFuYWdlL2FjY291bnRzP2FwaS12ZXJzaW9uPTIwMjAtMDYtMzAtcHJldmlldw==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "b01dc805-728a-4c21-92dd-bebe25dabdde" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "2f5adb56-5024-4f2c-a969-4c6a8bcc022b" + ], + "x-ms-correlation-request-id": [ + "2f5adb56-5024-4f2c-a969-4c6a8bcc022b" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20200822T132126Z:2f5adb56-5024-4f2c-a969-4c6a8bcc022b" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Sat, 22 Aug 2020 13:21:26 GMT" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "12" + ] + }, + "ResponseBody": "{\r\n \"value\": []\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/accounts/AMVM-SubLib-017-ABP?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL0FNVk0tU3ViTGliLTAxN19ncm91cC9wcm92aWRlcnMvTWljcm9zb2Z0LkF1dG9tYW5hZ2UvYWNjb3VudHMvQU1WTS1TdWJMaWItMDE3LUFCUD9hcGktdmVyc2lvbj0yMDIwLTA2LTMwLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "ee30f359-f92a-49e6-a47a-c2c2cbd65cb8" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-request-id": [ + "daa88489-3654-4ba9-b83c-0616ffe70946" + ], + "x-ms-correlation-request-id": [ + "daa88489-3654-4ba9-b83c-0616ffe70946" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20200822T132137Z:daa88489-3654-4ba9-b83c-0616ffe70946" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Sat, 22 Aug 2020 13:21:37 GMT" + ], + "Content-Length": [ + "385" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"identity\": {\r\n \"type\": \"SystemAssigned\",\r\n \"principalId\": \"f60187c9-9456-4386-aeb9-c1b50278e3f9\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\"\r\n },\r\n \"location\": \"eastus\",\r\n \"id\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/accounts/AMVM-SubLib-017-ABP\",\r\n \"name\": \"AMVM-SubLib-017-ABP\",\r\n \"type\": \"Microsoft.Automanage/accounts\"\r\n}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/AccountsTests/AccountsOperationsListsReturnsAllAccounts.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/AccountsTests/AccountsOperationsListsReturnsAllAccounts.json new file mode 100644 index 000000000000..cc366acda0be --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/AccountsTests/AccountsOperationsListsReturnsAllAccounts.json @@ -0,0 +1,68 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/myNewAmVm3/providers/Microsoft.Automanage/accounts?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL215TmV3QW1WbTMvcHJvdmlkZXJzL01pY3Jvc29mdC5BdXRvbWFuYWdlL2FjY291bnRzP2FwaS12ZXJzaW9uPTIwMjAtMDYtMzAtcHJldmlldw==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "1c8ff64d-c84b-4476-b9cd-4c5dfc7b97f5" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "fa5a34a8-b37b-44c7-9e7b-b2ae5a4159f0" + ], + "x-ms-correlation-request-id": [ + "fa5a34a8-b37b-44c7-9e7b-b2ae5a4159f0" + ], + "x-ms-routing-request-id": [ + "NORTHCENTRALUS:20200822T132243Z:fa5a34a8-b37b-44c7-9e7b-b2ae5a4159f0" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Sat, 22 Aug 2020 13:22:42 GMT" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "12" + ] + }, + "ResponseBody": "{\r\n \"value\": []\r\n}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesCreatesPreferences.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesCreatesPreferences.json new file mode 100644 index 000000000000..f4cbe2e8fa6f --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesCreatesPreferences.json @@ -0,0 +1,74 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/myNewAmVm3/providers/Microsoft.Automanage/configurationProfilePreferences/amvmCustomPreferenceSample?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL215TmV3QW1WbTMvcHJvdmlkZXJzL01pY3Jvc29mdC5BdXRvbWFuYWdlL2NvbmZpZ3VyYXRpb25Qcm9maWxlUHJlZmVyZW5jZXMvYW12bUN1c3RvbVByZWZlcmVuY2VTYW1wbGU/YXBpLXZlcnNpb249MjAyMC0wNi0zMC1wcmV2aWV3", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"vmBackup\": {\r\n \"timeZone\": \"Pacific Standard Time\",\r\n \"instantRpRetentionRangeInDays\": 14\r\n },\r\n \"antiMalware\": {\r\n \"enableRealTimeProtection\": \"True\",\r\n \"exclusions\": [\r\n \"C:\\\\temp\",\r\n \"notepad.exe\"\r\n ],\r\n \"scanType\": \"Quick\",\r\n \"scanDay\": \"1\",\r\n \"scanTimeInMinutes\": \"360\"\r\n }\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "81358e27-a022-4355-9ce4-d0ee7f5d814b" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "376" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-failure-cause": [ + "gateway" + ], + "x-ms-request-id": [ + "6f471c40-a75e-4290-acb5-226deb36fea1" + ], + "x-ms-correlation-request-id": [ + "6f471c40-a75e-4290-acb5-226deb36fea1" + ], + "x-ms-routing-request-id": [ + "CANADACENTRAL:20200822T142206Z:6f471c40-a75e-4290-acb5-226deb36fea1" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Sat, 22 Aug 2020 14:22:05 GMT" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "104" + ] + }, + "ResponseBody": "{\r\n \"error\": {\r\n \"code\": \"LocationRequired\",\r\n \"message\": \"The location property is required for this definition.\"\r\n }\r\n}", + "StatusCode": 400 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesGetReturnsExpectedPreferences.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesGetReturnsExpectedPreferences.json new file mode 100644 index 000000000000..506cbd29f947 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesGetReturnsExpectedPreferences.json @@ -0,0 +1,74 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/MYNEWAMVM3/providers/Microsoft.Automanage/configurationProfilePreferences/MyNewCustomPrefs?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL01ZTkVXQU1WTTMvcHJvdmlkZXJzL01pY3Jvc29mdC5BdXRvbWFuYWdlL2NvbmZpZ3VyYXRpb25Qcm9maWxlUHJlZmVyZW5jZXMvTXlOZXdDdXN0b21QcmVmcz9hcGktdmVyc2lvbj0yMDIwLTA2LTMwLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "30b62b38-5e94-462c-b6e8-f8a9ab011cd4" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "9f8a3f54-b99e-4059-b4e1-45f02008c9ae" + ], + "x-ms-correlation-request-id": [ + "9f8a3f54-b99e-4059-b4e1-45f02008c9ae" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20200822T143553Z:9f8a3f54-b99e-4059-b4e1-45f02008c9ae" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Sat, 22 Aug 2020 14:35:53 GMT" + ], + "Content-Length": [ + "758" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/myNewAmVm3/providers/Microsoft.Automanage/configurationProfilePreferences/MyNewCustomPrefs\",\r\n \"name\": \"MyNewCustomPrefs\",\r\n \"type\": \"Microsoft.Automanage/configurationProfilePreferences\",\r\n \"location\": \"westus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"antimalware\": {\r\n \"enableRealTimeProtection\": true,\r\n \"exclusions\": {\r\n \"extensions\": \"c:\\\\temp\",\r\n \"paths\": \"myDb.sql\",\r\n \"processes\": \"notepad.exe\"\r\n },\r\n \"runScheduledScan\": false,\r\n \"scanType\": \"Quick\",\r\n \"scanDay\": \"7\",\r\n \"scanTimeInMinutes\": \"120\"\r\n }\r\n },\r\n \"systemData\": {\r\n \"createdAt\": \"2020-08-22T10:25:21.4596406-04:00\",\r\n \"createdBy\": \"stowen@microsoft.com\",\r\n \"createdByType\": \"User\",\r\n \"lastModifiedAt\": \"2020-08-22T10:25:21.4596406-04:00\",\r\n \"lastModifiedBy\": \"stowen@microsoft.com\",\r\n \"lastModifiedByType\": \"User\"\r\n }\r\n}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesListsAnyPreferences.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesListsAnyPreferences.json new file mode 100644 index 000000000000..480262b01f7f --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesListsAnyPreferences.json @@ -0,0 +1,140 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/providers/Microsoft.Automanage/configurationProfilePreferences?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Byb3ZpZGVycy9NaWNyb3NvZnQuQXV0b21hbmFnZS9jb25maWd1cmF0aW9uUHJvZmlsZVByZWZlcmVuY2VzP2FwaS12ZXJzaW9uPTIwMjAtMDYtMzAtcHJldmlldw==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "aad404b2-a898-4dea-9627-e9b1d11d79af" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "3eef991e-5418-40e1-bc63-d1281f9e40f4" + ], + "x-ms-correlation-request-id": [ + "3eef991e-5418-40e1-bc63-d1281f9e40f4" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20200822T142714Z:3eef991e-5418-40e1-bc63-d1281f9e40f4" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Sat, 22 Aug 2020 14:27:14 GMT" + ], + "Content-Length": [ + "771" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"values\": [\r\n {\r\n \"id\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/myNewAmVm3/providers/Microsoft.Automanage/configurationProfilePreferences/MyNewCustomPrefs\",\r\n \"name\": \"MyNewCustomPrefs\",\r\n \"type\": \"Microsoft.Automanage/configurationProfilePreferences\",\r\n \"location\": \"westus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"antimalware\": {\r\n \"enableRealTimeProtection\": true,\r\n \"exclusions\": {\r\n \"extensions\": \"c:\\\\temp\",\r\n \"paths\": \"myDb.sql\",\r\n \"processes\": \"notepad.exe\"\r\n },\r\n \"runScheduledScan\": false,\r\n \"scanType\": \"Quick\",\r\n \"scanDay\": \"7\",\r\n \"scanTimeInMinutes\": \"120\"\r\n }\r\n },\r\n \"systemData\": {\r\n \"createdAt\": \"2020-08-22T10:25:21.4596406-04:00\",\r\n \"createdBy\": \"stowen@microsoft.com\",\r\n \"createdByType\": \"User\",\r\n \"lastModifiedAt\": \"2020-08-22T10:25:21.4596406-04:00\",\r\n \"lastModifiedBy\": \"stowen@microsoft.com\",\r\n \"lastModifiedByType\": \"User\"\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/MYNEWAMVM3/providers/Microsoft.Automanage/configurationProfilePreferences/MyNewCustomPrefs?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL01ZTkVXQU1WTTMvcHJvdmlkZXJzL01pY3Jvc29mdC5BdXRvbWFuYWdlL2NvbmZpZ3VyYXRpb25Qcm9maWxlUHJlZmVyZW5jZXMvTXlOZXdDdXN0b21QcmVmcz9hcGktdmVyc2lvbj0yMDIwLTA2LTMwLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "dc6c66c6-91cf-4d57-a4e2-36a850843092" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-request-id": [ + "de5ca056-fab8-43cc-96b2-80296b89f896" + ], + "x-ms-correlation-request-id": [ + "de5ca056-fab8-43cc-96b2-80296b89f896" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20200822T142715Z:de5ca056-fab8-43cc-96b2-80296b89f896" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Sat, 22 Aug 2020 14:27:15 GMT" + ], + "Content-Length": [ + "758" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/myNewAmVm3/providers/Microsoft.Automanage/configurationProfilePreferences/MyNewCustomPrefs\",\r\n \"name\": \"MyNewCustomPrefs\",\r\n \"type\": \"Microsoft.Automanage/configurationProfilePreferences\",\r\n \"location\": \"westus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"antimalware\": {\r\n \"enableRealTimeProtection\": true,\r\n \"exclusions\": {\r\n \"extensions\": \"c:\\\\temp\",\r\n \"paths\": \"myDb.sql\",\r\n \"processes\": \"notepad.exe\"\r\n },\r\n \"runScheduledScan\": false,\r\n \"scanType\": \"Quick\",\r\n \"scanDay\": \"7\",\r\n \"scanTimeInMinutes\": \"120\"\r\n }\r\n },\r\n \"systemData\": {\r\n \"createdAt\": \"2020-08-22T10:25:21.4596406-04:00\",\r\n \"createdBy\": \"stowen@microsoft.com\",\r\n \"createdByType\": \"User\",\r\n \"lastModifiedAt\": \"2020-08-22T10:25:21.4596406-04:00\",\r\n \"lastModifiedBy\": \"stowen@microsoft.com\",\r\n \"lastModifiedByType\": \"User\"\r\n }\r\n}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesListsPreferences.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesListsPreferences.json new file mode 100644 index 000000000000..23cfbb6e0079 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilePreferencesTests/ConfigurationProfilesPreferencesListsPreferences.json @@ -0,0 +1,74 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/MYNEWAMVM3/providers/Microsoft.Automanage/configurationProfilePreferences?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL01ZTkVXQU1WTTMvcHJvdmlkZXJzL01pY3Jvc29mdC5BdXRvbWFuYWdlL2NvbmZpZ3VyYXRpb25Qcm9maWxlUHJlZmVyZW5jZXM/YXBpLXZlcnNpb249MjAyMC0wNi0zMC1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "d047ffe4-6355-4f3d-a29f-dc743a625a89" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-request-id": [ + "8955c30b-aab9-4548-8ae9-5e8cd55063b8" + ], + "x-ms-correlation-request-id": [ + "8955c30b-aab9-4548-8ae9-5e8cd55063b8" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20200822T142954Z:8955c30b-aab9-4548-8ae9-5e8cd55063b8" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Sat, 22 Aug 2020 14:29:53 GMT" + ], + "Content-Length": [ + "771" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"values\": [\r\n {\r\n \"id\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/myNewAmVm3/providers/Microsoft.Automanage/configurationProfilePreferences/MyNewCustomPrefs\",\r\n \"name\": \"MyNewCustomPrefs\",\r\n \"type\": \"Microsoft.Automanage/configurationProfilePreferences\",\r\n \"location\": \"westus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"antimalware\": {\r\n \"enableRealTimeProtection\": true,\r\n \"exclusions\": {\r\n \"extensions\": \"c:\\\\temp\",\r\n \"paths\": \"myDb.sql\",\r\n \"processes\": \"notepad.exe\"\r\n },\r\n \"runScheduledScan\": false,\r\n \"scanType\": \"Quick\",\r\n \"scanDay\": \"7\",\r\n \"scanTimeInMinutes\": \"120\"\r\n }\r\n },\r\n \"systemData\": {\r\n \"createdAt\": \"2020-08-22T10:25:21.4596406-04:00\",\r\n \"createdBy\": \"stowen@microsoft.com\",\r\n \"createdByType\": \"User\",\r\n \"lastModifiedAt\": \"2020-08-22T10:25:21.4596406-04:00\",\r\n \"lastModifiedBy\": \"stowen@microsoft.com\",\r\n \"lastModifiedByType\": \"User\"\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilesAssignmentsTests/ConfigurationProfilesAssignmentsCreatesProfile.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilesAssignmentsTests/ConfigurationProfilesAssignmentsCreatesProfile.json new file mode 100644 index 000000000000..972e206103f8 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilesAssignmentsTests/ConfigurationProfilesAssignmentsCreatesProfile.json @@ -0,0 +1,80 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/mynewamvmVM_group/providers/Microsoft.Compute/virtualMachines/mynewamvmVM/providers/Microsoft.Automanage/configurationProfileAssignments/default?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL215bmV3YW12bVZNX2dyb3VwL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29tcHV0ZS92aXJ0dWFsTWFjaGluZXMvbXluZXdhbXZtVk0vcHJvdmlkZXJzL01pY3Jvc29mdC5BdXRvbWFuYWdlL2NvbmZpZ3VyYXRpb25Qcm9maWxlQXNzaWdubWVudHMvZGVmYXVsdD9hcGktdmVyc2lvbj0yMDIwLTA2LTMwLXByZXZpZXc=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"configurationProfile\": \"Azure Best Practices - Prod\",\r\n \"targetId\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/mynewamvmVM_group/providers/Microsoft.Compute/virtualMachines/mynewamvmVM\",\r\n \"accountId\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/accounts/AMVM-SubLib-017-ABP\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "132da640-bfbe-4f55-850d-ac9306056430" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "418" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-request-id": [ + "602cebb3-7473-4ce6-97ec-caca48afa50f" + ], + "x-ms-correlation-request-id": [ + "602cebb3-7473-4ce6-97ec-caca48afa50f" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20200821T151944Z:602cebb3-7473-4ce6-97ec-caca48afa50f" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Fri, 21 Aug 2020 15:19:44 GMT" + ], + "Content-Length": [ + "127" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"error\": {\r\n \"code\": \"UpdateOnPutNotSupported\",\r\n \"message\": \"Updating values of an existing item on PUT is not currently supported.\"\r\n }\r\n}", + "StatusCode": 409 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilesAssignmentsTests/ConfigurationProfilesAssignmentsGetsExpectedProfile.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilesAssignmentsTests/ConfigurationProfilesAssignmentsGetsExpectedProfile.json new file mode 100644 index 000000000000..8b7608e8c532 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilesAssignmentsTests/ConfigurationProfilesAssignmentsGetsExpectedProfile.json @@ -0,0 +1,206 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/configurationProfileAssignments?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL0FNVk0tU3ViTGliLTAxN19ncm91cC9wcm92aWRlcnMvTWljcm9zb2Z0LkF1dG9tYW5hZ2UvY29uZmlndXJhdGlvblByb2ZpbGVBc3NpZ25tZW50cz9hcGktdmVyc2lvbj0yMDIwLTA2LTMwLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "1ff82f08-6792-4579-a723-cf3cc51af06a" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "3758704f-fc16-453c-b79f-a9c1dba1b402" + ], + "x-ms-correlation-request-id": [ + "3758704f-fc16-453c-b79f-a9c1dba1b402" + ], + "x-ms-routing-request-id": [ + "CANADACENTRAL:20200821T151347Z:3758704f-fc16-453c-b79f-a9c1dba1b402" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Fri, 21 Aug 2020 15:13:46 GMT" + ], + "Content-Length": [ + "13" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"values\": []\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/configurationProfileAssignments?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL0FNVk0tU3ViTGliLTAxN19ncm91cC9wcm92aWRlcnMvTWljcm9zb2Z0LkF1dG9tYW5hZ2UvY29uZmlndXJhdGlvblByb2ZpbGVBc3NpZ25tZW50cz9hcGktdmVyc2lvbj0yMDIwLTA2LTMwLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "331bcfb2-f1bf-46c4-aef4-8ad567423bf5" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11997" + ], + "x-ms-request-id": [ + "de2aa054-f586-4c20-b4c4-cfa5684e586e" + ], + "x-ms-correlation-request-id": [ + "de2aa054-f586-4c20-b4c4-cfa5684e586e" + ], + "x-ms-routing-request-id": [ + "CANADACENTRAL:20200821T151347Z:de2aa054-f586-4c20-b4c4-cfa5684e586e" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Fri, 21 Aug 2020 15:13:47 GMT" + ], + "Content-Length": [ + "13" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"values\": []\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/accounts/AMVM-SubLib-017-ABP?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL0FNVk0tU3ViTGliLTAxN19ncm91cC9wcm92aWRlcnMvTWljcm9zb2Z0LkF1dG9tYW5hZ2UvYWNjb3VudHMvQU1WTS1TdWJMaWItMDE3LUFCUD9hcGktdmVyc2lvbj0yMDIwLTA2LTMwLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "1c2516ce-9cf5-4695-83ee-4e77ccfe800b" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-request-id": [ + "d5da7ce5-61ff-41cf-b705-e8cb04e7fb9b" + ], + "x-ms-correlation-request-id": [ + "d5da7ce5-61ff-41cf-b705-e8cb04e7fb9b" + ], + "x-ms-routing-request-id": [ + "CANADACENTRAL:20200821T151347Z:d5da7ce5-61ff-41cf-b705-e8cb04e7fb9b" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Fri, 21 Aug 2020 15:13:46 GMT" + ], + "Content-Length": [ + "385" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"identity\": {\r\n \"type\": \"SystemAssigned\",\r\n \"principalId\": \"f60187c9-9456-4386-aeb9-c1b50278e3f9\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\"\r\n },\r\n \"location\": \"eastus\",\r\n \"id\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/accounts/AMVM-SubLib-017-ABP\",\r\n \"name\": \"AMVM-SubLib-017-ABP\",\r\n \"type\": \"Microsoft.Automanage/accounts\"\r\n}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilesAssignmentsTests/ConfigurationProfilesListAssignmentsGetsExpectedProfile.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilesAssignmentsTests/ConfigurationProfilesListAssignmentsGetsExpectedProfile.json new file mode 100644 index 000000000000..dbfc9a706130 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/ConfigurationProfilesAssignmentsTests/ConfigurationProfilesListAssignmentsGetsExpectedProfile.json @@ -0,0 +1,74 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/DeluxeTest/providers/Microsoft.Automanage/configurationProfileAssignments?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvY2RkNTNhNzEtN2Q4MS00OTNkLWJjZTYtMjI0ZmVjNzIyM2E5L3Jlc291cmNlR3JvdXBzL0RlbHV4ZVRlc3QvcHJvdmlkZXJzL01pY3Jvc29mdC5BdXRvbWFuYWdlL2NvbmZpZ3VyYXRpb25Qcm9maWxlQXNzaWdubWVudHM/YXBpLXZlcnNpb249MjAyMC0wNi0zMC1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "e49a79a2-ca4a-4a1f-9afa-4ea84b6dcf1e" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Automanage.AutomanageClient/1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "1d14fe1b-14fc-4e01-99a9-c686c28704af" + ], + "x-ms-correlation-request-id": [ + "1d14fe1b-14fc-4e01-99a9-c686c28704af" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20200821T165801Z:1d14fe1b-14fc-4e01-99a9-c686c28704af" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Fri, 21 Aug 2020 16:58:01 GMT" + ], + "Content-Length": [ + "770" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"values\": [\r\n {\r\n \"properties\": {\r\n \"targetId\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/DeluxeTest/providers/Microsoft.Compute/virtualMachines/TestMeAmvmv\",\r\n \"configurationProfile\": \"Azure virtual machine best practices – Production\",\r\n \"accountId\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/AMVM-SubLib-017_group/providers/Microsoft.Automanage/accounts/AMVM-SubLib-017-ABP\",\r\n \"provisioningState\": \"New\",\r\n \"compliance\": {\r\n \"status\": \"InProgress\"\r\n }\r\n },\r\n \"id\": \"/subscriptions/cdd53a71-7d81-493d-bce6-224fec7223a9/resourceGroups/DeluxeTest/providers/Microsoft.Compute/virtualMachines/TestMeAmvmv/providers/Microsoft.Automanage/configurationProfileAssignments/default\",\r\n \"name\": \"default\",\r\n \"type\": \"Microsoft.Automanage/configurationProfileAssignments\"\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file diff --git a/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/OperationsTests/ListOperationsGetsAllValidOperations.json b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/OperationsTests/ListOperationsGetsAllValidOperations.json new file mode 100644 index 000000000000..7779c2009a57 --- /dev/null +++ b/sdk/automanage/Microsoft.Azure.Management.AutoManage/tests/SessionRecords/OperationsTests/ListOperationsGetsAllValidOperations.json @@ -0,0 +1,74 @@ +{ + "Entries": [ + { + "RequestUri": "/providers/Microsoft.Automanage/operations?api-version=2020-06-30-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuQXV0b21hbmFnZS9vcGVyYXRpb25zP2FwaS12ZXJzaW9uPTIwMjAtMDYtMzAtcHJldmlldw==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "8aef84e6-db4a-415c-964e-2f5af757bd99" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.03", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.AutoManage.AutomanageClient/0.6.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Request-Context": [ + "appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Kestrel" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11999" + ], + "x-ms-request-id": [ + "a665304b-9144-4ef3-a133-90cb34aa3184" + ], + "x-ms-correlation-request-id": [ + "a665304b-9144-4ef3-a133-90cb34aa3184" + ], + "x-ms-routing-request-id": [ + "NORTHCENTRALUS:20200903T143152Z:a665304b-9144-4ef3-a133-90cb34aa3184" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Thu, 03 Sep 2020 14:31:51 GMT" + ], + "Content-Length": [ + "2075" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"name\": \"Microsoft.Automanage/register/Action\",\r\n \"display\": {\r\n \"provider\": \"Microsoft Automanage\",\r\n \"resource\": \"Automanage Provider\",\r\n \"operation\": \"Registers the Automanage Provider\",\r\n \"description\": \"Registers the subscription for the Automanage Provider.\"\r\n },\r\n \"origin\": \"system\",\r\n \"isDataAction\": false\r\n },\r\n {\r\n \"name\": \"Microsoft.Automanage/accounts/Delete\",\r\n \"display\": {\r\n \"provider\": \"Microsoft Automanage\",\r\n \"resource\": \"Automanage Accounts\",\r\n \"operation\": \"Delete Automanage Accounts\",\r\n \"description\": \"Delete any Automanage Accounts\"\r\n },\r\n \"origin\": \"system\",\r\n \"isDataAction\": false\r\n },\r\n {\r\n \"name\": \"Microsoft.Automanage/accounts/Read\",\r\n \"display\": {\r\n \"provider\": \"Microsoft Automanage\",\r\n \"resource\": \"Automanage Accounts\",\r\n \"operation\": \"Read Automanage Accounts\",\r\n \"description\": \"Read any Automanage Accounts\"\r\n },\r\n \"origin\": \"system\",\r\n \"isDataAction\": false\r\n },\r\n {\r\n \"name\": \"Microsoft.Automanage/accounts/Write\",\r\n \"display\": {\r\n \"provider\": \"Microsoft Automanage\",\r\n \"resource\": \"Automanage Accounts\",\r\n \"operation\": \"Create or Update Automanage Accounts\",\r\n \"description\": \"Create or Update any Automanage Accounts\"\r\n },\r\n \"origin\": \"system\",\r\n \"isDataAction\": false\r\n },\r\n {\r\n \"name\": \"Microsoft.Automanage/configurationProfileAssignments/Delete\",\r\n \"display\": {\r\n \"provider\": \"Microsoft Automanage\",\r\n \"resource\": \"Automanage Configuration Profile Assignments\",\r\n \"operation\": \"Delete Configuration Profile Assignments\",\r\n \"description\": \"Delete any Configuration Profile Assignments\"\r\n },\r\n \"origin\": \"system\",\r\n \"isDataAction\": false\r\n },\r\n {\r\n \"name\": \"Microsoft.Automanage/configurationProfileAssignments/Read\",\r\n \"display\": {\r\n \"provider\": \"Microsoft Automanage\",\r\n \"resource\": \"Automanage Configuration Profile Assignments\",\r\n \"operation\": \"Read Configuration Profile Assignments\",\r\n \"description\": \"Read any Configuration Profile Assignments\"\r\n },\r\n \"origin\": \"system\",\r\n \"isDataAction\": false\r\n },\r\n {\r\n \"name\": \"Microsoft.Automanage/configurationProfileAssignments/Write\",\r\n \"display\": {\r\n \"provider\": \"Microsoft Automanage\",\r\n \"resource\": \"Automanage Configuration Profile Assignments\",\r\n \"operation\": \"Create or Update Configuration Profile Assignments\",\r\n \"description\": \"Create or Update any Configuration Profile Assignments\"\r\n },\r\n \"origin\": \"system\",\r\n \"isDataAction\": false\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "cdd53a71-7d81-493d-bce6-224fec7223a9" + } +} \ No newline at end of file