diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/AliasOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/AliasOperations.cs index da4174675671..de5add228343 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/AliasOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/AliasOperations.cs @@ -54,7 +54,9 @@ internal AliasOperations(SubscriptionClient client) /// Create Alias Subscription. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// @@ -64,10 +66,10 @@ internal AliasOperations(SubscriptionClient client) /// /// The cancellation token. /// - public async Task> CreateWithHttpMessagesAsync(string aliasName, PutAliasRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> CreateWithHttpMessagesAsync(string aliasName, PutAliasRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send Request - AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(aliasName, body, customHeaders, cancellationToken).ConfigureAwait(false); + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(aliasName, body, customHeaders, cancellationToken).ConfigureAwait(false); return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } @@ -75,7 +77,9 @@ internal AliasOperations(SubscriptionClient client) /// Get Alias Subscription. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// Headers that will be added to request. @@ -98,13 +102,16 @@ internal AliasOperations(SubscriptionClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetWithHttpMessagesAsync(string aliasName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetWithHttpMessagesAsync(string aliasName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (aliasName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "aliasName"); } - string apiVersion = "2020-09-01"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -113,7 +120,6 @@ internal AliasOperations(SubscriptionClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("aliasName", aliasName); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); } @@ -122,9 +128,9 @@ internal AliasOperations(SubscriptionClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/aliases/{aliasName}").ToString(); _url = _url.Replace("{aliasName}", System.Uri.EscapeDataString(aliasName)); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -214,7 +220,7 @@ internal AliasOperations(SubscriptionClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -227,7 +233,7 @@ internal AliasOperations(SubscriptionClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -250,7 +256,9 @@ internal AliasOperations(SubscriptionClient client) /// Delete Alias. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// Headers that will be added to request. @@ -276,7 +284,10 @@ internal AliasOperations(SubscriptionClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "aliasName"); } - string apiVersion = "2020-09-01"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -285,7 +296,6 @@ internal AliasOperations(SubscriptionClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("aliasName", aliasName); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); } @@ -294,9 +304,9 @@ internal AliasOperations(SubscriptionClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/aliases/{aliasName}").ToString(); _url = _url.Replace("{aliasName}", System.Uri.EscapeDataString(aliasName)); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -401,7 +411,7 @@ internal AliasOperations(SubscriptionClient client) } /// - /// Get Alias Subscription. + /// List Alias Subscription. /// /// /// Headers that will be added to request. @@ -415,12 +425,21 @@ internal AliasOperations(SubscriptionClient client) /// /// 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)) + public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - string apiVersion = "2020-09-01"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -428,7 +447,6 @@ internal AliasOperations(SubscriptionClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); } @@ -436,9 +454,9 @@ internal AliasOperations(SubscriptionClient client) var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/aliases").ToString(); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -528,7 +546,7 @@ internal AliasOperations(SubscriptionClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -541,7 +559,7 @@ internal AliasOperations(SubscriptionClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -564,7 +582,9 @@ internal AliasOperations(SubscriptionClient client) /// Create Alias Subscription. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// @@ -589,7 +609,7 @@ internal AliasOperations(SubscriptionClient client) /// /// A response object containing the response body and response headers. /// - public async Task> BeginCreateWithHttpMessagesAsync(string aliasName, PutAliasRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> BeginCreateWithHttpMessagesAsync(string aliasName, PutAliasRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (aliasName == null) { @@ -599,11 +619,10 @@ internal AliasOperations(SubscriptionClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "body"); } - if (body != null) + if (Client.ApiVersion == null) { - body.Validate(); + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - string apiVersion = "2020-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -613,7 +632,6 @@ internal AliasOperations(SubscriptionClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("aliasName", aliasName); tracingParameters.Add("body", body); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); } @@ -622,9 +640,9 @@ internal AliasOperations(SubscriptionClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/aliases/{aliasName}").ToString(); _url = _url.Replace("{aliasName}", System.Uri.EscapeDataString(aliasName)); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -720,7 +738,7 @@ internal AliasOperations(SubscriptionClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -733,7 +751,7 @@ internal AliasOperations(SubscriptionClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -751,7 +769,7 @@ internal AliasOperations(SubscriptionClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/AliasOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/AliasOperationsExtensions.cs index fee4b4322264..20862a6bbae8 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/AliasOperationsExtensions.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/AliasOperationsExtensions.cs @@ -28,11 +28,13 @@ public static partial class AliasOperationsExtensions /// The operations group for this extension method. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// - public static PutAliasResponse Create(this IAliasOperations operations, string aliasName, PutAliasRequest body) + public static SubscriptionAliasResponse Create(this IAliasOperations operations, string aliasName, PutAliasRequest body) { return operations.CreateAsync(aliasName, body).GetAwaiter().GetResult(); } @@ -44,14 +46,16 @@ public static PutAliasResponse Create(this IAliasOperations operations, string a /// The operations group for this extension method. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// /// /// The cancellation token. /// - public static async Task CreateAsync(this IAliasOperations operations, string aliasName, PutAliasRequest body, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task CreateAsync(this IAliasOperations operations, string aliasName, PutAliasRequest body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateWithHttpMessagesAsync(aliasName, body, null, cancellationToken).ConfigureAwait(false)) { @@ -66,9 +70,11 @@ public static PutAliasResponse Create(this IAliasOperations operations, string a /// The operations group for this extension method. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// - public static PutAliasResponse Get(this IAliasOperations operations, string aliasName) + public static SubscriptionAliasResponse Get(this IAliasOperations operations, string aliasName) { return operations.GetAsync(aliasName).GetAwaiter().GetResult(); } @@ -80,12 +86,14 @@ public static PutAliasResponse Get(this IAliasOperations operations, string alia /// The operations group for this extension method. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// The cancellation token. /// - public static async Task GetAsync(this IAliasOperations operations, string aliasName, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task GetAsync(this IAliasOperations operations, string aliasName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetWithHttpMessagesAsync(aliasName, null, cancellationToken).ConfigureAwait(false)) { @@ -100,7 +108,9 @@ public static PutAliasResponse Get(this IAliasOperations operations, string alia /// The operations group for this extension method. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// public static void Delete(this IAliasOperations operations, string aliasName) { @@ -114,7 +124,9 @@ public static void Delete(this IAliasOperations operations, string aliasName) /// The operations group for this extension method. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// The cancellation token. @@ -125,18 +137,18 @@ public static void Delete(this IAliasOperations operations, string aliasName) } /// - /// Get Alias Subscription. + /// List Alias Subscription. /// /// /// The operations group for this extension method. /// - public static PutAliasListResult List(this IAliasOperations operations) + public static SubscriptionAliasListResult List(this IAliasOperations operations) { return operations.ListAsync().GetAwaiter().GetResult(); } /// - /// Get Alias Subscription. + /// List Alias Subscription. /// /// /// The operations group for this extension method. @@ -144,7 +156,7 @@ public static PutAliasListResult List(this IAliasOperations operations) /// /// The cancellation token. /// - public static async Task ListAsync(this IAliasOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task ListAsync(this IAliasOperations operations, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { @@ -159,11 +171,13 @@ public static PutAliasListResult List(this IAliasOperations operations) /// The operations group for this extension method. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// - public static PutAliasResponse BeginCreate(this IAliasOperations operations, string aliasName, PutAliasRequest body) + public static SubscriptionAliasResponse BeginCreate(this IAliasOperations operations, string aliasName, PutAliasRequest body) { return operations.BeginCreateAsync(aliasName, body).GetAwaiter().GetResult(); } @@ -175,14 +189,16 @@ public static PutAliasResponse BeginCreate(this IAliasOperations operations, str /// The operations group for this extension method. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note that this + /// is not the same as subscription name and this doesn’t have any other + /// lifecycle need beyond the request for subscription creation. /// /// /// /// /// The cancellation token. /// - public static async Task BeginCreateAsync(this IAliasOperations operations, string aliasName, PutAliasRequest body, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task BeginCreateAsync(this IAliasOperations operations, string aliasName, PutAliasRequest body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateWithHttpMessagesAsync(aliasName, body, null, cancellationToken).ConfigureAwait(false)) { diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/BillingAccountOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/BillingAccountOperations.cs new file mode 100644 index 000000000000..b072c758f75f --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/BillingAccountOperations.cs @@ -0,0 +1,231 @@ +// +// 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.Subscription +{ + 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; + + /// + /// BillingAccountOperations operations. + /// + internal partial class BillingAccountOperations : IServiceOperations, IBillingAccountOperations + { + /// + /// Initializes a new instance of the BillingAccountOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal BillingAccountOperations(SubscriptionClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SubscriptionClient + /// + public SubscriptionClient Client { get; private set; } + + /// + /// Get Billing Account Policy. + /// + /// + /// Billing Account Id. + /// + /// + /// 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> GetPolicyWithHttpMessagesAsync(string billingAccountId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (billingAccountId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); + } + 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("billingAccountId", billingAccountId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetPolicy", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default").ToString(); + _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); + 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 ErrorResponseBodyException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponseBody _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/subscription/Microsoft.Azure.Management.Subscription/src/Generated/BillingAccountOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/BillingAccountOperationsExtensions.cs new file mode 100644 index 000000000000..a80b42cfb9fa --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/BillingAccountOperationsExtensions.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.Subscription +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for BillingAccountOperations. + /// + public static partial class BillingAccountOperationsExtensions + { + /// + /// Get Billing Account Policy. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing Account Id. + /// + public static BillingAccountPoliciesResponse GetPolicy(this IBillingAccountOperations operations, string billingAccountId) + { + return operations.GetPolicyAsync(billingAccountId).GetAwaiter().GetResult(); + } + + /// + /// Get Billing Account Policy. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing Account Id. + /// + /// + /// The cancellation token. + /// + public static async Task GetPolicyAsync(this IBillingAccountOperations operations, string billingAccountId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetPolicyWithHttpMessagesAsync(billingAccountId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IAliasOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IAliasOperations.cs index cfa5b2242375..dfcbb75fb49f 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IAliasOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IAliasOperations.cs @@ -27,7 +27,10 @@ public partial interface IAliasOperations /// Create Alias Subscription. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note + /// that this is not the same as subscription name and this doesn’t + /// have any other lifecycle need beyond the request for subscription + /// creation. /// /// /// @@ -46,12 +49,15 @@ public partial interface IAliasOperations /// /// Thrown when a required parameter is null /// - Task> CreateWithHttpMessagesAsync(string aliasName, PutAliasRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> CreateWithHttpMessagesAsync(string aliasName, PutAliasRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Get Alias Subscription. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note + /// that this is not the same as subscription name and this doesn’t + /// have any other lifecycle need beyond the request for subscription + /// creation. /// /// /// The headers that will be added to request. @@ -68,12 +74,15 @@ public partial interface IAliasOperations /// /// Thrown when a required parameter is null /// - Task> GetWithHttpMessagesAsync(string aliasName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> GetWithHttpMessagesAsync(string aliasName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Delete Alias. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note + /// that this is not the same as subscription name and this doesn’t + /// have any other lifecycle need beyond the request for subscription + /// creation. /// /// /// The headers that will be added to request. @@ -89,7 +98,7 @@ public partial interface IAliasOperations /// Task DeleteWithHttpMessagesAsync(string aliasName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Get Alias Subscription. + /// List Alias Subscription. /// /// /// The headers that will be added to request. @@ -106,12 +115,15 @@ public partial interface IAliasOperations /// /// Thrown when a required parameter is null /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Create Alias Subscription. /// /// - /// Alias Name + /// AliasName is the name for the subscription creation request. Note + /// that this is not the same as subscription name and this doesn’t + /// have any other lifecycle need beyond the request for subscription + /// creation. /// /// /// @@ -130,6 +142,6 @@ public partial interface IAliasOperations /// /// Thrown when a required parameter is null /// - Task> BeginCreateWithHttpMessagesAsync(string aliasName, PutAliasRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> BeginCreateWithHttpMessagesAsync(string aliasName, PutAliasRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IBillingAccountOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IBillingAccountOperations.cs new file mode 100644 index 000000000000..f415da8bd98c --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IBillingAccountOperations.cs @@ -0,0 +1,49 @@ +// +// 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.Subscription +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// BillingAccountOperations operations. + /// + public partial interface IBillingAccountOperations + { + /// + /// Get Billing Account Policy. + /// + /// + /// Billing Account Id. + /// + /// + /// 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> GetPolicyWithHttpMessagesAsync(string billingAccountId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IOperations.cs index 12c0b63db81d..3373bfc7e5ec 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/IOperations.cs @@ -32,7 +32,7 @@ public partial interface IOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -41,6 +41,28 @@ public partial interface IOperations /// /// Thrown when a required parameter is null /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all of the available Microsoft.Subscription API operations. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionClient.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionClient.cs index 7bbd5b6ec520..b6c2bd14b3e3 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionClient.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionClient.cs @@ -40,6 +40,12 @@ public partial interface ISubscriptionClient : System.IDisposable /// ServiceClientCredentials Credentials { get; } + /// + /// Version of the API to be used with the client request. Current + /// version is 2021-10-01 + /// + string ApiVersion { get; } + /// /// The preferred language for the response. /// @@ -59,16 +65,6 @@ public partial interface ISubscriptionClient : System.IDisposable bool? GenerateClientRequestId { get; set; } - /// - /// Gets the ISubscriptionsOperations. - /// - ISubscriptionsOperations Subscriptions { get; } - - /// - /// Gets the ITenantsOperations. - /// - ITenantsOperations Tenants { get; } - /// /// Gets the ISubscriptionOperations. /// @@ -84,5 +80,15 @@ public partial interface ISubscriptionClient : System.IDisposable /// IAliasOperations Alias { get; } + /// + /// Gets the ISubscriptionPolicyOperations. + /// + ISubscriptionPolicyOperations SubscriptionPolicy { get; } + + /// + /// Gets the IBillingAccountOperations. + /// + IBillingAccountOperations BillingAccount { get; } + } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionOperations.cs index 6c2d5c395ffb..a5350718e382 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionOperations.cs @@ -35,7 +35,7 @@ public partial interface ISubscriptionOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -60,7 +60,7 @@ public partial interface ISubscriptionOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -82,7 +82,7 @@ public partial interface ISubscriptionOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -92,5 +92,69 @@ public partial interface ISubscriptionOperations /// Thrown when a required parameter is null /// Task> EnableWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Accept subscription ownership. + /// + /// + /// Subscription Id. + /// + /// + /// + /// + /// 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> AcceptOwnershipWithHttpMessagesAsync(string subscriptionId, AcceptOwnershipRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Accept subscription ownership status. + /// + /// + /// Subscription Id. + /// + /// + /// 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> AcceptOwnershipStatusWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Accept subscription ownership. + /// + /// + /// Subscription Id. + /// + /// + /// + /// + /// 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> BeginAcceptOwnershipWithHttpMessagesAsync(string subscriptionId, AcceptOwnershipRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionsOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionPolicyOperations.cs similarity index 64% rename from sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionsOperations.cs rename to sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionPolicyOperations.cs index db652373d0ed..8698a0b53de9 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionsOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionPolicyOperations.cs @@ -19,20 +19,14 @@ namespace Microsoft.Azure.Management.Subscription using System.Threading.Tasks; /// - /// SubscriptionsOperations operations. + /// SubscriptionPolicyOperations operations. /// - public partial interface ISubscriptionsOperations + public partial interface ISubscriptionPolicyOperations { /// - /// Gets all available geo-locations. + /// Create or Update Subscription tenant policy for user's tenant. /// - /// - /// This operation provides all the locations that are available for - /// resource providers; however, each resource provider may support a - /// subset of this list. - /// - /// - /// The ID of the target subscription. + /// /// /// /// The headers that will be added to request. @@ -40,7 +34,7 @@ public partial interface ISubscriptionsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -49,20 +43,17 @@ public partial interface ISubscriptionsOperations /// /// Thrown when a required parameter is null /// - Task>> ListLocationsWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> AddUpdatePolicyForTenantWithHttpMessagesAsync(PutTenantPolicyRequestProperties body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Gets details about a specified subscription. + /// Get the subscription tenant policy for the user's tenant. /// - /// - /// The ID of the target subscription. - /// /// /// The headers that will be added to request. /// /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -71,9 +62,9 @@ public partial interface ISubscriptionsOperations /// /// Thrown when a required parameter is null /// - Task> GetWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> GetPolicyForTenantWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Gets all subscriptions for a tenant. + /// Get the subscription tenant policy for the user's tenant. /// /// /// The headers that will be added to request. @@ -81,7 +72,7 @@ public partial interface ISubscriptionsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -90,9 +81,9 @@ public partial interface ISubscriptionsOperations /// /// Thrown when a required parameter is null /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListPolicyForTenantWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Gets all subscriptions for a tenant. + /// Get the subscription tenant policy for the user's tenant. /// /// /// The NextLink from the previous successful call to List operation. @@ -103,7 +94,7 @@ public partial interface ISubscriptionsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -112,6 +103,6 @@ public partial interface ISubscriptionsOperations /// /// Thrown when a required parameter is null /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListPolicyForTenantNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ITenantsOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ITenantsOperations.cs deleted file mode 100644 index c644814aa156..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ITenantsOperations.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// 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.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// TenantsOperations operations. - /// - public partial interface ITenantsOperations - { - /// - /// Gets the tenants for your 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>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the tenants for your account. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnership.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnership.cs new file mode 100644 index 000000000000..0eb3a4d45d99 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnership.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.Subscription.Models +{ + + /// + /// Defines values for AcceptOwnership. + /// + public static class AcceptOwnership + { + public const string Pending = "Pending"; + public const string Completed = "Completed"; + public const string Expired = "Expired"; + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnershipRequest.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnershipRequest.cs new file mode 100644 index 000000000000..9f74669ff4e2 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnershipRequest.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The parameters required to accept subscription ownership. + /// + public partial class AcceptOwnershipRequest + { + /// + /// Initializes a new instance of the AcceptOwnershipRequest class. + /// + public AcceptOwnershipRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AcceptOwnershipRequest class. + /// + /// Accept subscription ownership request + /// properties. + public AcceptOwnershipRequest(AcceptOwnershipRequestProperties properties = default(AcceptOwnershipRequestProperties)) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets accept subscription ownership request properties. + /// + [JsonProperty(PropertyName = "properties")] + public AcceptOwnershipRequestProperties Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnershipRequestProperties.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnershipRequestProperties.cs new file mode 100644 index 000000000000..a21e0f807ae3 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnershipRequestProperties.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Accept subscription ownership request properties. + /// + public partial class AcceptOwnershipRequestProperties + { + /// + /// Initializes a new instance of the AcceptOwnershipRequestProperties + /// class. + /// + public AcceptOwnershipRequestProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AcceptOwnershipRequestProperties + /// class. + /// + /// The friendly name of the + /// subscription. + /// Management group Id for the + /// subscription. + /// Tags for the subscription + public AcceptOwnershipRequestProperties(string displayName, string managementGroupId = default(string), IDictionary tags = default(IDictionary)) + { + DisplayName = displayName; + ManagementGroupId = managementGroupId; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the friendly name of the subscription. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets management group Id for the subscription. + /// + [JsonProperty(PropertyName = "managementGroupId")] + public string ManagementGroupId { get; set; } + + /// + /// Gets or sets tags for the subscription + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (DisplayName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DisplayName"); + } + } + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnershipStatusResponse.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnershipStatusResponse.cs new file mode 100644 index 000000000000..27185f5c89bb --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/AcceptOwnershipStatusResponse.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Subscription Accept Ownership Response + /// + public partial class AcceptOwnershipStatusResponse + { + /// + /// Initializes a new instance of the AcceptOwnershipStatusResponse + /// class. + /// + public AcceptOwnershipStatusResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AcceptOwnershipStatusResponse + /// class. + /// + /// Newly created subscription Id. + /// Possible values include: + /// 'Pending', 'Completed', 'Expired' + /// UPN of the billing owner + /// Tenant Id of the + /// subscription + /// The display name of the + /// subscription. + /// Tags for the subscription + public AcceptOwnershipStatusResponse(string subscriptionId = default(string), string acceptOwnershipState = default(string), string billingOwner = default(string), string subscriptionTenantId = default(string), string displayName = default(string), IDictionary tags = default(IDictionary)) + { + SubscriptionId = subscriptionId; + AcceptOwnershipState = acceptOwnershipState; + BillingOwner = billingOwner; + SubscriptionTenantId = subscriptionTenantId; + DisplayName = displayName; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets newly created subscription Id. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets or sets possible values include: 'Pending', 'Completed', + /// 'Expired' + /// + [JsonProperty(PropertyName = "acceptOwnershipState")] + public string AcceptOwnershipState { get; set; } + + /// + /// Gets UPN of the billing owner + /// + [JsonProperty(PropertyName = "billingOwner")] + public string BillingOwner { get; private set; } + + /// + /// Gets or sets tenant Id of the subscription + /// + [JsonProperty(PropertyName = "subscriptionTenantId")] + public string SubscriptionTenantId { get; set; } + + /// + /// Gets or sets the display name of the subscription. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets tags for the subscription + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/BillingAccountPoliciesResponse.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/BillingAccountPoliciesResponse.cs new file mode 100644 index 000000000000..517cf9a4431f --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/BillingAccountPoliciesResponse.cs @@ -0,0 +1,86 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Billing account policies information. + /// + public partial class BillingAccountPoliciesResponse : IResource + { + /// + /// Initializes a new instance of the BillingAccountPoliciesResponse + /// class. + /// + public BillingAccountPoliciesResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BillingAccountPoliciesResponse + /// class. + /// + /// Fully qualified ID for the policy. + /// Policy name. + /// Resource type. + /// Billing account policies response + /// properties. + public BillingAccountPoliciesResponse(string id = default(string), string name = default(string), string type = default(string), BillingAccountPoliciesResponseProperties properties = default(BillingAccountPoliciesResponseProperties), SystemData systemData = default(SystemData)) + { + Id = id; + Name = name; + Type = type; + Properties = properties; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets fully qualified ID for the policy. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets policy name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets billing account policies response properties. + /// + [JsonProperty(PropertyName = "properties")] + public BillingAccountPoliciesResponseProperties Properties { get; set; } + + /// + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/BillingAccountPoliciesResponseProperties.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/BillingAccountPoliciesResponseProperties.cs new file mode 100644 index 000000000000..4bab9c544a26 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/BillingAccountPoliciesResponseProperties.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Put billing account policies response properties. + /// + public partial class BillingAccountPoliciesResponseProperties + { + /// + /// Initializes a new instance of the + /// BillingAccountPoliciesResponseProperties class. + /// + public BillingAccountPoliciesResponseProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// BillingAccountPoliciesResponseProperties class. + /// + /// Service tenant for the billing + /// account. + /// Determine if the transfers are allowed + /// for the billing account + public BillingAccountPoliciesResponseProperties(IList serviceTenants = default(IList), bool? allowTransfers = default(bool?)) + { + ServiceTenants = serviceTenants; + AllowTransfers = allowTransfers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets service tenant for the billing account. + /// + [JsonProperty(PropertyName = "serviceTenants")] + public IList ServiceTenants { get; set; } + + /// + /// Gets or sets determine if the transfers are allowed for the billing + /// account + /// + [JsonProperty(PropertyName = "allowTransfers")] + public bool? AllowTransfers { get; set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/CreatedByType.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/CreatedByType.cs new file mode 100644 index 000000000000..2e8acb1c42fa --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/CreatedByType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + + /// + /// Defines values for CreatedByType. + /// + public static class CreatedByType + { + public const string User = "User"; + public const string Application = "Application"; + public const string ManagedIdentity = "ManagedIdentity"; + public const string Key = "Key"; + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ErrorResponseBody.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ErrorResponseBody.cs index 6675e261bc18..575909638a13 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ErrorResponseBody.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ErrorResponseBody.cs @@ -31,9 +31,14 @@ public ErrorResponseBody() /// Initializes a new instance of the ErrorResponseBody class. /// /// The details of the error. - public ErrorResponseBody(ErrorResponse error = default(ErrorResponse)) + /// Error code + /// Error message indicating why the operation + /// failed. + public ErrorResponseBody(ErrorResponse error = default(ErrorResponse), string code = default(string), string message = default(string)) { Error = error; + Code = code; + Message = message; CustomInit(); } @@ -48,5 +53,17 @@ public ErrorResponseBody() [JsonProperty(PropertyName = "error")] public ErrorResponse Error { get; set; } + /// + /// Gets or sets error code + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets error message indicating why the operation failed. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ErrorResponseException.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ErrorResponseException.cs deleted file mode 100644 index b2fd7ef8417d..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ErrorResponseException.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -// 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.Subscription.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/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/GetTenantPolicyResponse.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/GetTenantPolicyResponse.cs new file mode 100644 index 000000000000..7ca4b8bd48c8 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/GetTenantPolicyResponse.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.Subscription.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Tenant policy Information. + /// + public partial class GetTenantPolicyResponse : IResource + { + /// + /// Initializes a new instance of the GetTenantPolicyResponse class. + /// + public GetTenantPolicyResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GetTenantPolicyResponse class. + /// + /// Policy Id. + /// Policy name. + /// Resource type. + /// Tenant policy properties. + public GetTenantPolicyResponse(string id = default(string), string name = default(string), string type = default(string), TenantPolicy properties = default(TenantPolicy), SystemData systemData = default(SystemData)) + { + Id = id; + Name = name; + Type = type; + Properties = properties; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets policy Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets policy name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets tenant policy properties. + /// + [JsonProperty(PropertyName = "properties")] + public TenantPolicy Properties { get; set; } + + /// + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Location.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Location.cs deleted file mode 100644 index da2f8289c695..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Location.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// 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.Subscription.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Location information. - /// - public partial class Location - { - /// - /// Initializes a new instance of the Location class. - /// - public Location() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Location class. - /// - /// The fully qualified ID of the location. For - /// example, - /// /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. - /// The subscription ID. - /// The location name. - /// The display name of the location. - /// The latitude of the location. - /// The longitude of the location. - public Location(string id = default(string), string subscriptionId = default(string), string name = default(string), string displayName = default(string), string latitude = default(string), string longitude = default(string)) - { - Id = id; - SubscriptionId = subscriptionId; - Name = name; - DisplayName = displayName; - Latitude = latitude; - Longitude = longitude; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the fully qualified ID of the location. For example, - /// /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets the subscription ID. - /// - [JsonProperty(PropertyName = "subscriptionId")] - public string SubscriptionId { get; private set; } - - /// - /// Gets the location name. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets the display name of the location. - /// - [JsonProperty(PropertyName = "displayName")] - public string DisplayName { get; private set; } - - /// - /// Gets the latitude of the location. - /// - [JsonProperty(PropertyName = "latitude")] - public string Latitude { get; private set; } - - /// - /// Gets the longitude of the location. - /// - [JsonProperty(PropertyName = "longitude")] - public string Longitude { get; private set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Operation.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Operation.cs index 6ff91e6a10cc..a3b1d2c569e4 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Operation.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Operation.cs @@ -31,11 +31,14 @@ public Operation() /// /// Operation name: /// {provider}/{resource}/{operation} + /// Indicates whether the operation is a + /// data action /// The object that represents the /// operation. - public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay)) + public Operation(string name = default(string), bool? isDataAction = default(bool?), OperationDisplay display = default(OperationDisplay)) { Name = name; + IsDataAction = isDataAction; Display = display; CustomInit(); } @@ -51,6 +54,12 @@ public Operation() [JsonProperty(PropertyName = "name")] public string Name { get; set; } + /// + /// Gets or sets indicates whether the operation is a data action + /// + [JsonProperty(PropertyName = "isDataAction")] + public bool? IsDataAction { get; set; } + /// /// Gets or sets the object that represents the operation. /// diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/OperationDisplay.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/OperationDisplay.cs index 2245272581ed..a71aab35296d 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/OperationDisplay.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/OperationDisplay.cs @@ -35,11 +35,14 @@ public OperationDisplay() /// performed: Profile, endpoint, etc. /// Operation type: Read, write, delete, /// etc. - public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string)) + /// Localized friendly description for the + /// 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(); } @@ -67,5 +70,11 @@ public OperationDisplay() [JsonProperty(PropertyName = "operation")] public string Operation { get; set; } + /// + /// Gets or sets localized friendly description for the operation + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/OperationListResult.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/OperationListResult.cs deleted file mode 100644 index 22c1beb90f95..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/OperationListResult.cs +++ /dev/null @@ -1,64 +0,0 @@ -// -// 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.Subscription.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Result of the request to list operations. It contains a list of - /// operations and a URL link to get the next set of results. - /// - public partial class OperationListResult - { - /// - /// Initializes a new instance of the OperationListResult class. - /// - public OperationListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the OperationListResult class. - /// - /// List of operations. - /// URL to get the next set of operation list - /// results if there are any. - public OperationListResult(IList value = default(IList), string nextLink = default(string)) - { - Value = value; - NextLink = nextLink; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets list of operations. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - /// - /// Gets or sets URL to get the next set of operation list results if - /// there are any. - /// - [JsonProperty(PropertyName = "nextLink")] - public string NextLink { get; set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page.cs index b7b259149ab9..fb0038913603 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page.cs @@ -26,7 +26,7 @@ public class Page : IPage /// /// Gets the link to the next page. /// - [JsonProperty("")] + [JsonProperty("nextLink")] public string NextPageLink { get; private set; } [JsonProperty("value")] diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page1.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page1.cs deleted file mode 100644 index 9d88e45ba683..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page1.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// 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.Subscription.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 Page1 : IPage - { - /// - /// Gets the link to the next page. - /// - [JsonProperty("nextLink")] - public string NextPageLink { get; private set; } - - [JsonProperty("value")] - private IList Items{ get; set; } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - public IEnumerator GetEnumerator() - { - return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequest.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequest.cs index c5616ceaa743..9f9dc8f4d105 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequest.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequest.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.Subscription.Models { - using Microsoft.Rest; using Newtonsoft.Json; using System.Linq; @@ -31,7 +30,7 @@ public PutAliasRequest() /// Initializes a new instance of the PutAliasRequest class. /// /// Put alias request properties. - public PutAliasRequest(PutAliasRequestProperties properties) + public PutAliasRequest(PutAliasRequestProperties properties = default(PutAliasRequestProperties)) { Properties = properties; CustomInit(); @@ -48,18 +47,5 @@ public PutAliasRequest(PutAliasRequestProperties properties) [JsonProperty(PropertyName = "properties")] public PutAliasRequestProperties Properties { get; set; } - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Properties == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Properties"); - } - } } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequestAdditionalProperties.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequestAdditionalProperties.cs new file mode 100644 index 000000000000..c5c3eed343e2 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequestAdditionalProperties.cs @@ -0,0 +1,82 @@ +// +// 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.Subscription.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Put subscription additional properties. + /// + public partial class PutAliasRequestAdditionalProperties + { + /// + /// Initializes a new instance of the + /// PutAliasRequestAdditionalProperties class. + /// + public PutAliasRequestAdditionalProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PutAliasRequestAdditionalProperties class. + /// + /// Management group Id for the + /// subscription. + /// Tenant Id of the + /// subscription + /// Owner Id of the + /// subscription + /// Tags for the subscription + public PutAliasRequestAdditionalProperties(string managementGroupId = default(string), string subscriptionTenantId = default(string), string subscriptionOwnerId = default(string), IDictionary tags = default(IDictionary)) + { + ManagementGroupId = managementGroupId; + SubscriptionTenantId = subscriptionTenantId; + SubscriptionOwnerId = subscriptionOwnerId; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets management group Id for the subscription. + /// + [JsonProperty(PropertyName = "managementGroupId")] + public string ManagementGroupId { get; set; } + + /// + /// Gets or sets tenant Id of the subscription + /// + [JsonProperty(PropertyName = "subscriptionTenantId")] + public string SubscriptionTenantId { get; set; } + + /// + /// Gets or sets owner Id of the subscription + /// + [JsonProperty(PropertyName = "subscriptionOwnerId")] + public string SubscriptionOwnerId { get; set; } + + /// + /// Gets or sets tags for the subscription + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequestProperties.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequestProperties.cs index dc803b7b3409..25437858bacb 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequestProperties.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasRequestProperties.cs @@ -31,21 +31,21 @@ public PutAliasRequestProperties() /// /// The friendly name of the /// subscription. - /// The workload type of the subscription. It - /// can be either Production or DevTest. Possible values include: - /// 'Production', 'DevTest' - /// Determines whether subscription is - /// fieldLed, partnerLed or LegacyEA + /// Possible values include: 'Production', + /// 'DevTest' /// This parameter can be used to create /// alias for existing subscription Id - /// Reseller ID, basically MPN Id - public PutAliasRequestProperties(string displayName = default(string), string workload = default(string), string billingScope = default(string), string subscriptionId = default(string), string resellerId = default(string)) + /// Reseller Id + /// Put alias request additional + /// properties. + public PutAliasRequestProperties(string displayName = default(string), string workload = default(string), string billingScope = default(string), string subscriptionId = default(string), string resellerId = default(string), PutAliasRequestAdditionalProperties additionalProperties = default(PutAliasRequestAdditionalProperties)) { DisplayName = displayName; Workload = workload; BillingScope = billingScope; SubscriptionId = subscriptionId; ResellerId = resellerId; + AdditionalProperties = additionalProperties; CustomInit(); } @@ -61,16 +61,12 @@ public PutAliasRequestProperties() public string DisplayName { get; set; } /// - /// Gets or sets the workload type of the subscription. It can be - /// either Production or DevTest. Possible values include: - /// 'Production', 'DevTest' + /// Gets or sets possible values include: 'Production', 'DevTest' /// [JsonProperty(PropertyName = "workload")] public string Workload { get; set; } /// - /// Gets or sets determines whether subscription is fieldLed, - /// partnerLed or LegacyEA /// [JsonProperty(PropertyName = "billingScope")] public string BillingScope { get; set; } @@ -83,10 +79,16 @@ public PutAliasRequestProperties() public string SubscriptionId { get; set; } /// - /// Gets or sets reseller ID, basically MPN Id + /// Gets or sets reseller Id /// [JsonProperty(PropertyName = "resellerId")] public string ResellerId { get; set; } + /// + /// Gets or sets put alias request additional properties. + /// + [JsonProperty(PropertyName = "additionalProperties")] + public PutAliasRequestAdditionalProperties AdditionalProperties { get; set; } + } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasResponseProperties.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasResponseProperties.cs deleted file mode 100644 index 180d517ee36e..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasResponseProperties.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -// 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.Subscription.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Put subscription creation result properties. - /// - public partial class PutAliasResponseProperties - { - /// - /// Initializes a new instance of the PutAliasResponseProperties class. - /// - public PutAliasResponseProperties() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PutAliasResponseProperties class. - /// - /// Newly created subscription Id. - /// The provisioning state of the - /// resource. Possible values include: 'Accepted', 'Succeeded', - /// 'Failed' - public PutAliasResponseProperties(string subscriptionId = default(string), string provisioningState = default(string)) - { - SubscriptionId = subscriptionId; - ProvisioningState = provisioningState; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets newly created subscription Id. - /// - [JsonProperty(PropertyName = "subscriptionId")] - public string SubscriptionId { get; private set; } - - /// - /// Gets or sets the provisioning state of the resource. Possible - /// values include: 'Accepted', 'Succeeded', 'Failed' - /// - [JsonProperty(PropertyName = "provisioningState")] - public string ProvisioningState { get; set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutTenantPolicyRequestProperties.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutTenantPolicyRequestProperties.cs new file mode 100644 index 000000000000..2e6b029360a1 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutTenantPolicyRequestProperties.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.Subscription.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Put tenant policy request properties. + /// + public partial class PutTenantPolicyRequestProperties + { + /// + /// Initializes a new instance of the PutTenantPolicyRequestProperties + /// class. + /// + public PutTenantPolicyRequestProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PutTenantPolicyRequestProperties + /// class. + /// + /// Blocks the leaving of + /// subscriptions from user's tenant. + /// Blocks the entering of + /// subscriptions into user's tenant. + /// List of user objectIds that are + /// exempted from the set subscription tenant policies for the user's + /// tenant. + public PutTenantPolicyRequestProperties(bool? blockSubscriptionsLeavingTenant = default(bool?), bool? blockSubscriptionsIntoTenant = default(bool?), IList exemptedPrincipals = default(IList)) + { + BlockSubscriptionsLeavingTenant = blockSubscriptionsLeavingTenant; + BlockSubscriptionsIntoTenant = blockSubscriptionsIntoTenant; + ExemptedPrincipals = exemptedPrincipals; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets blocks the leaving of subscriptions from user's + /// tenant. + /// + [JsonProperty(PropertyName = "blockSubscriptionsLeavingTenant")] + public bool? BlockSubscriptionsLeavingTenant { get; set; } + + /// + /// Gets or sets blocks the entering of subscriptions into user's + /// tenant. + /// + [JsonProperty(PropertyName = "blockSubscriptionsIntoTenant")] + public bool? BlockSubscriptionsIntoTenant { get; set; } + + /// + /// Gets or sets list of user objectIds that are exempted from the set + /// subscription tenant policies for the user's tenant. + /// + [JsonProperty(PropertyName = "exemptedPrincipals")] + public IList ExemptedPrincipals { get; set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantIdDescription.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ServiceTenantResponse.cs similarity index 50% rename from sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantIdDescription.cs rename to sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ServiceTenantResponse.cs index ad20b421ddf6..5d5452801875 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantIdDescription.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ServiceTenantResponse.cs @@ -14,29 +14,27 @@ namespace Microsoft.Azure.Management.Subscription.Models using System.Linq; /// - /// Tenant Id information. + /// Billing account service tenant. /// - public partial class TenantIdDescription + public partial class ServiceTenantResponse { /// - /// Initializes a new instance of the TenantIdDescription class. + /// Initializes a new instance of the ServiceTenantResponse class. /// - public TenantIdDescription() + public ServiceTenantResponse() { CustomInit(); } /// - /// Initializes a new instance of the TenantIdDescription class. + /// Initializes a new instance of the ServiceTenantResponse class. /// - /// The fully qualified ID of the tenant. For example, - /// /tenants/00000000-0000-0000-0000-000000000000. - /// The tenant ID. For example, - /// 00000000-0000-0000-0000-000000000000. - public TenantIdDescription(string id = default(string), string tenantId = default(string)) + /// Service tenant id. + /// Service tenant name. + public ServiceTenantResponse(string tenantId = default(string), string tenantName = default(string)) { - Id = id; TenantId = tenantId; + TenantName = tenantName; CustomInit(); } @@ -46,18 +44,16 @@ public TenantIdDescription() partial void CustomInit(); /// - /// Gets the fully qualified ID of the tenant. For example, - /// /tenants/00000000-0000-0000-0000-000000000000. + /// Gets or sets service tenant id. /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; set; } /// - /// Gets the tenant ID. For example, - /// 00000000-0000-0000-0000-000000000000. + /// Gets or sets service tenant name. /// - [JsonProperty(PropertyName = "tenantId")] - public string TenantId { get; private set; } + [JsonProperty(PropertyName = "tenantName")] + public string TenantName { get; set; } } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SpendingLimit.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SpendingLimit.cs deleted file mode 100644 index b99c7dd697bb..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SpendingLimit.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -// 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.Subscription.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for SpendingLimit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum SpendingLimit - { - [EnumMember(Value = "On")] - On, - [EnumMember(Value = "Off")] - Off, - [EnumMember(Value = "CurrentPeriodOff")] - CurrentPeriodOff - } - internal static class SpendingLimitEnumExtension - { - internal static string ToSerializedValue(this SpendingLimit? value) - { - return value == null ? null : ((SpendingLimit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this SpendingLimit value) - { - switch( value ) - { - case SpendingLimit.On: - return "On"; - case SpendingLimit.Off: - return "Off"; - case SpendingLimit.CurrentPeriodOff: - return "CurrentPeriodOff"; - } - return null; - } - - internal static SpendingLimit? ParseSpendingLimit(this string value) - { - switch( value ) - { - case "On": - return SpendingLimit.On; - case "Off": - return SpendingLimit.Off; - case "CurrentPeriodOff": - return SpendingLimit.CurrentPeriodOff; - } - return null; - } - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAcceptOwnershipHeaders.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAcceptOwnershipHeaders.cs new file mode 100644 index 000000000000..475c347bdc97 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAcceptOwnershipHeaders.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for AcceptOwnership operation. + /// + public partial class SubscriptionAcceptOwnershipHeaders + { + /// + /// Initializes a new instance of the + /// SubscriptionAcceptOwnershipHeaders class. + /// + public SubscriptionAcceptOwnershipHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SubscriptionAcceptOwnershipHeaders class. + /// + /// GET this URL to retrieve the status of the + /// asynchronous operation. + /// The amount of delay to use while the + /// status of the operation is checked. The value is expressed in + /// seconds. + public SubscriptionAcceptOwnershipHeaders(string location = default(string), int? retryAfter = default(int?)) + { + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets GET this URL to retrieve the status of the + /// asynchronous operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets the amount of delay to use while the status of the + /// operation is checked. The value is expressed in seconds. + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasListResult.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAliasListResult.cs similarity index 74% rename from sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasListResult.cs rename to sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAliasListResult.cs index 043dfbff2ba3..a840ef7c0f14 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasListResult.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAliasListResult.cs @@ -18,23 +18,25 @@ namespace Microsoft.Azure.Management.Subscription.Models /// /// The list of aliases. /// - public partial class PutAliasListResult + public partial class SubscriptionAliasListResult { /// - /// Initializes a new instance of the PutAliasListResult class. + /// Initializes a new instance of the SubscriptionAliasListResult + /// class. /// - public PutAliasListResult() + public SubscriptionAliasListResult() { CustomInit(); } /// - /// Initializes a new instance of the PutAliasListResult class. + /// Initializes a new instance of the SubscriptionAliasListResult + /// class. /// /// The list of alias. /// The link (url) to the next page of /// results. - public PutAliasListResult(IList value = default(IList), string nextLink = default(string)) + public SubscriptionAliasListResult(IList value = default(IList), string nextLink = default(string)) { Value = value; NextLink = nextLink; @@ -50,7 +52,7 @@ public PutAliasListResult() /// Gets the list of alias. /// [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } + public IList Value { get; private set; } /// /// Gets the link (url) to the next page of results. diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasResponse.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAliasResponse.cs similarity index 67% rename from sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasResponse.cs rename to sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAliasResponse.cs index 4c0baaeb7dd2..6dd6555313db 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/PutAliasResponse.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAliasResponse.cs @@ -18,30 +18,32 @@ namespace Microsoft.Azure.Management.Subscription.Models /// /// Subscription Information with the alias. /// - public partial class PutAliasResponse : IResource + public partial class SubscriptionAliasResponse : IResource { /// - /// Initializes a new instance of the PutAliasResponse class. + /// Initializes a new instance of the SubscriptionAliasResponse class. /// - public PutAliasResponse() + public SubscriptionAliasResponse() { CustomInit(); } /// - /// Initializes a new instance of the PutAliasResponse class. + /// Initializes a new instance of the SubscriptionAliasResponse class. /// /// Fully qualified ID for the alias resource. /// Alias ID. /// Resource type, /// Microsoft.Subscription/aliases. - /// Put Alias response properties. - public PutAliasResponse(string id = default(string), string name = default(string), string type = default(string), PutAliasResponseProperties properties = default(PutAliasResponseProperties)) + /// Subscription Alias response + /// properties. + public SubscriptionAliasResponse(string id = default(string), string name = default(string), string type = default(string), SubscriptionAliasResponseProperties properties = default(SubscriptionAliasResponseProperties), SystemData systemData = default(SystemData)) { Id = id; Name = name; Type = type; Properties = properties; + SystemData = systemData; CustomInit(); } @@ -69,10 +71,15 @@ public PutAliasResponse() public string Type { get; private set; } /// - /// Gets or sets put Alias response properties. + /// Gets or sets subscription Alias response properties. /// [JsonProperty(PropertyName = "properties")] - public PutAliasResponseProperties Properties { get; set; } + public SubscriptionAliasResponseProperties Properties { get; set; } + + /// + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAliasResponseProperties.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAliasResponseProperties.cs new file mode 100644 index 000000000000..27d78abed3cb --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionAliasResponseProperties.cs @@ -0,0 +1,142 @@ +// +// 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.Subscription.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Put subscription creation result properties. + /// + public partial class SubscriptionAliasResponseProperties + { + /// + /// Initializes a new instance of the + /// SubscriptionAliasResponseProperties class. + /// + public SubscriptionAliasResponseProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SubscriptionAliasResponseProperties class. + /// + /// Newly created subscription Id. + /// The display name of the + /// subscription. + /// The provisioning state of the + /// resource. Possible values include: 'Accepted', 'Succeeded', + /// 'Failed' + /// Url to accept ownership of the + /// subscription. + /// Possible values include: + /// 'Pending', 'Completed', 'Expired' + /// Possible values include: 'Production', + /// 'DevTest' + /// Reseller Id + /// Owner Id of the + /// subscription + /// The Management Group Id. + /// Tags for the subscription + public SubscriptionAliasResponseProperties(string subscriptionId = default(string), string displayName = default(string), string provisioningState = default(string), string acceptOwnershipUrl = default(string), string acceptOwnershipState = default(string), string billingScope = default(string), string workload = default(string), string resellerId = default(string), string subscriptionOwnerId = default(string), string managementGroupId = default(string), IDictionary tags = default(IDictionary)) + { + SubscriptionId = subscriptionId; + DisplayName = displayName; + ProvisioningState = provisioningState; + AcceptOwnershipUrl = acceptOwnershipUrl; + AcceptOwnershipState = acceptOwnershipState; + BillingScope = billingScope; + Workload = workload; + ResellerId = resellerId; + SubscriptionOwnerId = subscriptionOwnerId; + ManagementGroupId = managementGroupId; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets newly created subscription Id. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets or sets the display name of the subscription. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the provisioning state of the resource. Possible + /// values include: 'Accepted', 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets url to accept ownership of the subscription. + /// + [JsonProperty(PropertyName = "acceptOwnershipUrl")] + public string AcceptOwnershipUrl { get; private set; } + + /// + /// Gets or sets possible values include: 'Pending', 'Completed', + /// 'Expired' + /// + [JsonProperty(PropertyName = "acceptOwnershipState")] + public string AcceptOwnershipState { get; set; } + + /// + /// + [JsonProperty(PropertyName = "billingScope")] + public string BillingScope { get; set; } + + /// + /// Gets or sets possible values include: 'Production', 'DevTest' + /// + [JsonProperty(PropertyName = "workload")] + public string Workload { get; set; } + + /// + /// Gets or sets reseller Id + /// + [JsonProperty(PropertyName = "resellerId")] + public string ResellerId { get; set; } + + /// + /// Gets or sets owner Id of the subscription + /// + [JsonProperty(PropertyName = "subscriptionOwnerId")] + public string SubscriptionOwnerId { get; set; } + + /// + /// Gets or sets the Management Group Id. + /// + [JsonProperty(PropertyName = "managementGroupId")] + public string ManagementGroupId { get; set; } + + /// + /// Gets or sets tags for the subscription + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionModel.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionModel.cs deleted file mode 100644 index 58b6ccf61b5b..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionModel.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// 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.Subscription.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Subscription information. - /// - public partial class SubscriptionModel - { - /// - /// Initializes a new instance of the SubscriptionModel class. - /// - public SubscriptionModel() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SubscriptionModel class. - /// - /// The fully qualified ID for the subscription. For - /// example, - /// /subscriptions/00000000-0000-0000-0000-000000000000. - /// The subscription ID. - /// The subscription display name. - /// The subscription state. Possible values are - /// Enabled, Warned, PastDue, Disabled, and Deleted. Possible values - /// include: 'Enabled', 'Warned', 'PastDue', 'Disabled', - /// 'Deleted' - /// The subscription - /// policies. - /// The authorization source of the - /// request. Valid values are one or more combinations of Legacy, - /// RoleBased, Bypassed, Direct and Management. For example, 'Legacy, - /// RoleBased'. - public SubscriptionModel(string id = default(string), string subscriptionId = default(string), string displayName = default(string), SubscriptionState? state = default(SubscriptionState?), SubscriptionPolicies subscriptionPolicies = default(SubscriptionPolicies), string authorizationSource = default(string)) - { - Id = id; - SubscriptionId = subscriptionId; - DisplayName = displayName; - State = state; - SubscriptionPolicies = subscriptionPolicies; - AuthorizationSource = authorizationSource; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the fully qualified ID for the subscription. For example, - /// /subscriptions/00000000-0000-0000-0000-000000000000. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets the subscription ID. - /// - [JsonProperty(PropertyName = "subscriptionId")] - public string SubscriptionId { get; private set; } - - /// - /// Gets the subscription display name. - /// - [JsonProperty(PropertyName = "displayName")] - public string DisplayName { get; private set; } - - /// - /// Gets the subscription state. Possible values are Enabled, Warned, - /// PastDue, Disabled, and Deleted. Possible values include: 'Enabled', - /// 'Warned', 'PastDue', 'Disabled', 'Deleted' - /// - [JsonProperty(PropertyName = "state")] - public SubscriptionState? State { get; private set; } - - /// - /// Gets or sets the subscription policies. - /// - [JsonProperty(PropertyName = "subscriptionPolicies")] - public SubscriptionPolicies SubscriptionPolicies { get; set; } - - /// - /// Gets or sets the authorization source of the request. Valid values - /// are one or more combinations of Legacy, RoleBased, Bypassed, Direct - /// and Management. For example, 'Legacy, RoleBased'. - /// - [JsonProperty(PropertyName = "authorizationSource")] - public string AuthorizationSource { get; set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionPolicies.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionPolicies.cs deleted file mode 100644 index 78258171c630..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionPolicies.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -// 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.Subscription.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Subscription policies. - /// - public partial class SubscriptionPolicies - { - /// - /// Initializes a new instance of the SubscriptionPolicies class. - /// - public SubscriptionPolicies() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SubscriptionPolicies class. - /// - /// The subscription location - /// placement ID. The ID indicates which regions are visible for a - /// subscription. For example, a subscription with a location placement - /// Id of Public_2014-09-01 has access to Azure public regions. - /// The subscription quota ID. - /// The subscription spending limit. - /// Possible values include: 'On', 'Off', 'CurrentPeriodOff' - public SubscriptionPolicies(string locationPlacementId = default(string), string quotaId = default(string), SpendingLimit? spendingLimit = default(SpendingLimit?)) - { - LocationPlacementId = locationPlacementId; - QuotaId = quotaId; - SpendingLimit = spendingLimit; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the subscription location placement ID. The ID indicates which - /// regions are visible for a subscription. For example, a subscription - /// with a location placement Id of Public_2014-09-01 has access to - /// Azure public regions. - /// - [JsonProperty(PropertyName = "locationPlacementId")] - public string LocationPlacementId { get; private set; } - - /// - /// Gets the subscription quota ID. - /// - [JsonProperty(PropertyName = "quotaId")] - public string QuotaId { get; private set; } - - /// - /// Gets the subscription spending limit. Possible values include: - /// 'On', 'Off', 'CurrentPeriodOff' - /// - [JsonProperty(PropertyName = "spendingLimit")] - public SpendingLimit? SpendingLimit { get; private set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionState.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionState.cs deleted file mode 100644 index 155901fb698f..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionState.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -// 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.Subscription.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for SubscriptionState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum SubscriptionState - { - [EnumMember(Value = "Enabled")] - Enabled, - [EnumMember(Value = "Warned")] - Warned, - [EnumMember(Value = "PastDue")] - PastDue, - [EnumMember(Value = "Disabled")] - Disabled, - [EnumMember(Value = "Deleted")] - Deleted - } - internal static class SubscriptionStateEnumExtension - { - internal static string ToSerializedValue(this SubscriptionState? value) - { - return value == null ? null : ((SubscriptionState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this SubscriptionState value) - { - switch( value ) - { - case SubscriptionState.Enabled: - return "Enabled"; - case SubscriptionState.Warned: - return "Warned"; - case SubscriptionState.PastDue: - return "PastDue"; - case SubscriptionState.Disabled: - return "Disabled"; - case SubscriptionState.Deleted: - return "Deleted"; - } - return null; - } - - internal static SubscriptionState? ParseSubscriptionState(this string value) - { - switch( value ) - { - case "Enabled": - return SubscriptionState.Enabled; - case "Warned": - return SubscriptionState.Warned; - case "PastDue": - return SubscriptionState.PastDue; - case "Disabled": - return SubscriptionState.Disabled; - case "Deleted": - return SubscriptionState.Deleted; - } - return null; - } - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SystemData.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SystemData.cs new file mode 100644 index 000000000000..e97b7befd960 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SystemData.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Metadata pertaining to creation and last modification of the resource. + /// + public partial class SystemData + { + /// + /// Initializes a new instance of the SystemData class. + /// + public SystemData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemData class. + /// + /// The identity that created the + /// resource. + /// The type of identity that created the + /// resource. Possible values include: 'User', 'Application', + /// 'ManagedIdentity', 'Key' + /// The timestamp of resource creation + /// (UTC). + /// The identity that last modified the + /// resource. + /// The type of identity that last + /// modified the resource. Possible values include: 'User', + /// 'Application', 'ManagedIdentity', 'Key' + /// The timestamp of resource last + /// modification (UTC) + public SystemData(string createdBy = default(string), string createdByType = default(string), System.DateTime? createdAt = default(System.DateTime?), string lastModifiedBy = default(string), string lastModifiedByType = default(string), System.DateTime? lastModifiedAt = default(System.DateTime?)) + { + CreatedBy = createdBy; + CreatedByType = createdByType; + CreatedAt = createdAt; + LastModifiedBy = lastModifiedBy; + LastModifiedByType = lastModifiedByType; + LastModifiedAt = lastModifiedAt; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity that created the resource. + /// + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets the type of identity that created the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "createdByType")] + public string CreatedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource creation (UTC). + /// + [JsonProperty(PropertyName = "createdAt")] + public System.DateTime? CreatedAt { get; set; } + + /// + /// Gets or sets the identity that last modified the resource. + /// + [JsonProperty(PropertyName = "lastModifiedBy")] + public string LastModifiedBy { get; set; } + + /// + /// Gets or sets the type of identity that last modified the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "lastModifiedByType")] + public string LastModifiedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource last modification (UTC) + /// + [JsonProperty(PropertyName = "lastModifiedAt")] + public System.DateTime? LastModifiedAt { get; set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantPolicy.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantPolicy.cs new file mode 100644 index 000000000000..3f555da833f8 --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantPolicy.cs @@ -0,0 +1,84 @@ +// +// 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.Subscription.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tenant policy. + /// + public partial class TenantPolicy + { + /// + /// Initializes a new instance of the TenantPolicy class. + /// + public TenantPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TenantPolicy class. + /// + /// Policy Id. + /// Blocks the leaving of + /// subscriptions from user's tenant. + /// Blocks the entering of + /// subscriptions into user's tenant. + /// List of user objectIds that are + /// exempted from the set subscription tenant policies for the user's + /// tenant. + public TenantPolicy(string policyId = default(string), bool? blockSubscriptionsLeavingTenant = default(bool?), bool? blockSubscriptionsIntoTenant = default(bool?), IList exemptedPrincipals = default(IList)) + { + PolicyId = policyId; + BlockSubscriptionsLeavingTenant = blockSubscriptionsLeavingTenant; + BlockSubscriptionsIntoTenant = blockSubscriptionsIntoTenant; + ExemptedPrincipals = exemptedPrincipals; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets policy Id. + /// + [JsonProperty(PropertyName = "policyId")] + public string PolicyId { get; private set; } + + /// + /// Gets or sets blocks the leaving of subscriptions from user's + /// tenant. + /// + [JsonProperty(PropertyName = "blockSubscriptionsLeavingTenant")] + public bool? BlockSubscriptionsLeavingTenant { get; set; } + + /// + /// Gets or sets blocks the entering of subscriptions into user's + /// tenant. + /// + [JsonProperty(PropertyName = "blockSubscriptionsIntoTenant")] + public bool? BlockSubscriptionsIntoTenant { get; set; } + + /// + /// Gets or sets list of user objectIds that are exempted from the set + /// subscription tenant policies for the user's tenant. + /// + [JsonProperty(PropertyName = "exemptedPrincipals")] + public IList ExemptedPrincipals { get; set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Operations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Operations.cs index 4bfea45641e4..634a69094499 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Operations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Operations.cs @@ -59,18 +59,27 @@ internal Operations(SubscriptionClient client) /// /// 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)) + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - string apiVersion = "2020-09-01"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -78,7 +87,6 @@ internal Operations(SubscriptionClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); } @@ -86,10 +94,178 @@ internal Operations(SubscriptionClient client) var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/operations").ToString(); List _queryParameters = new List(); - if (apiVersion != null) + 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 ErrorResponseBodyException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponseBody _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; + } + + /// + /// Lists all of the available Microsoft.Subscription API operations. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); @@ -150,11 +326,11 @@ internal Operations(SubscriptionClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseBodyException(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); + ErrorResponseBody _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex.Body = _errorBody; @@ -178,7 +354,7 @@ internal Operations(SubscriptionClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -191,7 +367,7 @@ internal Operations(SubscriptionClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/OperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/OperationsExtensions.cs index 32eafb86f429..5b1f6d71ec72 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/OperationsExtensions.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/OperationsExtensions.cs @@ -27,7 +27,7 @@ public static partial class OperationsExtensions /// /// The operations group for this extension method. /// - public static OperationListResult List(this IOperations operations) + public static IPage List(this IOperations operations) { return operations.ListAsync().GetAwaiter().GetResult(); } @@ -41,7 +41,7 @@ public static OperationListResult List(this IOperations operations) /// /// The cancellation token. /// - public static async Task ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { @@ -49,5 +49,39 @@ public static OperationListResult List(this IOperations operations) } } + /// + /// Lists all of the available Microsoft.Subscription API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Microsoft.Subscription API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SdkInfo_SubscriptionClient.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SdkInfo_SubscriptionClient.cs index c5fa9c1d9f5a..9b04abe83d8d 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SdkInfo_SubscriptionClient.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SdkInfo_SubscriptionClient.cs @@ -19,24 +19,13 @@ public static IEnumerable> ApiInfo_SubscriptionCli { return new Tuple[] { - new Tuple("Subscription", "Alias", "2020-09-01"), - new Tuple("Subscription", "Operations", "2020-09-01"), - new Tuple("Subscription", "Subscription", "2020-09-01"), - new Tuple("SubscriptionClient", "Subscriptions", "2016-06-01"), - new Tuple("SubscriptionClient", "Tenants", "2016-06-01"), + new Tuple("Billing", "BillingAccount", "2021-10-01"), + new Tuple("Subscription", "Alias", "2021-10-01"), + new Tuple("Subscription", "Operations", "2021-10-01"), + new Tuple("Subscription", "Subscription", "2021-10-01"), + new Tuple("Subscription", "SubscriptionPolicy", "2021-10-01"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/subscription/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=C:\\github2\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "a2f45d8b74aa5def295b86ffceecdeb27b8e1602"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } - diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionClient.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionClient.cs index 9507c4496060..bfc923c3f24f 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionClient.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionClient.cs @@ -46,6 +46,12 @@ public partial class SubscriptionClient : ServiceClient, ISu /// public ServiceClientCredentials Credentials { get; private set; } + /// + /// Version of the API to be used with the client request. Current version is + /// 2021-10-01 + /// + public string ApiVersion { get; private set; } + /// /// The preferred language for the response. /// @@ -64,16 +70,6 @@ public partial class SubscriptionClient : ServiceClient, ISu /// public bool? GenerateClientRequestId { get; set; } - /// - /// Gets the ISubscriptionsOperations. - /// - public virtual ISubscriptionsOperations Subscriptions { get; private set; } - - /// - /// Gets the ITenantsOperations. - /// - public virtual ITenantsOperations Tenants { get; private set; } - /// /// Gets the ISubscriptionOperations. /// @@ -89,6 +85,16 @@ public partial class SubscriptionClient : ServiceClient, ISu /// public virtual IAliasOperations Alias { get; private set; } + /// + /// Gets the ISubscriptionPolicyOperations. + /// + public virtual ISubscriptionPolicyOperations SubscriptionPolicy { get; private set; } + + /// + /// Gets the IBillingAccountOperations. + /// + public virtual IBillingAccountOperations BillingAccount { get; private set; } + /// /// Initializes a new instance of the SubscriptionClient class. /// @@ -330,12 +336,13 @@ public SubscriptionClient(System.Uri baseUri, ServiceClientCredentials credentia /// private void Initialize() { - Subscriptions = new SubscriptionsOperations(this); - Tenants = new TenantsOperations(this); Subscription = new SubscriptionOperations(this); Operations = new Operations(this); Alias = new AliasOperations(this); + SubscriptionPolicy = new SubscriptionPolicyOperations(this); + BillingAccount = new BillingAccountOperations(this); BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2021-10-01"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperations.cs index b597649f41b4..19530c9a477e 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperations.cs @@ -62,7 +62,7 @@ internal SubscriptionOperations(SubscriptionClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -83,7 +83,10 @@ internal SubscriptionOperations(SubscriptionClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); } - string apiVersion = "2020-09-01"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -92,7 +95,6 @@ internal SubscriptionOperations(SubscriptionClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("subscriptionId", subscriptionId); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Cancel", tracingParameters); } @@ -101,9 +103,9 @@ internal SubscriptionOperations(SubscriptionClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -165,11 +167,11 @@ internal SubscriptionOperations(SubscriptionClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseBodyException(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); + ErrorResponseBody _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex.Body = _errorBody; @@ -240,7 +242,7 @@ internal SubscriptionOperations(SubscriptionClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -265,7 +267,10 @@ internal SubscriptionOperations(SubscriptionClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "body"); } - string apiVersion = "2020-09-01"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -275,7 +280,6 @@ internal SubscriptionOperations(SubscriptionClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("subscriptionId", subscriptionId); tracingParameters.Add("body", body); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Rename", tracingParameters); } @@ -284,9 +288,9 @@ internal SubscriptionOperations(SubscriptionClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -354,11 +358,11 @@ internal SubscriptionOperations(SubscriptionClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseBodyException(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); + ErrorResponseBody _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex.Body = _errorBody; @@ -426,7 +430,7 @@ internal SubscriptionOperations(SubscriptionClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -447,7 +451,10 @@ internal SubscriptionOperations(SubscriptionClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); } - string apiVersion = "2020-09-01"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -456,7 +463,6 @@ internal SubscriptionOperations(SubscriptionClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("subscriptionId", subscriptionId); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Enable", tracingParameters); } @@ -465,9 +471,9 @@ internal SubscriptionOperations(SubscriptionClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -529,11 +535,11 @@ internal SubscriptionOperations(SubscriptionClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseBodyException(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); + ErrorResponseBody _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex.Body = _errorBody; @@ -589,5 +595,389 @@ internal SubscriptionOperations(SubscriptionClient client) return _result; } + /// + /// Accept subscription ownership. + /// + /// + /// Subscription Id. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> AcceptOwnershipWithHttpMessagesAsync(string subscriptionId, AcceptOwnershipRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginAcceptOwnershipWithHttpMessagesAsync(subscriptionId, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Accept subscription ownership status. + /// + /// + /// Subscription Id. + /// + /// + /// 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> AcceptOwnershipStatusWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "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("subscriptionId", subscriptionId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "AcceptOwnershipStatus", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/{subscriptionId}/acceptOwnershipStatus").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(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 ErrorResponseBodyException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponseBody _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; + } + + /// + /// Accept subscription ownership. + /// + /// + /// Subscription Id. + /// + /// + /// + /// + /// 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> BeginAcceptOwnershipWithHttpMessagesAsync(string subscriptionId, AcceptOwnershipRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (body != null) + { + body.Validate(); + } + 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("subscriptionId", subscriptionId); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginAcceptOwnership", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/{subscriptionId}/acceptOwnership").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202) + { + var ex = new ErrorResponseBodyException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponseBody _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 AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationsExtensions.cs index 523995713542..28f43ea96558 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationsExtensions.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationsExtensions.cs @@ -129,5 +129,115 @@ public static EnabledSubscriptionId Enable(this ISubscriptionOperations operatio } } + /// + /// Accept subscription ownership. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + /// + /// + public static SubscriptionAcceptOwnershipHeaders AcceptOwnership(this ISubscriptionOperations operations, string subscriptionId, AcceptOwnershipRequest body) + { + return operations.AcceptOwnershipAsync(subscriptionId, body).GetAwaiter().GetResult(); + } + + /// + /// Accept subscription ownership. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task AcceptOwnershipAsync(this ISubscriptionOperations operations, string subscriptionId, AcceptOwnershipRequest body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.AcceptOwnershipWithHttpMessagesAsync(subscriptionId, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Accept subscription ownership status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + public static AcceptOwnershipStatusResponse AcceptOwnershipStatus(this ISubscriptionOperations operations, string subscriptionId) + { + return operations.AcceptOwnershipStatusAsync(subscriptionId).GetAwaiter().GetResult(); + } + + /// + /// Accept subscription ownership status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + /// + /// The cancellation token. + /// + public static async Task AcceptOwnershipStatusAsync(this ISubscriptionOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.AcceptOwnershipStatusWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Accept subscription ownership. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + /// + /// + public static SubscriptionAcceptOwnershipHeaders BeginAcceptOwnership(this ISubscriptionOperations operations, string subscriptionId, AcceptOwnershipRequest body) + { + return operations.BeginAcceptOwnershipAsync(subscriptionId, body).GetAwaiter().GetResult(); + } + + /// + /// Accept subscription ownership. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task BeginAcceptOwnershipAsync(this ISubscriptionOperations operations, string subscriptionId, AcceptOwnershipRequest body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginAcceptOwnershipWithHttpMessagesAsync(subscriptionId, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionPolicyOperations.cs similarity index 80% rename from sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperations.cs rename to sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionPolicyOperations.cs index df94b1e2387c..d345e38a9de1 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionPolicyOperations.cs @@ -23,12 +23,12 @@ namespace Microsoft.Azure.Management.Subscription using System.Threading.Tasks; /// - /// SubscriptionsOperations operations. + /// SubscriptionPolicyOperations operations. /// - internal partial class SubscriptionsOperations : IServiceOperations, ISubscriptionsOperations + internal partial class SubscriptionPolicyOperations : IServiceOperations, ISubscriptionPolicyOperations { /// - /// Initializes a new instance of the SubscriptionsOperations class. + /// Initializes a new instance of the SubscriptionPolicyOperations class. /// /// /// Reference to the service client. @@ -36,7 +36,7 @@ internal partial class SubscriptionsOperations : IServiceOperations /// Thrown when a required parameter is null /// - internal SubscriptionsOperations(SubscriptionClient client) + internal SubscriptionPolicyOperations(SubscriptionClient client) { if (client == null) { @@ -51,15 +51,9 @@ internal SubscriptionsOperations(SubscriptionClient client) public SubscriptionClient Client { get; private set; } /// - /// Gets all available geo-locations. + /// Create or Update Subscription tenant policy for user's tenant. /// - /// - /// This operation provides all the locations that are available for resource - /// providers; however, each resource provider may support a subset of this - /// list. - /// - /// - /// The ID of the target subscription. + /// /// /// /// Headers that will be added to request. @@ -67,7 +61,7 @@ internal SubscriptionsOperations(SubscriptionClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -82,13 +76,16 @@ internal SubscriptionsOperations(SubscriptionClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListLocationsWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> AddUpdatePolicyForTenantWithHttpMessagesAsync(PutTenantPolicyRequestProperties body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (subscriptionId == null) + if (body == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - string apiVersion = "2016-06-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -96,19 +93,17 @@ internal SubscriptionsOperations(SubscriptionClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("subscriptionId", subscriptionId); - tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("body", body); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListLocations", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "AddUpdatePolicyForTenant", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/locations").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/policies/default").ToString(); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -117,7 +112,7 @@ internal SubscriptionsOperations(SubscriptionClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -148,6 +143,12 @@ internal SubscriptionsOperations(SubscriptionClient client) // Serialize Request string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } // Set Credentials if (Client.Credentials != null) { @@ -168,16 +169,15 @@ internal SubscriptionsOperations(SubscriptionClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200) + if ((int)_statusCode != 201) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseBodyException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponseBody _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -187,10 +187,6 @@ internal SubscriptionsOperations(SubscriptionClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -203,7 +199,7 @@ internal SubscriptionsOperations(SubscriptionClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse>(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -211,12 +207,12 @@ internal SubscriptionsOperations(SubscriptionClient client) _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } // Deserialize Response - if ((int)_statusCode == 200) + if ((int)_statusCode == 201) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -236,18 +232,15 @@ internal SubscriptionsOperations(SubscriptionClient client) } /// - /// Gets details about a specified subscription. + /// Get the subscription tenant policy for the user's tenant. /// - /// - /// The ID of the target subscription. - /// /// /// Headers that will be added to request. /// /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -262,13 +255,12 @@ internal SubscriptionsOperations(SubscriptionClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetPolicyForTenantWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (subscriptionId == null) + if (Client.ApiVersion == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - string apiVersion = "2016-06-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -276,19 +268,16 @@ internal SubscriptionsOperations(SubscriptionClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("subscriptionId", subscriptionId); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetPolicyForTenant", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/policies/default").ToString(); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -350,14 +339,13 @@ internal SubscriptionsOperations(SubscriptionClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseBodyException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponseBody _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -367,10 +355,6 @@ internal SubscriptionsOperations(SubscriptionClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -383,7 +367,7 @@ internal SubscriptionsOperations(SubscriptionClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -396,7 +380,7 @@ internal SubscriptionsOperations(SubscriptionClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -416,7 +400,7 @@ internal SubscriptionsOperations(SubscriptionClient client) } /// - /// Gets all subscriptions for a tenant. + /// Get the subscription tenant policy for the user's tenant. /// /// /// Headers that will be added to request. @@ -424,18 +408,27 @@ internal SubscriptionsOperations(SubscriptionClient client) /// /// 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)) + public async Task>> ListPolicyForTenantWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - string apiVersion = "2016-06-01"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -443,17 +436,16 @@ internal SubscriptionsOperations(SubscriptionClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListPolicyForTenant", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/policies").ToString(); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -515,14 +507,13 @@ internal SubscriptionsOperations(SubscriptionClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseBodyException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponseBody _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -532,10 +523,6 @@ internal SubscriptionsOperations(SubscriptionClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -548,7 +535,7 @@ internal SubscriptionsOperations(SubscriptionClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse>(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -561,7 +548,7 @@ internal SubscriptionsOperations(SubscriptionClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -581,7 +568,7 @@ internal SubscriptionsOperations(SubscriptionClient client) } /// - /// Gets all subscriptions for a tenant. + /// Get the subscription tenant policy for the user's tenant. /// /// /// The NextLink from the previous successful call to List operation. @@ -592,7 +579,7 @@ internal SubscriptionsOperations(SubscriptionClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -607,7 +594,7 @@ internal SubscriptionsOperations(SubscriptionClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListPolicyForTenantNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -622,7 +609,7 @@ internal SubscriptionsOperations(SubscriptionClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListPolicyForTenantNext", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -688,14 +675,13 @@ internal SubscriptionsOperations(SubscriptionClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseBodyException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponseBody _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -705,10 +691,6 @@ internal SubscriptionsOperations(SubscriptionClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -721,7 +703,7 @@ internal SubscriptionsOperations(SubscriptionClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse>(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -734,7 +716,7 @@ internal SubscriptionsOperations(SubscriptionClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionPolicyOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionPolicyOperationsExtensions.cs new file mode 100644 index 000000000000..9be431a3377e --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionPolicyOperationsExtensions.cs @@ -0,0 +1,147 @@ +// +// 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.Subscription +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SubscriptionPolicyOperations. + /// + public static partial class SubscriptionPolicyOperationsExtensions + { + /// + /// Create or Update Subscription tenant policy for user's tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// + public static GetTenantPolicyResponse AddUpdatePolicyForTenant(this ISubscriptionPolicyOperations operations, PutTenantPolicyRequestProperties body) + { + return operations.AddUpdatePolicyForTenantAsync(body).GetAwaiter().GetResult(); + } + + /// + /// Create or Update Subscription tenant policy for user's tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task AddUpdatePolicyForTenantAsync(this ISubscriptionPolicyOperations operations, PutTenantPolicyRequestProperties body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.AddUpdatePolicyForTenantWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the subscription tenant policy for the user's tenant. + /// + /// + /// The operations group for this extension method. + /// + public static GetTenantPolicyResponse GetPolicyForTenant(this ISubscriptionPolicyOperations operations) + { + return operations.GetPolicyForTenantAsync().GetAwaiter().GetResult(); + } + + /// + /// Get the subscription tenant policy for the user's tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task GetPolicyForTenantAsync(this ISubscriptionPolicyOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetPolicyForTenantWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the subscription tenant policy for the user's tenant. + /// + /// + /// The operations group for this extension method. + /// + public static IPage ListPolicyForTenant(this ISubscriptionPolicyOperations operations) + { + return operations.ListPolicyForTenantAsync().GetAwaiter().GetResult(); + } + + /// + /// Get the subscription tenant policy for the user's tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListPolicyForTenantAsync(this ISubscriptionPolicyOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListPolicyForTenantWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the subscription tenant policy for the user's tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListPolicyForTenantNext(this ISubscriptionPolicyOperations operations, string nextPageLink) + { + return operations.ListPolicyForTenantNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get the subscription tenant policy for the user's tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListPolicyForTenantNextAsync(this ISubscriptionPolicyOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListPolicyForTenantNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperationsExtensions.cs deleted file mode 100644 index 442d21e3d7ee..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperationsExtensions.cs +++ /dev/null @@ -1,167 +0,0 @@ -// -// 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.Subscription -{ - 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 SubscriptionsOperations. - /// - public static partial class SubscriptionsOperationsExtensions - { - /// - /// Gets all available geo-locations. - /// - /// - /// This operation provides all the locations that are available for resource - /// providers; however, each resource provider may support a subset of this - /// list. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The ID of the target subscription. - /// - public static IEnumerable ListLocations(this ISubscriptionsOperations operations, string subscriptionId) - { - return operations.ListLocationsAsync(subscriptionId).GetAwaiter().GetResult(); - } - - /// - /// Gets all available geo-locations. - /// - /// - /// This operation provides all the locations that are available for resource - /// providers; however, each resource provider may support a subset of this - /// list. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The ID of the target subscription. - /// - /// - /// The cancellation token. - /// - public static async Task> ListLocationsAsync(this ISubscriptionsOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListLocationsWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets details about a specified subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The ID of the target subscription. - /// - public static SubscriptionModel Get(this ISubscriptionsOperations operations, string subscriptionId) - { - return operations.GetAsync(subscriptionId).GetAwaiter().GetResult(); - } - - /// - /// Gets details about a specified subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The ID of the target subscription. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this ISubscriptionsOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// The operations group for this extension method. - /// - public static IPage List(this ISubscriptionsOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this ISubscriptionsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this ISubscriptionsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this ISubscriptionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperations.cs deleted file mode 100644 index 69509b6381d6..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperations.cs +++ /dev/null @@ -1,392 +0,0 @@ -// -// 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.Subscription -{ - 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; - - /// - /// TenantsOperations operations. - /// - internal partial class TenantsOperations : IServiceOperations, ITenantsOperations - { - /// - /// Initializes a new instance of the TenantsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal TenantsOperations(SubscriptionClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SubscriptionClient - /// - public SubscriptionClient Client { get; private set; } - - /// - /// Gets the tenants for your 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 - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - string apiVersion = "2016-06-01"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); - 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("/") ? "" : "/")), "tenants").ToString(); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - 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; - } - - /// - /// Gets the tenants for your account. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - 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/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperationsExtensions.cs deleted file mode 100644 index 36b8f3fbf030..000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperationsExtensions.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -// 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.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for TenantsOperations. - /// - public static partial class TenantsOperationsExtensions - { - /// - /// Gets the tenants for your account. - /// - /// - /// The operations group for this extension method. - /// - public static IPage List(this ITenantsOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets the tenants for your account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this ITenantsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the tenants for your account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this ITenantsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets the tenants for your account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this ITenantsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -}