From 259be18b00e377e4d141151f0527cc72a1c4e365 Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Tue, 26 Mar 2019 23:55:47 +0000 Subject: [PATCH 1/4] .NET SDK Resource Provider:'Billing' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/5486' REST Spec PR Author 'wilcobmsft' REST Spec PR Last commit --- .../Generated/BillingManagementClient.cs | 12 + .../BillingProfileInvoiceSectionOperations.cs | 211 +++++++++++++++ ...ofileInvoiceSectionOperationsExtensions.cs | 62 +++++ .../Generated/IBillingManagementClient.cs | 10 + ...IBillingProfileInvoiceSectionOperations.cs | 49 ++++ ...eSectionsByBillingProfileNameOperations.cs | 53 ++++ ...eSectionsByBillingProfileNameOperations.cs | 254 ++++++++++++++++++ ...yBillingProfileNameOperationsExtensions.cs | 67 +++++ ...SectionsByBillingProfileNameListHeaders.cs | 66 +++++ .../SdkInfo_BillingManagementClient.cs | 2 + 10 files changed, 786 insertions(+) create mode 100644 src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperations.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperationsExtensions.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/IBillingProfileInvoiceSectionOperations.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperationsExtensions.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingProfileNameListHeaders.cs diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs index 738a043235d0..e8d49fcbef8c 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs @@ -118,6 +118,11 @@ public partial class BillingManagementClient : ServiceClient public virtual IInvoiceSectionsOperations InvoiceSections { get; private set; } + /// + /// Gets the IInvoiceSectionsByBillingProfileNameOperations. + /// + public virtual IInvoiceSectionsByBillingProfileNameOperations InvoiceSectionsByBillingProfileName { get; private set; } + /// /// Gets the IInvoiceSectionsWithCreateSubscriptionPermissionOperations. /// @@ -213,6 +218,11 @@ public partial class BillingManagementClient : ServiceClient public virtual IBillingPropertyOperations BillingProperty { get; private set; } + /// + /// Gets the IBillingProfileInvoiceSectionOperations. + /// + public virtual IBillingProfileInvoiceSectionOperations BillingProfileInvoiceSection { get; private set; } + /// /// Gets the ITransfersOperations. /// @@ -522,6 +532,7 @@ private void Initialize() BillingProfiles = new BillingProfilesOperations(this); InvoiceSectionsByBillingAccountName = new InvoiceSectionsByBillingAccountNameOperations(this); InvoiceSections = new InvoiceSectionsOperations(this); + InvoiceSectionsByBillingProfileName = new InvoiceSectionsByBillingProfileNameOperations(this); InvoiceSectionsWithCreateSubscriptionPermission = new InvoiceSectionsWithCreateSubscriptionPermissionOperations(this); DepartmentsByBillingAccountName = new DepartmentsByBillingAccountNameOperations(this); Departments = new DepartmentsOperations(this); @@ -541,6 +552,7 @@ private void Initialize() TransactionsByBillingAccount = new TransactionsByBillingAccountOperations(this); Policy = new PolicyOperations(this); BillingProperty = new BillingPropertyOperations(this); + BillingProfileInvoiceSection = new BillingProfileInvoiceSectionOperations(this); Transfers = new TransfersOperations(this); RecipientTransfers = new RecipientTransfersOperations(this); Operations = new Operations(this); diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperations.cs new file mode 100644 index 000000000000..3780d5e9c379 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperations.cs @@ -0,0 +1,211 @@ +// +// 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.Billing +{ + 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; + + /// + /// BillingProfileInvoiceSectionOperations operations. + /// + internal partial class BillingProfileInvoiceSectionOperations : IServiceOperations, IBillingProfileInvoiceSectionOperations + { + /// + /// Initializes a new instance of the BillingProfileInvoiceSectionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal BillingProfileInvoiceSectionOperations(BillingManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the BillingManagementClient + /// + public BillingManagementClient Client { get; private set; } + + /// + /// Elevates the caller's access to match their billing profile access. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection 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 ElevateWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (billingAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); + } + if (invoiceSectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "invoiceSectionName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("invoiceSectionName", invoiceSectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Elevate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/elevate").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{invoiceSectionName}", System.Uri.EscapeDataString(invoiceSectionName)); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperationsExtensions.cs new file mode 100644 index 000000000000..e0b5ce5064b0 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperationsExtensions.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for BillingProfileInvoiceSectionOperations. + /// + public static partial class BillingProfileInvoiceSectionOperationsExtensions + { + /// + /// Elevates the caller's access to match their billing profile access. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection Id. + /// + public static void Elevate(this IBillingProfileInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName) + { + operations.ElevateAsync(billingAccountName, invoiceSectionName).GetAwaiter().GetResult(); + } + + /// + /// Elevates the caller's access to match their billing profile access. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection Id. + /// + /// + /// The cancellation token. + /// + public static async Task ElevateAsync(this IBillingProfileInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.ElevateWithHttpMessagesAsync(billingAccountName, invoiceSectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs index 281322c3bbcd..41254200c6cc 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs @@ -115,6 +115,11 @@ public partial interface IBillingManagementClient : System.IDisposable /// IInvoiceSectionsOperations InvoiceSections { get; } + /// + /// Gets the IInvoiceSectionsByBillingProfileNameOperations. + /// + IInvoiceSectionsByBillingProfileNameOperations InvoiceSectionsByBillingProfileName { get; } + /// /// Gets the IInvoiceSectionsWithCreateSubscriptionPermissionOperations. /// @@ -210,6 +215,11 @@ public partial interface IBillingManagementClient : System.IDisposable /// IBillingPropertyOperations BillingProperty { get; } + /// + /// Gets the IBillingProfileInvoiceSectionOperations. + /// + IBillingProfileInvoiceSectionOperations BillingProfileInvoiceSection { get; } + /// /// Gets the ITransfersOperations. /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/IBillingProfileInvoiceSectionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IBillingProfileInvoiceSectionOperations.cs new file mode 100644 index 000000000000..c72bf93547c6 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/IBillingProfileInvoiceSectionOperations.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.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// BillingProfileInvoiceSectionOperations operations. + /// + public partial interface IBillingProfileInvoiceSectionOperations + { + /// + /// Elevates the caller's access to match their billing profile access. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection 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 ElevateWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs new file mode 100644 index 000000000000..deb5879340a1 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// InvoiceSectionsByBillingProfileNameOperations operations. + /// + public partial interface IInvoiceSectionsByBillingProfileNameOperations + { + /// + /// Lists all invoice sections under a billing profile for a user which + /// he has access to. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile 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> ListWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs new file mode 100644 index 000000000000..3475f16296f6 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs @@ -0,0 +1,254 @@ +// +// 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.Billing +{ + 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; + + /// + /// InvoiceSectionsByBillingProfileNameOperations operations. + /// + internal partial class InvoiceSectionsByBillingProfileNameOperations : IServiceOperations, IInvoiceSectionsByBillingProfileNameOperations + { + /// + /// Initializes a new instance of the InvoiceSectionsByBillingProfileNameOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal InvoiceSectionsByBillingProfileNameOperations(BillingManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the BillingManagementClient + /// + public BillingManagementClient Client { get; private set; } + + /// + /// Lists all invoice sections under a billing profile for a user which he has + /// access to. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile 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> ListWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (billingAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); + } + if (billingProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("billingProfileName", billingProfileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName)); + 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 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + 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/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperationsExtensions.cs new file mode 100644 index 000000000000..6b40a3bed5ff --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperationsExtensions.cs @@ -0,0 +1,67 @@ +// +// 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.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for InvoiceSectionsByBillingProfileNameOperations. + /// + public static partial class InvoiceSectionsByBillingProfileNameOperationsExtensions + { + /// + /// Lists all invoice sections under a billing profile for a user which he has + /// access to. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile Id. + /// + public static InvoiceSectionListResult List(this IInvoiceSectionsByBillingProfileNameOperations operations, string billingAccountName, string billingProfileName) + { + return operations.ListAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult(); + } + + /// + /// Lists all invoice sections under a billing profile for a user which he has + /// access to. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile Id. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IInvoiceSectionsByBillingProfileNameOperations operations, string billingAccountName, string billingProfileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountName, billingProfileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingProfileNameListHeaders.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingProfileNameListHeaders.cs new file mode 100644 index 000000000000..061474c41ea6 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingProfileNameListHeaders.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.Billing.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for List operation. + /// + public partial class InvoiceSectionsByBillingProfileNameListHeaders + { + /// + /// Initializes a new instance of the + /// InvoiceSectionsByBillingProfileNameListHeaders class. + /// + public InvoiceSectionsByBillingProfileNameListHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// InvoiceSectionsByBillingProfileNameListHeaders 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 InvoiceSectionsByBillingProfileNameListHeaders(string location = default(string), string retryAfter = default(string)) + { + 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 string RetryAfter { get; set; } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs index 6c9aaae26045..5d230270dd6f 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs @@ -28,6 +28,7 @@ public static IEnumerable> ApiInfo_BillingManageme new Tuple("Billing", "BillingProfileBillingPermissions", "2018-11-01-preview"), new Tuple("Billing", "BillingProfileBillingRoleAssignment", "2018-11-01-preview"), new Tuple("Billing", "BillingProfileBillingRoleDefinition", "2018-11-01-preview"), + new Tuple("Billing", "BillingProfileInvoiceSection", "2018-11-01-preview"), new Tuple("Billing", "BillingProfiles", "2018-11-01-preview"), new Tuple("Billing", "BillingProfilesByBillingAccountName", "2018-11-01-preview"), new Tuple("Billing", "BillingProperty", "2018-11-01-preview"), @@ -45,6 +46,7 @@ public static IEnumerable> ApiInfo_BillingManageme new Tuple("Billing", "InvoiceSections", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionsBillingPermissions", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionsByBillingAccountName", "2018-11-01-preview"), + new Tuple("Billing", "InvoiceSectionsByBillingProfileName", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionsWithCreateSubscriptionPermission", "2018-11-01-preview"), new Tuple("Billing", "InvoicesByBillingAccount", "2018-11-01-preview"), new Tuple("Billing", "InvoicesByBillingProfile", "2018-11-01-preview"), From e5c0046b5d2765e82ee3317b82f3eb51cf2a61f5 Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Thu, 28 Mar 2019 02:01:41 +0000 Subject: [PATCH 2/4] .NET SDK Resource Provider:'Billing' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/5486' REST Spec PR Author 'wilcobmsft' REST Spec PR Last commit --- ...eSectionsByBillingAccountNameOperations.cs | 2 +- ...eSectionsByBillingProfileNameOperations.cs | 2 +- ...hCreateSubscriptionPermissionOperations.cs | 2 +- ...eSectionsByBillingAccountNameOperations.cs | 19 +----- ...eSectionsByBillingProfileNameOperations.cs | 19 +----- ...hCreateSubscriptionPermissionOperations.cs | 19 +----- ...SectionsByBillingAccountNameListHeaders.cs | 66 ------------------- ...SectionsByBillingProfileNameListHeaders.cs | 66 ------------------- ...CreateSubscriptionPermissionListHeaders.cs | 66 ------------------- 9 files changed, 12 insertions(+), 249 deletions(-) delete mode 100644 src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingAccountNameListHeaders.cs delete mode 100644 src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingProfileNameListHeaders.cs delete mode 100644 src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsWithCreateSubscriptionPermissionListHeaders.cs diff --git a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingAccountNameOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingAccountNameOperations.cs index 73b8b070427b..8a9c32ffef12 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingAccountNameOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingAccountNameOperations.cs @@ -47,6 +47,6 @@ public partial interface IInvoiceSectionsByBillingAccountNameOperations /// /// Thrown when a required parameter is null /// - Task> ListWithHttpMessagesAsync(string billingAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> ListWithHttpMessagesAsync(string billingAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs index deb5879340a1..a455120d93ce 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs @@ -48,6 +48,6 @@ public partial interface IInvoiceSectionsByBillingProfileNameOperations /// /// Thrown when a required parameter is null /// - Task> ListWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> ListWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsWithCreateSubscriptionPermissionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsWithCreateSubscriptionPermissionOperations.cs index 1b8d4ec1f66a..758b2d926ce8 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsWithCreateSubscriptionPermissionOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsWithCreateSubscriptionPermissionOperations.cs @@ -48,6 +48,6 @@ public partial interface IInvoiceSectionsWithCreateSubscriptionPermissionOperati /// /// Thrown when a required parameter is null /// - Task> ListWithHttpMessagesAsync(string billingAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> ListWithHttpMessagesAsync(string billingAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingAccountNameOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingAccountNameOperations.cs index 5411ff991ddc..718ccaaba215 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingAccountNameOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingAccountNameOperations.cs @@ -80,7 +80,7 @@ internal InvoiceSectionsByBillingAccountNameOperations(BillingManagementClient c /// /// A response object containing the response body and response headers. /// - public async Task> ListWithHttpMessagesAsync(string billingAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ListWithHttpMessagesAsync(string billingAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.ApiVersion == null) { @@ -173,7 +173,7 @@ internal InvoiceSectionsByBillingAccountNameOperations(BillingManagementClient c HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) + if ((int)_statusCode != 200) { var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -203,7 +203,7 @@ internal InvoiceSectionsByBillingAccountNameOperations(BillingManagementClient c 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")) @@ -228,19 +228,6 @@ internal InvoiceSectionsByBillingAccountNameOperations(BillingManagementClient c throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } - 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); diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs index 3475f16296f6..4a5420bc731c 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs @@ -81,7 +81,7 @@ internal InvoiceSectionsByBillingProfileNameOperations(BillingManagementClient c /// /// A response object containing the response body and response headers. /// - public async Task> ListWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ListWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.ApiVersion == null) { @@ -175,7 +175,7 @@ internal InvoiceSectionsByBillingProfileNameOperations(BillingManagementClient c HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) + if ((int)_statusCode != 200) { var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -205,7 +205,7 @@ internal InvoiceSectionsByBillingProfileNameOperations(BillingManagementClient c 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")) @@ -230,19 +230,6 @@ internal InvoiceSectionsByBillingProfileNameOperations(BillingManagementClient c throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } - 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); diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsWithCreateSubscriptionPermissionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsWithCreateSubscriptionPermissionOperations.cs index 839ec7153f42..a04c15556001 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsWithCreateSubscriptionPermissionOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsWithCreateSubscriptionPermissionOperations.cs @@ -80,7 +80,7 @@ internal InvoiceSectionsWithCreateSubscriptionPermissionOperations(BillingManage /// /// A response object containing the response body and response headers. /// - public async Task> ListWithHttpMessagesAsync(string billingAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ListWithHttpMessagesAsync(string billingAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.ApiVersion == null) { @@ -173,7 +173,7 @@ internal InvoiceSectionsWithCreateSubscriptionPermissionOperations(BillingManage HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) + if ((int)_statusCode != 200) { var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -203,7 +203,7 @@ internal InvoiceSectionsWithCreateSubscriptionPermissionOperations(BillingManage 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")) @@ -228,19 +228,6 @@ internal InvoiceSectionsWithCreateSubscriptionPermissionOperations(BillingManage throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } - 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); diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingAccountNameListHeaders.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingAccountNameListHeaders.cs deleted file mode 100644 index 10dead4f6047..000000000000 --- a/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingAccountNameListHeaders.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.Billing.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines headers for List operation. - /// - public partial class InvoiceSectionsByBillingAccountNameListHeaders - { - /// - /// Initializes a new instance of the - /// InvoiceSectionsByBillingAccountNameListHeaders class. - /// - public InvoiceSectionsByBillingAccountNameListHeaders() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// InvoiceSectionsByBillingAccountNameListHeaders 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 InvoiceSectionsByBillingAccountNameListHeaders(string location = default(string), string retryAfter = default(string)) - { - 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 string RetryAfter { get; set; } - - } -} diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingProfileNameListHeaders.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingProfileNameListHeaders.cs deleted file mode 100644 index 061474c41ea6..000000000000 --- a/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsByBillingProfileNameListHeaders.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.Billing.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines headers for List operation. - /// - public partial class InvoiceSectionsByBillingProfileNameListHeaders - { - /// - /// Initializes a new instance of the - /// InvoiceSectionsByBillingProfileNameListHeaders class. - /// - public InvoiceSectionsByBillingProfileNameListHeaders() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// InvoiceSectionsByBillingProfileNameListHeaders 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 InvoiceSectionsByBillingProfileNameListHeaders(string location = default(string), string retryAfter = default(string)) - { - 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 string RetryAfter { get; set; } - - } -} diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsWithCreateSubscriptionPermissionListHeaders.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsWithCreateSubscriptionPermissionListHeaders.cs deleted file mode 100644 index 70a70d02f1a5..000000000000 --- a/src/SDKs/Billing/Management.Billing/Generated/Models/InvoiceSectionsWithCreateSubscriptionPermissionListHeaders.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.Billing.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines headers for List operation. - /// - public partial class InvoiceSectionsWithCreateSubscriptionPermissionListHeaders - { - /// - /// Initializes a new instance of the - /// InvoiceSectionsWithCreateSubscriptionPermissionListHeaders class. - /// - public InvoiceSectionsWithCreateSubscriptionPermissionListHeaders() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// InvoiceSectionsWithCreateSubscriptionPermissionListHeaders 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 InvoiceSectionsWithCreateSubscriptionPermissionListHeaders(string location = default(string), string retryAfter = default(string)) - { - 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 string RetryAfter { get; set; } - - } -} From 70d4b6f88bf3558aa91e16154260809c88119648 Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Thu, 28 Mar 2019 16:44:44 +0000 Subject: [PATCH 3/4] .NET SDK Resource Provider:'Billing' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/5486' REST Spec PR Author 'wilcobmsft' REST Spec PR Last commit --- .../Generated/BillingManagementClient.cs | 12 +- .../Generated/IBillingManagementClient.cs | 9 +- ...ations.cs => IInvoiceSectionOperations.cs} | 6 +- ...eSectionsByBillingProfileNameOperations.cs | 53 ---- .../Generated/IInvoiceSectionsOperations.cs | 26 ++ ...rations.cs => InvoiceSectionOperations.cs} | 12 +- ... => InvoiceSectionOperationsExtensions.cs} | 12 +- ...eSectionsByBillingProfileNameOperations.cs | 241 ------------------ ...yBillingProfileNameOperationsExtensions.cs | 67 ----- .../Generated/InvoiceSectionsOperations.cs | 187 ++++++++++++++ .../InvoiceSectionsOperationsExtensions.cs | 42 +++ .../SdkInfo_BillingManagementClient.cs | 3 +- 12 files changed, 276 insertions(+), 394 deletions(-) rename src/SDKs/Billing/Management.Billing/Generated/{IBillingProfileInvoiceSectionOperations.cs => IInvoiceSectionOperations.cs} (80%) delete mode 100644 src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs rename src/SDKs/Billing/Management.Billing/Generated/{BillingProfileInvoiceSectionOperations.cs => InvoiceSectionOperations.cs} (92%) rename src/SDKs/Billing/Management.Billing/Generated/{BillingProfileInvoiceSectionOperationsExtensions.cs => InvoiceSectionOperationsExtensions.cs} (68%) delete mode 100644 src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs delete mode 100644 src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperationsExtensions.cs diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs index e8d49fcbef8c..24fd84aa906f 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs @@ -118,11 +118,6 @@ public partial class BillingManagementClient : ServiceClient public virtual IInvoiceSectionsOperations InvoiceSections { get; private set; } - /// - /// Gets the IInvoiceSectionsByBillingProfileNameOperations. - /// - public virtual IInvoiceSectionsByBillingProfileNameOperations InvoiceSectionsByBillingProfileName { get; private set; } - /// /// Gets the IInvoiceSectionsWithCreateSubscriptionPermissionOperations. /// @@ -219,9 +214,9 @@ public partial class BillingManagementClient : ServiceClient - /// Gets the IBillingProfileInvoiceSectionOperations. + /// Gets the IInvoiceSectionOperations. /// - public virtual IBillingProfileInvoiceSectionOperations BillingProfileInvoiceSection { get; private set; } + public virtual IInvoiceSectionOperations InvoiceSection { get; private set; } /// /// Gets the ITransfersOperations. @@ -532,7 +527,6 @@ private void Initialize() BillingProfiles = new BillingProfilesOperations(this); InvoiceSectionsByBillingAccountName = new InvoiceSectionsByBillingAccountNameOperations(this); InvoiceSections = new InvoiceSectionsOperations(this); - InvoiceSectionsByBillingProfileName = new InvoiceSectionsByBillingProfileNameOperations(this); InvoiceSectionsWithCreateSubscriptionPermission = new InvoiceSectionsWithCreateSubscriptionPermissionOperations(this); DepartmentsByBillingAccountName = new DepartmentsByBillingAccountNameOperations(this); Departments = new DepartmentsOperations(this); @@ -552,7 +546,7 @@ private void Initialize() TransactionsByBillingAccount = new TransactionsByBillingAccountOperations(this); Policy = new PolicyOperations(this); BillingProperty = new BillingPropertyOperations(this); - BillingProfileInvoiceSection = new BillingProfileInvoiceSectionOperations(this); + InvoiceSection = new InvoiceSectionOperations(this); Transfers = new TransfersOperations(this); RecipientTransfers = new RecipientTransfersOperations(this); Operations = new Operations(this); diff --git a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs index 41254200c6cc..7a596db3996b 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs @@ -115,11 +115,6 @@ public partial interface IBillingManagementClient : System.IDisposable /// IInvoiceSectionsOperations InvoiceSections { get; } - /// - /// Gets the IInvoiceSectionsByBillingProfileNameOperations. - /// - IInvoiceSectionsByBillingProfileNameOperations InvoiceSectionsByBillingProfileName { get; } - /// /// Gets the IInvoiceSectionsWithCreateSubscriptionPermissionOperations. /// @@ -216,9 +211,9 @@ public partial interface IBillingManagementClient : System.IDisposable IBillingPropertyOperations BillingProperty { get; } /// - /// Gets the IBillingProfileInvoiceSectionOperations. + /// Gets the IInvoiceSectionOperations. /// - IBillingProfileInvoiceSectionOperations BillingProfileInvoiceSection { get; } + IInvoiceSectionOperations InvoiceSection { get; } /// /// Gets the ITransfersOperations. diff --git a/src/SDKs/Billing/Management.Billing/Generated/IBillingProfileInvoiceSectionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionOperations.cs similarity index 80% rename from src/SDKs/Billing/Management.Billing/Generated/IBillingProfileInvoiceSectionOperations.cs rename to src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionOperations.cs index c72bf93547c6..653c96b170cc 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IBillingProfileInvoiceSectionOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionOperations.cs @@ -19,9 +19,9 @@ namespace Microsoft.Azure.Management.Billing using System.Threading.Tasks; /// - /// BillingProfileInvoiceSectionOperations operations. + /// InvoiceSectionOperations operations. /// - public partial interface IBillingProfileInvoiceSectionOperations + public partial interface IInvoiceSectionOperations { /// /// Elevates the caller's access to match their billing profile access. @@ -44,6 +44,6 @@ public partial interface IBillingProfileInvoiceSectionOperations /// /// Thrown when a required parameter is null /// - Task ElevateWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task ElevateToBillingProfileWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.cs deleted file mode 100644 index a455120d93ce..000000000000 --- a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsByBillingProfileNameOperations.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.Billing -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// InvoiceSectionsByBillingProfileNameOperations operations. - /// - public partial interface IInvoiceSectionsByBillingProfileNameOperations - { - /// - /// Lists all invoice sections under a billing profile for a user which - /// he has access to. - /// - /// - /// billing Account Id. - /// - /// - /// Billing Profile 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> ListWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsOperations.cs index e15c1f00694b..807602a73ef6 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsOperations.cs @@ -49,6 +49,32 @@ public partial interface IInvoiceSectionsOperations /// Task> CreateWithHttpMessagesAsync(string billingAccountName, InvoiceSectionProperties parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Lists all invoice sections under a billing profile for a user which + /// he has access to. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile 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> ListByBillingProfileNameWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Get the InvoiceSection by id. /// /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperations.cs similarity index 92% rename from src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperations.cs rename to src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperations.cs index 3780d5e9c379..4838d43506bb 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperations.cs @@ -23,12 +23,12 @@ namespace Microsoft.Azure.Management.Billing using System.Threading.Tasks; /// - /// BillingProfileInvoiceSectionOperations operations. + /// InvoiceSectionOperations operations. /// - internal partial class BillingProfileInvoiceSectionOperations : IServiceOperations, IBillingProfileInvoiceSectionOperations + internal partial class InvoiceSectionOperations : IServiceOperations, IInvoiceSectionOperations { /// - /// Initializes a new instance of the BillingProfileInvoiceSectionOperations class. + /// Initializes a new instance of the InvoiceSectionOperations class. /// /// /// Reference to the service client. @@ -36,7 +36,7 @@ internal partial class BillingProfileInvoiceSectionOperations : IServiceOperatio /// /// Thrown when a required parameter is null /// - internal BillingProfileInvoiceSectionOperations(BillingManagementClient client) + internal InvoiceSectionOperations(BillingManagementClient client) { if (client == null) { @@ -77,7 +77,7 @@ internal BillingProfileInvoiceSectionOperations(BillingManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task ElevateWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task ElevateToBillingProfileWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (billingAccountName == null) { @@ -97,7 +97,7 @@ internal BillingProfileInvoiceSectionOperations(BillingManagementClient client) tracingParameters.Add("billingAccountName", billingAccountName); tracingParameters.Add("invoiceSectionName", invoiceSectionName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Elevate", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ElevateToBillingProfile", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperationsExtensions.cs similarity index 68% rename from src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperationsExtensions.cs rename to src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperationsExtensions.cs index e0b5ce5064b0..4412ba5d0e76 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/BillingProfileInvoiceSectionOperationsExtensions.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperationsExtensions.cs @@ -17,9 +17,9 @@ namespace Microsoft.Azure.Management.Billing using System.Threading.Tasks; /// - /// Extension methods for BillingProfileInvoiceSectionOperations. + /// Extension methods for InvoiceSectionOperations. /// - public static partial class BillingProfileInvoiceSectionOperationsExtensions + public static partial class InvoiceSectionOperationsExtensions { /// /// Elevates the caller's access to match their billing profile access. @@ -33,9 +33,9 @@ public static partial class BillingProfileInvoiceSectionOperationsExtensions /// /// InvoiceSection Id. /// - public static void Elevate(this IBillingProfileInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName) + public static void ElevateToBillingProfile(this IInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName) { - operations.ElevateAsync(billingAccountName, invoiceSectionName).GetAwaiter().GetResult(); + operations.ElevateToBillingProfileAsync(billingAccountName, invoiceSectionName).GetAwaiter().GetResult(); } /// @@ -53,9 +53,9 @@ public static void Elevate(this IBillingProfileInvoiceSectionOperations operatio /// /// The cancellation token. /// - public static async Task ElevateAsync(this IBillingProfileInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task ElevateToBillingProfileAsync(this IInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName, CancellationToken cancellationToken = default(CancellationToken)) { - (await operations.ElevateWithHttpMessagesAsync(billingAccountName, invoiceSectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + (await operations.ElevateToBillingProfileWithHttpMessagesAsync(billingAccountName, invoiceSectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } } diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs deleted file mode 100644 index 4a5420bc731c..000000000000 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperations.cs +++ /dev/null @@ -1,241 +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.Billing -{ - 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; - - /// - /// InvoiceSectionsByBillingProfileNameOperations operations. - /// - internal partial class InvoiceSectionsByBillingProfileNameOperations : IServiceOperations, IInvoiceSectionsByBillingProfileNameOperations - { - /// - /// Initializes a new instance of the InvoiceSectionsByBillingProfileNameOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal InvoiceSectionsByBillingProfileNameOperations(BillingManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the BillingManagementClient - /// - public BillingManagementClient Client { get; private set; } - - /// - /// Lists all invoice sections under a billing profile for a user which he has - /// access to. - /// - /// - /// billing Account Id. - /// - /// - /// Billing Profile 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> ListWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (billingAccountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); - } - if (billingProfileName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileName"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("billingAccountName", billingAccountName); - tracingParameters.Add("billingProfileName", billingProfileName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections").ToString(); - _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); - _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperationsExtensions.cs deleted file mode 100644 index 6b40a3bed5ff..000000000000 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsByBillingProfileNameOperationsExtensions.cs +++ /dev/null @@ -1,67 +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.Billing -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for InvoiceSectionsByBillingProfileNameOperations. - /// - public static partial class InvoiceSectionsByBillingProfileNameOperationsExtensions - { - /// - /// Lists all invoice sections under a billing profile for a user which he has - /// access to. - /// - /// - /// The operations group for this extension method. - /// - /// - /// billing Account Id. - /// - /// - /// Billing Profile Id. - /// - public static InvoiceSectionListResult List(this IInvoiceSectionsByBillingProfileNameOperations operations, string billingAccountName, string billingProfileName) - { - return operations.ListAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult(); - } - - /// - /// Lists all invoice sections under a billing profile for a user which he has - /// access to. - /// - /// - /// The operations group for this extension method. - /// - /// - /// billing Account Id. - /// - /// - /// Billing Profile Id. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IInvoiceSectionsByBillingProfileNameOperations operations, string billingAccountName, string billingProfileName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountName, billingProfileName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperations.cs index deb3b7f0b048..59fc8d69208d 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperations.cs @@ -72,6 +72,193 @@ internal InvoiceSectionsOperations(BillingManagementClient client) return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } + /// + /// Lists all invoice sections under a billing profile for a user which he has + /// access to. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile 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> ListByBillingProfileNameWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (billingAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); + } + if (billingProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("billingProfileName", billingProfileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByBillingProfileName", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + /// /// Get the InvoiceSection by id. /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperationsExtensions.cs index d87fb17619e7..093623a2c334 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperationsExtensions.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperationsExtensions.cs @@ -61,6 +61,48 @@ public static InvoiceSection Create(this IInvoiceSectionsOperations operations, } } + /// + /// Lists all invoice sections under a billing profile for a user which he has + /// access to. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile Id. + /// + public static InvoiceSectionListResult ListByBillingProfileName(this IInvoiceSectionsOperations operations, string billingAccountName, string billingProfileName) + { + return operations.ListByBillingProfileNameAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult(); + } + + /// + /// Lists all invoice sections under a billing profile for a user which he has + /// access to. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile Id. + /// + /// + /// The cancellation token. + /// + public static async Task ListByBillingProfileNameAsync(this IInvoiceSectionsOperations operations, string billingAccountName, string billingProfileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByBillingProfileNameWithHttpMessagesAsync(billingAccountName, billingProfileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Get the InvoiceSection by id. /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs index 5d230270dd6f..51816bcf902b 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs @@ -28,7 +28,6 @@ public static IEnumerable> ApiInfo_BillingManageme new Tuple("Billing", "BillingProfileBillingPermissions", "2018-11-01-preview"), new Tuple("Billing", "BillingProfileBillingRoleAssignment", "2018-11-01-preview"), new Tuple("Billing", "BillingProfileBillingRoleDefinition", "2018-11-01-preview"), - new Tuple("Billing", "BillingProfileInvoiceSection", "2018-11-01-preview"), new Tuple("Billing", "BillingProfiles", "2018-11-01-preview"), new Tuple("Billing", "BillingProfilesByBillingAccountName", "2018-11-01-preview"), new Tuple("Billing", "BillingProperty", "2018-11-01-preview"), @@ -41,12 +40,12 @@ public static IEnumerable> ApiInfo_BillingManageme new Tuple("Billing", "EnrollmentAccountsByBillingAccountName", "2018-11-01-preview"), new Tuple("Billing", "Invoice", "2018-11-01-preview"), new Tuple("Billing", "InvoicePricesheet", "2018-11-01-preview"), + new Tuple("Billing", "InvoiceSection", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionBillingRoleAssignment", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionBillingRoleDefinition", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSections", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionsBillingPermissions", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionsByBillingAccountName", "2018-11-01-preview"), - new Tuple("Billing", "InvoiceSectionsByBillingProfileName", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionsWithCreateSubscriptionPermission", "2018-11-01-preview"), new Tuple("Billing", "InvoicesByBillingAccount", "2018-11-01-preview"), new Tuple("Billing", "InvoicesByBillingProfile", "2018-11-01-preview"), From 9c74e7d52b72d123a318aa9ef59b4064f971bb02 Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Thu, 28 Mar 2019 18:14:48 +0000 Subject: [PATCH 4/4] .NET SDK Resource Provider:'Billing' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/5486' REST Spec PR Author 'wilcobmsft' REST Spec PR Last commit --- .../Generated/BillingManagementClient.cs | 6 - .../Generated/IBillingManagementClient.cs | 5 - .../Generated/IInvoiceSectionOperations.cs | 49 ---- .../Generated/IInvoiceSectionsOperations.cs | 22 ++ .../Generated/InvoiceSectionOperations.cs | 211 ------------------ .../InvoiceSectionOperationsExtensions.cs | 62 ----- .../Generated/InvoiceSectionsOperations.cs | 157 +++++++++++++ .../InvoiceSectionsOperationsExtensions.cs | 37 +++ .../SdkInfo_BillingManagementClient.cs | 1 - 9 files changed, 216 insertions(+), 334 deletions(-) delete mode 100644 src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionOperations.cs delete mode 100644 src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperations.cs delete mode 100644 src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperationsExtensions.cs diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs index 24fd84aa906f..738a043235d0 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs @@ -213,11 +213,6 @@ public partial class BillingManagementClient : ServiceClient public virtual IBillingPropertyOperations BillingProperty { get; private set; } - /// - /// Gets the IInvoiceSectionOperations. - /// - public virtual IInvoiceSectionOperations InvoiceSection { get; private set; } - /// /// Gets the ITransfersOperations. /// @@ -546,7 +541,6 @@ private void Initialize() TransactionsByBillingAccount = new TransactionsByBillingAccountOperations(this); Policy = new PolicyOperations(this); BillingProperty = new BillingPropertyOperations(this); - InvoiceSection = new InvoiceSectionOperations(this); Transfers = new TransfersOperations(this); RecipientTransfers = new RecipientTransfersOperations(this); Operations = new Operations(this); diff --git a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs index 7a596db3996b..281322c3bbcd 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs @@ -210,11 +210,6 @@ public partial interface IBillingManagementClient : System.IDisposable /// IBillingPropertyOperations BillingProperty { get; } - /// - /// Gets the IInvoiceSectionOperations. - /// - IInvoiceSectionOperations InvoiceSection { get; } - /// /// Gets the ITransfersOperations. /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionOperations.cs deleted file mode 100644 index 653c96b170cc..000000000000 --- a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionOperations.cs +++ /dev/null @@ -1,49 +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.Billing -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// InvoiceSectionOperations operations. - /// - public partial interface IInvoiceSectionOperations - { - /// - /// Elevates the caller's access to match their billing profile access. - /// - /// - /// billing Account Id. - /// - /// - /// InvoiceSection 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 ElevateToBillingProfileWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsOperations.cs index 807602a73ef6..a84830082b95 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IInvoiceSectionsOperations.cs @@ -131,6 +131,28 @@ public partial interface IInvoiceSectionsOperations /// Task> UpdateWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, InvoiceSection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Elevates the caller's access to match their billing profile access. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection 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 ElevateToBillingProfileWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// The operation to create a InvoiceSection. /// /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperations.cs deleted file mode 100644 index 4838d43506bb..000000000000 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperations.cs +++ /dev/null @@ -1,211 +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.Billing -{ - 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; - - /// - /// InvoiceSectionOperations operations. - /// - internal partial class InvoiceSectionOperations : IServiceOperations, IInvoiceSectionOperations - { - /// - /// Initializes a new instance of the InvoiceSectionOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal InvoiceSectionOperations(BillingManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the BillingManagementClient - /// - public BillingManagementClient Client { get; private set; } - - /// - /// Elevates the caller's access to match their billing profile access. - /// - /// - /// billing Account Id. - /// - /// - /// InvoiceSection 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 ElevateToBillingProfileWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (billingAccountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); - } - if (invoiceSectionName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "invoiceSectionName"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("billingAccountName", billingAccountName); - tracingParameters.Add("invoiceSectionName", invoiceSectionName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ElevateToBillingProfile", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/elevate").ToString(); - _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); - _url = _url.Replace("{invoiceSectionName}", System.Uri.EscapeDataString(invoiceSectionName)); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204) - { - var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperationsExtensions.cs deleted file mode 100644 index 4412ba5d0e76..000000000000 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionOperationsExtensions.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.Billing -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for InvoiceSectionOperations. - /// - public static partial class InvoiceSectionOperationsExtensions - { - /// - /// Elevates the caller's access to match their billing profile access. - /// - /// - /// The operations group for this extension method. - /// - /// - /// billing Account Id. - /// - /// - /// InvoiceSection Id. - /// - public static void ElevateToBillingProfile(this IInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName) - { - operations.ElevateToBillingProfileAsync(billingAccountName, invoiceSectionName).GetAwaiter().GetResult(); - } - - /// - /// Elevates the caller's access to match their billing profile access. - /// - /// - /// The operations group for this extension method. - /// - /// - /// billing Account Id. - /// - /// - /// InvoiceSection Id. - /// - /// - /// The cancellation token. - /// - public static async Task ElevateToBillingProfileAsync(this IInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.ElevateToBillingProfileWithHttpMessagesAsync(billingAccountName, invoiceSectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperations.cs index 59fc8d69208d..c3e5cc18a46a 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperations.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperations.cs @@ -478,6 +478,163 @@ internal InvoiceSectionsOperations(BillingManagementClient client) return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } + /// + /// Elevates the caller's access to match their billing profile access. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection 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 ElevateToBillingProfileWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (billingAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); + } + if (invoiceSectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "invoiceSectionName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("invoiceSectionName", invoiceSectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ElevateToBillingProfile", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/elevate").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{invoiceSectionName}", System.Uri.EscapeDataString(invoiceSectionName)); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + /// /// The operation to create a InvoiceSection. /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperationsExtensions.cs index 093623a2c334..ab0faf202780 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperationsExtensions.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/InvoiceSectionsOperationsExtensions.cs @@ -195,6 +195,43 @@ public static InvoiceSection Update(this IInvoiceSectionsOperations operations, } } + /// + /// Elevates the caller's access to match their billing profile access. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection Id. + /// + public static void ElevateToBillingProfile(this IInvoiceSectionsOperations operations, string billingAccountName, string invoiceSectionName) + { + operations.ElevateToBillingProfileAsync(billingAccountName, invoiceSectionName).GetAwaiter().GetResult(); + } + + /// + /// Elevates the caller's access to match their billing profile access. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection Id. + /// + /// + /// The cancellation token. + /// + public static async Task ElevateToBillingProfileAsync(this IInvoiceSectionsOperations operations, string billingAccountName, string invoiceSectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.ElevateToBillingProfileWithHttpMessagesAsync(billingAccountName, invoiceSectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + /// /// The operation to create a InvoiceSection. /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs index 51816bcf902b..6c9aaae26045 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs @@ -40,7 +40,6 @@ public static IEnumerable> ApiInfo_BillingManageme new Tuple("Billing", "EnrollmentAccountsByBillingAccountName", "2018-11-01-preview"), new Tuple("Billing", "Invoice", "2018-11-01-preview"), new Tuple("Billing", "InvoicePricesheet", "2018-11-01-preview"), - new Tuple("Billing", "InvoiceSection", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionBillingRoleAssignment", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSectionBillingRoleDefinition", "2018-11-01-preview"), new Tuple("Billing", "InvoiceSections", "2018-11-01-preview"),