diff --git a/src/SDKs/Billing/AzSdk.RP.props b/src/SDKs/Billing/AzSdk.RP.props
index 26ad7d93c996..54e2e949f901 100644
--- a/src/SDKs/Billing/AzSdk.RP.props
+++ b/src/SDKs/Billing/AzSdk.RP.props
@@ -1,7 +1,7 @@
- Billing_2018-03-01-preview;
+ Billing_2018-11-01-preview;
$(PackageTags);$(CommonTags);$(AzureApiTag);
\ No newline at end of file
diff --git a/src/SDKs/Billing/Management.Billing/Generated/AvailableBalanceByBillingProfileOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/AvailableBalanceByBillingProfileOperations.cs
new file mode 100644
index 000000000000..ddce3acf6011
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/AvailableBalanceByBillingProfileOperations.cs
@@ -0,0 +1,241 @@
+//
+// 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;
+
+ ///
+ /// AvailableBalanceByBillingProfileOperations operations.
+ ///
+ internal partial class AvailableBalanceByBillingProfileOperations : IServiceOperations, IAvailableBalanceByBillingProfileOperations
+ {
+ ///
+ /// Initializes a new instance of the AvailableBalanceByBillingProfileOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal AvailableBalanceByBillingProfileOperations(BillingManagementClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the BillingManagementClient
+ ///
+ public BillingManagementClient Client { get; private set; }
+
+ ///
+ /// The latest available credit balance for a given billingAccountName and
+ /// billingProfileName.
+ ///
+ ///
+ /// 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> GetWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (billingAccountName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName");
+ }
+ if (billingProfileName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ tracingParameters.Add("billingProfileName", billingProfileName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default").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/AvailableBalanceByBillingProfileOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/AvailableBalanceByBillingProfileOperationsExtensions.cs
new file mode 100644
index 000000000000..68077b35397f
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/AvailableBalanceByBillingProfileOperationsExtensions.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 AvailableBalanceByBillingProfileOperations.
+ ///
+ public static partial class AvailableBalanceByBillingProfileOperationsExtensions
+ {
+ ///
+ /// The latest available credit balance for a given billingAccountName and
+ /// billingProfileName.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ public static AvailableBalance Get(this IAvailableBalanceByBillingProfileOperations operations, string billingAccountName, string billingProfileName)
+ {
+ return operations.GetAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// The latest available credit balance for a given billingAccountName and
+ /// billingProfileName.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IAvailableBalanceByBillingProfileOperations operations, string billingAccountName, string billingProfileName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(billingAccountName, billingProfileName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingPermissionsOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingPermissionsOperations.cs
new file mode 100644
index 000000000000..d7dfb7e6c200
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingPermissionsOperations.cs
@@ -0,0 +1,231 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.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;
+
+ ///
+ /// BillingAccountBillingPermissionsOperations operations.
+ ///
+ internal partial class BillingAccountBillingPermissionsOperations : IServiceOperations, IBillingAccountBillingPermissionsOperations
+ {
+ ///
+ /// Initializes a new instance of the BillingAccountBillingPermissionsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BillingAccountBillingPermissionsOperations(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 billingPermissions for the caller has for a billing account.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListWithHttpMessagesAsync(string billingAccountName, 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");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ 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}/providers/Microsoft.Billing/billingPermissions").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ 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/BillingAccountBillingPermissionsOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingPermissionsOperationsExtensions.cs
new file mode 100644
index 000000000000..216698ede9a2
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingPermissionsOperationsExtensions.cs
@@ -0,0 +1,59 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for BillingAccountBillingPermissionsOperations.
+ ///
+ public static partial class BillingAccountBillingPermissionsOperationsExtensions
+ {
+ ///
+ /// Lists all billingPermissions for the caller has for a billing account.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ public static BillingPermissionsListResult List(this IBillingAccountBillingPermissionsOperations operations, string billingAccountName)
+ {
+ return operations.ListAsync(billingAccountName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists all billingPermissions for the caller has for a billing account.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IBillingAccountBillingPermissionsOperations operations, string billingAccountName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/InvoicesOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleAssignmentOperations.cs
similarity index 79%
rename from src/SDKs/Billing/Management.Billing/Generated/InvoicesOperations.cs
rename to src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleAssignmentOperations.cs
index 5d335d270df5..c13212d949e2 100644
--- a/src/SDKs/Billing/Management.Billing/Generated/InvoicesOperations.cs
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleAssignmentOperations.cs
@@ -23,12 +23,12 @@ namespace Microsoft.Azure.Management.Billing
using System.Threading.Tasks;
///
- /// InvoicesOperations operations.
+ /// BillingAccountBillingRoleAssignmentOperations operations.
///
- internal partial class InvoicesOperations : IServiceOperations, IInvoicesOperations
+ internal partial class BillingAccountBillingRoleAssignmentOperations : IServiceOperations, IBillingAccountBillingRoleAssignmentOperations
{
///
- /// Initializes a new instance of the InvoicesOperations class.
+ /// Initializes a new instance of the BillingAccountBillingRoleAssignmentOperations class.
///
///
/// Reference to the service client.
@@ -36,7 +36,7 @@ internal partial class InvoicesOperations : IServiceOperations
/// Thrown when a required parameter is null
///
- internal InvoicesOperations(BillingManagementClient client)
+ internal BillingAccountBillingRoleAssignmentOperations(BillingManagementClient client)
{
if (client == null)
{
@@ -51,32 +51,13 @@ internal InvoicesOperations(BillingManagementClient client)
public BillingManagementClient Client { get; private set; }
///
- /// Lists the available invoices for a subscription in reverse chronological
- /// order beginning with the most recent invoice. In preview, invoices are
- /// available via this API only for invoice periods which end December 1, 2016
- /// or later. This is only supported for Azure Web-Direct subscriptions. Other
- /// subscription types which were not purchased directly through the Azure web
- /// portal are not supported through this preview API.
- ///
+ /// Get the role assignment for the caller
///
- ///
- /// May be used to expand the downloadUrl property within a list of invoices.
- /// This enables download links to be generated for multiple invoices at once.
- /// By default, downloadURLs are not included when listing invoices.
+ ///
+ /// billing Account Id.
///
- ///
- /// May be used to filter invoices by invoicePeriodEndDate. The filter supports
- /// 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support
- /// 'ne', 'or', or 'not'.
- ///
- ///
- /// Skiptoken is only used if a previous operation returned a partial result.
- /// If a previous response contains a nextLink element, the value of the
- /// nextLink element will include a skiptoken parameter that specifies a
- /// starting point to use for subsequent calls.
- ///
- ///
- /// May be used to limit the number of results to the most recent N invoices.
+ ///
+ /// role assignment id.
///
///
/// Headers that will be added to request.
@@ -99,23 +80,19 @@ internal InvoicesOperations(BillingManagementClient client)
///
/// A response object containing the response body and response headers.
///
- public async Task>> ListWithHttpMessagesAsync(string expand = default(string), string filter = default(string), string skiptoken = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ public async Task> GetWithHttpMessagesAsync(string billingAccountName, string billingRoleAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
- if (Client.SubscriptionId == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
- }
if (Client.ApiVersion == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
}
- if (top > 100)
+ if (billingAccountName == null)
{
- throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 100);
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName");
}
- if (top < 1)
+ if (billingRoleAssignmentName == null)
{
- throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1);
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingRoleAssignmentName");
}
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
@@ -124,38 +101,21 @@ internal InvoicesOperations(BillingManagementClient client)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("expand", expand);
- tracingParameters.Add("filter", filter);
- tracingParameters.Add("skiptoken", skiptoken);
- tracingParameters.Add("top", top);
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ tracingParameters.Add("billingRoleAssignmentName", billingRoleAssignmentName);
tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
}
// Construct URL
var _baseUrl = Client.BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices").ToString();
- _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ _url = _url.Replace("{billingRoleAssignmentName}", System.Uri.EscapeDataString(billingRoleAssignmentName));
List _queryParameters = new List();
if (Client.ApiVersion != null)
{
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
}
- if (expand != null)
- {
- _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
- }
- if (filter != null)
- {
- _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
- }
- if (skiptoken != null)
- {
- _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken)));
- }
- if (top != null)
- {
- _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
- }
if (_queryParameters.Count > 0)
{
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
@@ -244,7 +204,7 @@ internal InvoicesOperations(BillingManagementClient client)
throw ex;
}
// Create Result
- var _result = new AzureOperationResponse>();
+ var _result = new AzureOperationResponse();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
if (_httpResponse.Headers.Contains("x-ms-request-id"))
@@ -257,7 +217,7 @@ internal InvoicesOperations(BillingManagementClient client)
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
- _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings);
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
}
catch (JsonException ex)
{
@@ -277,14 +237,13 @@ internal InvoicesOperations(BillingManagementClient client)
}
///
- /// Gets a named invoice resource. When getting a single invoice, the
- /// downloadUrl property is expanded automatically. This is only supported for
- /// Azure Web-Direct subscriptions. Other subscription types which were not
- /// purchased directly through the Azure web portal are not supported through
- /// this preview API.
+ /// Delete the role assignment on this billing account
///
- ///
- /// The name of an invoice resource.
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// role assignment id.
///
///
/// Headers that will be added to request.
@@ -307,19 +266,19 @@ internal InvoicesOperations(BillingManagementClient client)
///
/// A response object containing the response body and response headers.
///
- public async Task> GetWithHttpMessagesAsync(string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ public async Task> DeleteWithHttpMessagesAsync(string billingAccountName, string billingRoleAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
- if (Client.SubscriptionId == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
- }
if (Client.ApiVersion == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
}
- if (invoiceName == null)
+ if (billingAccountName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName");
+ }
+ if (billingRoleAssignmentName == null)
{
- throw new ValidationException(ValidationRules.CannotBeNull, "invoiceName");
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingRoleAssignmentName");
}
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
@@ -328,15 +287,16 @@ internal InvoicesOperations(BillingManagementClient client)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("invoiceName", invoiceName);
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ tracingParameters.Add("billingRoleAssignmentName", billingRoleAssignmentName);
tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
}
// Construct URL
var _baseUrl = Client.BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}").ToString();
- _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
- _url = _url.Replace("{invoiceName}", System.Uri.EscapeDataString(invoiceName));
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ _url = _url.Replace("{billingRoleAssignmentName}", System.Uri.EscapeDataString(billingRoleAssignmentName));
List _queryParameters = new List();
if (Client.ApiVersion != null)
{
@@ -349,7 +309,7 @@ internal InvoicesOperations(BillingManagementClient client)
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.Method = new HttpMethod("DELETE");
_httpRequest.RequestUri = new System.Uri(_url);
// Set Headers
if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
@@ -430,7 +390,7 @@ internal InvoicesOperations(BillingManagementClient client)
throw ex;
}
// Create Result
- var _result = new AzureOperationResponse();
+ var _result = new AzureOperationResponse();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
if (_httpResponse.Headers.Contains("x-ms-request-id"))
@@ -443,7 +403,7 @@ internal InvoicesOperations(BillingManagementClient client)
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
- _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
}
catch (JsonException ex)
{
@@ -463,12 +423,11 @@ internal InvoicesOperations(BillingManagementClient client)
}
///
- /// Gets the most recent invoice. When getting a single invoice, the
- /// downloadUrl property is expanded automatically. This is only supported for
- /// Azure Web-Direct subscriptions. Other subscription types which were not
- /// purchased directly through the Azure web portal are not supported through
- /// this preview API.
+ /// Get the role assignments on the Billing Account
///
+ ///
+ /// billing Account Id.
+ ///
///
/// Headers that will be added to request.
///
@@ -490,16 +449,16 @@ internal InvoicesOperations(BillingManagementClient client)
///
/// A response object containing the response body and response headers.
///
- public async Task> GetLatestWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ public async Task> ListWithHttpMessagesAsync(string billingAccountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
- if (Client.SubscriptionId == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
- }
if (Client.ApiVersion == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
}
+ if (billingAccountName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName");
+ }
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
@@ -507,13 +466,14 @@ internal InvoicesOperations(BillingManagementClient client)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("billingAccountName", billingAccountName);
tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "GetLatest", tracingParameters);
+ ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
}
// Construct URL
var _baseUrl = Client.BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/latest").ToString();
- _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingRoleAssignments").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
List _queryParameters = new List();
if (Client.ApiVersion != null)
{
@@ -607,7 +567,7 @@ internal InvoicesOperations(BillingManagementClient client)
throw ex;
}
// Create Result
- var _result = new AzureOperationResponse();
+ var _result = new AzureOperationResponse();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
if (_httpResponse.Headers.Contains("x-ms-request-id"))
@@ -620,7 +580,7 @@ internal InvoicesOperations(BillingManagementClient client)
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
- _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
}
catch (JsonException ex)
{
@@ -640,16 +600,10 @@ internal InvoicesOperations(BillingManagementClient client)
}
///
- /// Lists the available invoices for a subscription in reverse chronological
- /// order beginning with the most recent invoice. In preview, invoices are
- /// available via this API only for invoice periods which end December 1, 2016
- /// or later. This is only supported for Azure Web-Direct subscriptions. Other
- /// subscription types which were not purchased directly through the Azure web
- /// portal are not supported through this preview API.
- ///
+ /// The operation to add a role assignment to a billing account.
///
- ///
- /// The NextLink from the previous successful call to List operation.
+ ///
+ /// billing Account Id.
///
///
/// Headers that will be added to request.
@@ -672,12 +626,17 @@ internal InvoicesOperations(BillingManagementClient client)
///
/// A response object containing the response body and response headers.
///
- public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ public async Task> AddWithHttpMessagesAsync(string billingAccountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
- if (nextPageLink == null)
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ if (billingAccountName == null)
{
- throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName");
}
+ BillingRoleAssignmentPayload parameters = new BillingRoleAssignmentPayload();
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
@@ -685,14 +644,20 @@ internal InvoicesOperations(BillingManagementClient client)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ tracingParameters.Add("parameters", parameters);
tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
+ ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters);
}
// Construct URL
- string _url = "{nextLink}";
- _url = _url.Replace("{nextLink}", nextPageLink);
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/createBillingRoleAssignment").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
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);
@@ -700,7 +665,7 @@ internal InvoicesOperations(BillingManagementClient client)
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.Method = new HttpMethod("POST");
_httpRequest.RequestUri = new System.Uri(_url);
// Set Headers
if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
@@ -731,6 +696,12 @@ internal InvoicesOperations(BillingManagementClient client)
// Serialize Request
string _requestContent = null;
+ if(parameters != null)
+ {
+ _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
// Set Credentials
if (Client.Credentials != null)
{
@@ -751,7 +722,7 @@ internal InvoicesOperations(BillingManagementClient client)
HttpStatusCode _statusCode = _httpResponse.StatusCode;
cancellationToken.ThrowIfCancellationRequested();
string _responseContent = null;
- if ((int)_statusCode != 200)
+ if ((int)_statusCode != 201)
{
var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
try
@@ -781,7 +752,7 @@ internal InvoicesOperations(BillingManagementClient client)
throw ex;
}
// Create Result
- var _result = new AzureOperationResponse>();
+ var _result = new AzureOperationResponse();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
if (_httpResponse.Headers.Contains("x-ms-request-id"))
@@ -789,12 +760,12 @@ internal InvoicesOperations(BillingManagementClient client)
_result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
}
// Deserialize Response
- if ((int)_statusCode == 200)
+ if ((int)_statusCode == 201)
{
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
- _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings);
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
}
catch (JsonException ex)
{
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleAssignmentOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleAssignmentOperationsExtensions.cs
new file mode 100644
index 000000000000..9c5c97d5444c
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleAssignmentOperationsExtensions.cs
@@ -0,0 +1,173 @@
+//
+// 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 BillingAccountBillingRoleAssignmentOperations.
+ ///
+ public static partial class BillingAccountBillingRoleAssignmentOperationsExtensions
+ {
+ ///
+ /// Get the role assignment for the caller
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// role assignment id.
+ ///
+ public static BillingRoleAssignment Get(this IBillingAccountBillingRoleAssignmentOperations operations, string billingAccountName, string billingRoleAssignmentName)
+ {
+ return operations.GetAsync(billingAccountName, billingRoleAssignmentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Get the role assignment for the caller
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// role assignment id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IBillingAccountBillingRoleAssignmentOperations operations, string billingAccountName, string billingRoleAssignmentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(billingAccountName, billingRoleAssignmentName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Delete the role assignment on this billing account
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// role assignment id.
+ ///
+ public static BillingRoleAssignment Delete(this IBillingAccountBillingRoleAssignmentOperations operations, string billingAccountName, string billingRoleAssignmentName)
+ {
+ return operations.DeleteAsync(billingAccountName, billingRoleAssignmentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Delete the role assignment on this billing account
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// role assignment id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteAsync(this IBillingAccountBillingRoleAssignmentOperations operations, string billingAccountName, string billingRoleAssignmentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.DeleteWithHttpMessagesAsync(billingAccountName, billingRoleAssignmentName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Get the role assignments on the Billing Account
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ public static BillingRoleAssignmentListResult List(this IBillingAccountBillingRoleAssignmentOperations operations, string billingAccountName)
+ {
+ return operations.ListAsync(billingAccountName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Get the role assignments on the Billing Account
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IBillingAccountBillingRoleAssignmentOperations operations, string billingAccountName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// The operation to add a role assignment to a billing account.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ public static BillingRoleAssignmentListResult Add(this IBillingAccountBillingRoleAssignmentOperations operations, string billingAccountName)
+ {
+ return operations.AddAsync(billingAccountName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// The operation to add a role assignment to a billing account.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task AddAsync(this IBillingAccountBillingRoleAssignmentOperations operations, string billingAccountName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.AddWithHttpMessagesAsync(billingAccountName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleDefinitionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleDefinitionOperations.cs
new file mode 100644
index 000000000000..d9f31f8e92ba
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleDefinitionOperations.cs
@@ -0,0 +1,417 @@
+//
+// 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;
+
+ ///
+ /// BillingAccountBillingRoleDefinitionOperations operations.
+ ///
+ internal partial class BillingAccountBillingRoleDefinitionOperations : IServiceOperations, IBillingAccountBillingRoleDefinitionOperations
+ {
+ ///
+ /// Initializes a new instance of the BillingAccountBillingRoleDefinitionOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BillingAccountBillingRoleDefinitionOperations(BillingManagementClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the BillingManagementClient
+ ///
+ public BillingManagementClient Client { get; private set; }
+
+ ///
+ /// Gets the role definition for a role
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// role definition 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> GetWithHttpMessagesAsync(string billingAccountName, string billingRoleDefinitionName, 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 (billingRoleDefinitionName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingRoleDefinitionName");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ tracingParameters.Add("billingRoleDefinitionName", billingRoleDefinitionName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingRoleDefinitions/{billingRoleDefinitionName}").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ _url = _url.Replace("{billingRoleDefinitionName}", System.Uri.EscapeDataString(billingRoleDefinitionName));
+ 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;
+ }
+
+ ///
+ /// Lists the role definition for a billing account
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListWithHttpMessagesAsync(string billingAccountName, 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");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ 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}/providers/Microsoft.Billing/billingRoleDefinitions").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ 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/BillingAccountBillingRoleDefinitionOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleDefinitionOperationsExtensions.cs
new file mode 100644
index 000000000000..972504e8b1e8
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountBillingRoleDefinitionOperationsExtensions.cs
@@ -0,0 +1,99 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for BillingAccountBillingRoleDefinitionOperations.
+ ///
+ public static partial class BillingAccountBillingRoleDefinitionOperationsExtensions
+ {
+ ///
+ /// Gets the role definition for a role
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// role definition id.
+ ///
+ public static BillingRoleDefinition Get(this IBillingAccountBillingRoleDefinitionOperations operations, string billingAccountName, string billingRoleDefinitionName)
+ {
+ return operations.GetAsync(billingAccountName, billingRoleDefinitionName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets the role definition for a role
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// role definition id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IBillingAccountBillingRoleDefinitionOperations operations, string billingAccountName, string billingRoleDefinitionName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(billingAccountName, billingRoleDefinitionName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Lists the role definition for a billing account
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ public static BillingRoleDefinitionListResult List(this IBillingAccountBillingRoleDefinitionOperations operations, string billingAccountName)
+ {
+ return operations.ListAsync(billingAccountName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists the role definition for a billing account
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IBillingAccountBillingRoleDefinitionOperations operations, string billingAccountName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsOperations.cs
new file mode 100644
index 000000000000..1d076d68748b
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsOperations.cs
@@ -0,0 +1,415 @@
+//
+// 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;
+
+ ///
+ /// BillingAccountsOperations operations.
+ ///
+ internal partial class BillingAccountsOperations : IServiceOperations, IBillingAccountsOperations
+ {
+ ///
+ /// Initializes a new instance of the BillingAccountsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BillingAccountsOperations(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 billing accounts for a user which he has access to.
+ ///
+ ///
+ /// May be used to expand the invoiceSections and billingProfiles.
+ ///
+ ///
+ /// 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 expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("expand", expand);
+ 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").ToString();
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (expand != null)
+ {
+ _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
+ }
+ 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 billing account by id.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// May be used to expand the invoiceSections and billingProfiles.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetWithHttpMessagesAsync(string billingAccountName, string expand = default(string), 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");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ tracingParameters.Add("expand", expand);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (expand != null)
+ {
+ _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
+ }
+ 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/BillingAccountsOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsOperationsExtensions.cs
new file mode 100644
index 000000000000..ba67081d8381
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsOperationsExtensions.cs
@@ -0,0 +1,99 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for BillingAccountsOperations.
+ ///
+ public static partial class BillingAccountsOperationsExtensions
+ {
+ ///
+ /// Lists all billing accounts for a user which he has access to.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// May be used to expand the invoiceSections and billingProfiles.
+ ///
+ public static BillingAccountListResult List(this IBillingAccountsOperations operations, string expand = default(string))
+ {
+ return operations.ListAsync(expand).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists all billing accounts for a user which he has access to.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// May be used to expand the invoiceSections and billingProfiles.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IBillingAccountsOperations operations, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(expand, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Get the billing account by id.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// May be used to expand the invoiceSections and billingProfiles.
+ ///
+ public static BillingAccount Get(this IBillingAccountsOperations operations, string billingAccountName, string expand = default(string))
+ {
+ return operations.GetAsync(billingAccountName, expand).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Get the billing account by id.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// May be used to expand the invoiceSections and billingProfiles.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IBillingAccountsOperations operations, string billingAccountName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(billingAccountName, expand, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsWithCreateInvoiceSectionPermissionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsWithCreateInvoiceSectionPermissionOperations.cs
new file mode 100644
index 000000000000..ad75dffb454b
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsWithCreateInvoiceSectionPermissionOperations.cs
@@ -0,0 +1,231 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.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;
+
+ ///
+ /// BillingAccountsWithCreateInvoiceSectionPermissionOperations operations.
+ ///
+ internal partial class BillingAccountsWithCreateInvoiceSectionPermissionOperations : IServiceOperations, IBillingAccountsWithCreateInvoiceSectionPermissionOperations
+ {
+ ///
+ /// Initializes a new instance of the BillingAccountsWithCreateInvoiceSectionPermissionOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BillingAccountsWithCreateInvoiceSectionPermissionOperations(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 billing accounts with create invoiceSection permission for a
+ /// user.
+ ///
+ ///
+ /// May be used to expand the invoiceSections and billingProfiles.
+ ///
+ ///
+ /// 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 expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("expand", expand);
+ 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/listBillingAccountsWithCreateInvoiceSectionPermission").ToString();
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (expand != null)
+ {
+ _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
+ }
+ 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/BillingAccountsWithCreateInvoiceSectionPermissionOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsWithCreateInvoiceSectionPermissionOperationsExtensions.cs
new file mode 100644
index 000000000000..c70367f78729
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsWithCreateInvoiceSectionPermissionOperationsExtensions.cs
@@ -0,0 +1,61 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for BillingAccountsWithCreateInvoiceSectionPermissionOperations.
+ ///
+ public static partial class BillingAccountsWithCreateInvoiceSectionPermissionOperationsExtensions
+ {
+ ///
+ /// Lists all billing accounts with create invoiceSection permission for a
+ /// user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// May be used to expand the invoiceSections and billingProfiles.
+ ///
+ public static BillingAccountListResult List(this IBillingAccountsWithCreateInvoiceSectionPermissionOperations operations, string expand = default(string))
+ {
+ return operations.ListAsync(expand).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists all billing accounts with create invoiceSection permission for a
+ /// user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// May be used to expand the invoiceSections and billingProfiles.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IBillingAccountsWithCreateInvoiceSectionPermissionOperations operations, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(expand, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs
index c526acc2501b..3b1d69e4d146 100644
--- a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs
@@ -20,6 +20,8 @@ namespace Microsoft.Azure.Management.Billing
using System.Linq;
using System.Net;
using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
///
/// Billing client provides access to billing resources for Azure
@@ -49,7 +51,7 @@ public partial class BillingManagementClient : ServiceClient
/// Version of the API to be used with the client request. The current version
- /// is 2018-03-01-preview.
+ /// is 2018-11-01-preview.
///
public string ApiVersion { get; private set; }
@@ -59,42 +61,241 @@ public partial class BillingManagementClient : ServiceClient
- /// Gets or sets the preferred language for the response.
+ /// The preferred language for the response.
///
public string AcceptLanguage { get; set; }
///
- /// Gets or sets the retry timeout in seconds for Long Running Operations.
- /// Default value is 30.
+ /// The retry timeout in seconds for Long Running Operations. Default value is
+ /// 30.
///
public int? LongRunningOperationRetryTimeout { get; set; }
///
- /// When set to true a unique x-ms-client-request-id value is generated and
- /// included in each request. Default is true.
+ /// Whether a unique x-ms-client-request-id should be generated. When set to
+ /// true a unique x-ms-client-request-id value is generated and included in
+ /// each request. Default is true.
///
public bool? GenerateClientRequestId { get; set; }
+ ///
+ /// Gets the IBillingAccountsOperations.
+ ///
+ public virtual IBillingAccountsOperations BillingAccounts { get; private set; }
+
+ ///
+ /// Gets the IBillingAccountsWithCreateInvoiceSectionPermissionOperations.
+ ///
+ public virtual IBillingAccountsWithCreateInvoiceSectionPermissionOperations BillingAccountsWithCreateInvoiceSectionPermission { get; private set; }
+
+ ///
+ /// Gets the IAvailableBalanceByBillingProfileOperations.
+ ///
+ public virtual IAvailableBalanceByBillingProfileOperations AvailableBalanceByBillingProfile { get; private set; }
+
+ ///
+ /// Gets the IPaymentMethodsByBillingProfileOperations.
+ ///
+ public virtual IPaymentMethodsByBillingProfileOperations PaymentMethodsByBillingProfile { get; private set; }
+
+ ///
+ /// Gets the IBillingProfilesByBillingAccountNameOperations.
+ ///
+ public virtual IBillingProfilesByBillingAccountNameOperations BillingProfilesByBillingAccountName { get; private set; }
+
+ ///
+ /// Gets the IBillingProfilesOperations.
+ ///
+ public virtual IBillingProfilesOperations BillingProfiles { get; private set; }
+
+ ///
+ /// Gets the IInvoiceSectionsByBillingAccountNameOperations.
+ ///
+ public virtual IInvoiceSectionsByBillingAccountNameOperations InvoiceSectionsByBillingAccountName { get; private set; }
+
+ ///
+ /// Gets the IInvoiceSectionsOperations.
+ ///
+ public virtual IInvoiceSectionsOperations InvoiceSections { get; private set; }
+
+ ///
+ /// Gets the IInvoiceSectionsWithCreateSubscriptionPermissionOperations.
+ ///
+ public virtual IInvoiceSectionsWithCreateSubscriptionPermissionOperations InvoiceSectionsWithCreateSubscriptionPermission { get; private set; }
+
+ ///
+ /// Gets the IDepartmentsByBillingAccountNameOperations.
+ ///
+ public virtual IDepartmentsByBillingAccountNameOperations DepartmentsByBillingAccountName { get; private set; }
+
+ ///
+ /// Gets the IDepartmentsOperations.
+ ///
+ public virtual IDepartmentsOperations Departments { get; private set; }
+
+ ///
+ /// Gets the IEnrollmentAccountsByBillingAccountNameOperations.
+ ///
+ public virtual IEnrollmentAccountsByBillingAccountNameOperations EnrollmentAccountsByBillingAccountName { get; private set; }
+
///
/// Gets the IEnrollmentAccountsOperations.
///
public virtual IEnrollmentAccountsOperations EnrollmentAccounts { get; private set; }
///
- /// Gets the IBillingPeriodsOperations.
+ /// Gets the IInvoicesByBillingAccountOperations.
+ ///
+ public virtual IInvoicesByBillingAccountOperations InvoicesByBillingAccount { get; private set; }
+
+ ///
+ /// Gets the IInvoicePricesheetOperations.
+ ///
+ public virtual IInvoicePricesheetOperations InvoicePricesheet { get; private set; }
+
+ ///
+ /// Gets the IInvoicesByBillingProfileOperations.
+ ///
+ public virtual IInvoicesByBillingProfileOperations InvoicesByBillingProfile { get; private set; }
+
+ ///
+ /// Gets the IInvoiceOperations.
+ ///
+ public virtual IInvoiceOperations Invoice { get; private set; }
+
+ ///
+ /// Gets the IProductsByBillingSubscriptionsOperations.
+ ///
+ public virtual IProductsByBillingSubscriptionsOperations ProductsByBillingSubscriptions { get; private set; }
+
+ ///
+ /// Gets the IBillingSubscriptionsByBillingProfileOperations.
///
- public virtual IBillingPeriodsOperations BillingPeriods { get; private set; }
+ public virtual IBillingSubscriptionsByBillingProfileOperations BillingSubscriptionsByBillingProfile { get; private set; }
///
- /// Gets the IInvoicesOperations.
+ /// Gets the IBillingSubscriptionsByInvoiceSectionOperations.
///
- public virtual IInvoicesOperations Invoices { get; private set; }
+ public virtual IBillingSubscriptionsByInvoiceSectionOperations BillingSubscriptionsByInvoiceSection { get; private set; }
+
+ ///
+ /// Gets the IBillingSubscriptionOperations.
+ ///
+ public virtual IBillingSubscriptionOperations BillingSubscription { get; private set; }
+
+ ///
+ /// Gets the IProductsByBillingAccountOperations.
+ ///
+ public virtual IProductsByBillingAccountOperations ProductsByBillingAccount { get; private set; }
+
+ ///
+ /// Gets the IProductsByInvoiceSectionOperations.
+ ///
+ public virtual IProductsByInvoiceSectionOperations ProductsByInvoiceSection { get; private set; }
+
+ ///
+ /// Gets the IProductsOperations.
+ ///
+ public virtual IProductsOperations Products { get; private set; }
+
+ ///
+ /// Gets the ITransactionsByBillingAccountOperations.
+ ///
+ public virtual ITransactionsByBillingAccountOperations TransactionsByBillingAccount { get; private set; }
+
+ ///
+ /// Gets the ITransactionsByBillingProfileOperations.
+ ///
+ public virtual ITransactionsByBillingProfileOperations TransactionsByBillingProfile { get; private set; }
+
+ ///
+ /// Gets the ITransactionsByInvoiceSectionOperations.
+ ///
+ public virtual ITransactionsByInvoiceSectionOperations TransactionsByInvoiceSection { get; private set; }
+
+ ///
+ /// Gets the IPolicyOperations.
+ ///
+ public virtual IPolicyOperations Policy { get; private set; }
+
+ ///
+ /// Gets the IBillingPropertyOperations.
+ ///
+ public virtual IBillingPropertyOperations BillingProperty { get; private set; }
+
+ ///
+ /// Gets the ITransfersOperations.
+ ///
+ public virtual ITransfersOperations Transfers { get; private set; }
+
+ ///
+ /// Gets the IRecipientTransfersOperations.
+ ///
+ public virtual IRecipientTransfersOperations RecipientTransfers { get; private set; }
///
/// Gets the IOperations.
///
public virtual IOperations Operations { get; private set; }
+ ///
+ /// Gets the IBillingAccountBillingPermissionsOperations.
+ ///
+ public virtual IBillingAccountBillingPermissionsOperations BillingAccountBillingPermissions { get; private set; }
+
+ ///
+ /// Gets the IInvoiceSectionsBillingPermissionsOperations.
+ ///
+ public virtual IInvoiceSectionsBillingPermissionsOperations InvoiceSectionsBillingPermissions { get; private set; }
+
+ ///
+ /// Gets the IBillingProfileBillingPermissionsOperations.
+ ///
+ public virtual IBillingProfileBillingPermissionsOperations BillingProfileBillingPermissions { get; private set; }
+
+ ///
+ /// Gets the IBillingAccountBillingRoleDefinitionOperations.
+ ///
+ public virtual IBillingAccountBillingRoleDefinitionOperations BillingAccountBillingRoleDefinition { get; private set; }
+
+ ///
+ /// Gets the IInvoiceSectionBillingRoleDefinitionOperations.
+ ///
+ public virtual IInvoiceSectionBillingRoleDefinitionOperations InvoiceSectionBillingRoleDefinition { get; private set; }
+
+ ///
+ /// Gets the IBillingProfileBillingRoleDefinitionOperations.
+ ///
+ public virtual IBillingProfileBillingRoleDefinitionOperations BillingProfileBillingRoleDefinition { get; private set; }
+
+ ///
+ /// Gets the IBillingAccountBillingRoleAssignmentOperations.
+ ///
+ public virtual IBillingAccountBillingRoleAssignmentOperations BillingAccountBillingRoleAssignment { get; private set; }
+
+ ///
+ /// Gets the IInvoiceSectionBillingRoleAssignmentOperations.
+ ///
+ public virtual IInvoiceSectionBillingRoleAssignmentOperations InvoiceSectionBillingRoleAssignment { get; private set; }
+
+ ///
+ /// Gets the IBillingProfileBillingRoleAssignmentOperations.
+ ///
+ public virtual IBillingProfileBillingRoleAssignmentOperations BillingProfileBillingRoleAssignment { get; private set; }
+
+ ///
+ /// Initializes a new instance of the BillingManagementClient class.
+ ///
+ ///
+ /// HttpClient to be used
+ ///
+ ///
+ /// True: will dispose the provided httpClient on calling BillingManagementClient.Dispose(). False: will not dispose provided httpClient
+ protected BillingManagementClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
+ {
+ Initialize();
+ }
+
///
/// Initializes a new instance of the BillingManagementClient class.
///
@@ -190,6 +391,33 @@ public BillingManagementClient(ServiceClientCredentials credentials, params Dele
}
}
+ ///
+ /// Initializes a new instance of the BillingManagementClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// HttpClient to be used
+ ///
+ ///
+ /// True: will dispose the provided httpClient on calling BillingManagementClient.Dispose(). False: will not dispose provided httpClient
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public BillingManagementClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
///
/// Initializes a new instance of the BillingManagementClient class.
///
@@ -296,12 +524,49 @@ public BillingManagementClient(System.Uri baseUri, ServiceClientCredentials cred
///
private void Initialize()
{
+ BillingAccounts = new BillingAccountsOperations(this);
+ BillingAccountsWithCreateInvoiceSectionPermission = new BillingAccountsWithCreateInvoiceSectionPermissionOperations(this);
+ AvailableBalanceByBillingProfile = new AvailableBalanceByBillingProfileOperations(this);
+ PaymentMethodsByBillingProfile = new PaymentMethodsByBillingProfileOperations(this);
+ BillingProfilesByBillingAccountName = new BillingProfilesByBillingAccountNameOperations(this);
+ BillingProfiles = new BillingProfilesOperations(this);
+ InvoiceSectionsByBillingAccountName = new InvoiceSectionsByBillingAccountNameOperations(this);
+ InvoiceSections = new InvoiceSectionsOperations(this);
+ InvoiceSectionsWithCreateSubscriptionPermission = new InvoiceSectionsWithCreateSubscriptionPermissionOperations(this);
+ DepartmentsByBillingAccountName = new DepartmentsByBillingAccountNameOperations(this);
+ Departments = new DepartmentsOperations(this);
+ EnrollmentAccountsByBillingAccountName = new EnrollmentAccountsByBillingAccountNameOperations(this);
EnrollmentAccounts = new EnrollmentAccountsOperations(this);
- BillingPeriods = new BillingPeriodsOperations(this);
- Invoices = new InvoicesOperations(this);
+ InvoicesByBillingAccount = new InvoicesByBillingAccountOperations(this);
+ InvoicePricesheet = new InvoicePricesheetOperations(this);
+ InvoicesByBillingProfile = new InvoicesByBillingProfileOperations(this);
+ Invoice = new InvoiceOperations(this);
+ ProductsByBillingSubscriptions = new ProductsByBillingSubscriptionsOperations(this);
+ BillingSubscriptionsByBillingProfile = new BillingSubscriptionsByBillingProfileOperations(this);
+ BillingSubscriptionsByInvoiceSection = new BillingSubscriptionsByInvoiceSectionOperations(this);
+ BillingSubscription = new BillingSubscriptionOperations(this);
+ ProductsByBillingAccount = new ProductsByBillingAccountOperations(this);
+ ProductsByInvoiceSection = new ProductsByInvoiceSectionOperations(this);
+ Products = new ProductsOperations(this);
+ TransactionsByBillingAccount = new TransactionsByBillingAccountOperations(this);
+ TransactionsByBillingProfile = new TransactionsByBillingProfileOperations(this);
+ TransactionsByInvoiceSection = new TransactionsByInvoiceSectionOperations(this);
+ Policy = new PolicyOperations(this);
+ BillingProperty = new BillingPropertyOperations(this);
+ Transfers = new TransfersOperations(this);
+ RecipientTransfers = new RecipientTransfersOperations(this);
Operations = new Operations(this);
+ BillingAccountBillingPermissions = new BillingAccountBillingPermissionsOperations(this);
+ InvoiceSectionsBillingPermissions = new InvoiceSectionsBillingPermissionsOperations(this);
+ BillingProfileBillingPermissions = new BillingProfileBillingPermissionsOperations(this);
+ BillingAccountBillingRoleDefinition = new BillingAccountBillingRoleDefinitionOperations(this);
+ InvoiceSectionBillingRoleDefinition = new InvoiceSectionBillingRoleDefinitionOperations(this);
+ BillingProfileBillingRoleDefinition = new BillingProfileBillingRoleDefinitionOperations(this);
+ BillingAccountBillingRoleAssignment = new BillingAccountBillingRoleAssignmentOperations(this);
+ InvoiceSectionBillingRoleAssignment = new InvoiceSectionBillingRoleAssignmentOperations(this);
+ BillingProfileBillingRoleAssignment = new BillingProfileBillingRoleAssignmentOperations(this);
BaseUri = new System.Uri("https://management.azure.com");
- ApiVersion = "2018-03-01-preview";
+ ApiVersion = "2018-11-01-preview";
AcceptLanguage = "en-US";
LongRunningOperationRetryTimeout = 30;
GenerateClientRequestId = true;
@@ -335,5 +600,414 @@ private void Initialize()
DeserializationSettings.Converters.Add(new TransformationJsonConverter());
DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
}
+ ///
+ /// Cancel product by product id
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Invoice Id.
+ ///
+ ///
+ /// Update auto renew request parameters.
+ ///
+ ///
+ /// 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> UpdateAutoRenewForBillingAccountWithHttpMessagesAsync(string billingAccountName, string productName, UpdateAutoRenewRequest body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (billingAccountName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName");
+ }
+ if (productName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "productName");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ if (body == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "body");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ tracingParameters.Add("productName", productName);
+ tracingParameters.Add("body", body);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "UpdateAutoRenewForBillingAccount", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/updateAutoRenew").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ _url = _url.Replace("{productName}", System.Uri.EscapeDataString(productName));
+ List _queryParameters = new List();
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(body != null)
+ {
+ _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await 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 = SafeJsonConvert.DeserializeObject(_responseContent, 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 = SafeJsonConvert.DeserializeObject(_responseContent, 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;
+ }
+
+ ///
+ /// Cancel auto renew for product by product id
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// InvoiceSection Id.
+ ///
+ ///
+ /// Invoice Id.
+ ///
+ ///
+ /// Update auto renew request parameters.
+ ///
+ ///
+ /// 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> UpdateAutoRenewForInvoiceSectionWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, string productName, UpdateAutoRenewRequest body, 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");
+ }
+ if (productName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "productName");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ if (body == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "body");
+ }
+ // 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("productName", productName);
+ tracingParameters.Add("body", body);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "UpdateAutoRenewForInvoiceSection", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/products/{productName}/updateAutoRenew").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ _url = _url.Replace("{invoiceSectionName}", System.Uri.EscapeDataString(invoiceSectionName));
+ _url = _url.Replace("{productName}", System.Uri.EscapeDataString(productName));
+ List _queryParameters = new List();
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(body != null)
+ {
+ _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await 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 = SafeJsonConvert.DeserializeObject(_responseContent, 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 = SafeJsonConvert.DeserializeObject(_responseContent, 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/BillingManagementClientExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClientExtensions.cs
new file mode 100644
index 000000000000..a2fd45941a5a
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClientExtensions.cs
@@ -0,0 +1,123 @@
+//
+// 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 BillingManagementClient.
+ ///
+ public static partial class BillingManagementClientExtensions
+ {
+ ///
+ /// Cancel product by product id
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Invoice Id.
+ ///
+ ///
+ /// Update auto renew request parameters.
+ ///
+ public static UpdateAutoRenewOperationSummary UpdateAutoRenewForBillingAccount(this IBillingManagementClient operations, string billingAccountName, string productName, UpdateAutoRenewRequest body)
+ {
+ return operations.UpdateAutoRenewForBillingAccountAsync(billingAccountName, productName, body).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Cancel product by product id
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Invoice Id.
+ ///
+ ///
+ /// Update auto renew request parameters.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task UpdateAutoRenewForBillingAccountAsync(this IBillingManagementClient operations, string billingAccountName, string productName, UpdateAutoRenewRequest body, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.UpdateAutoRenewForBillingAccountWithHttpMessagesAsync(billingAccountName, productName, body, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Cancel auto renew for product by product id
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// InvoiceSection Id.
+ ///
+ ///
+ /// Invoice Id.
+ ///
+ ///
+ /// Update auto renew request parameters.
+ ///
+ public static UpdateAutoRenewOperationSummary UpdateAutoRenewForInvoiceSection(this IBillingManagementClient operations, string billingAccountName, string invoiceSectionName, string productName, UpdateAutoRenewRequest body)
+ {
+ return operations.UpdateAutoRenewForInvoiceSectionAsync(billingAccountName, invoiceSectionName, productName, body).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Cancel auto renew for product by product id
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// InvoiceSection Id.
+ ///
+ ///
+ /// Invoice Id.
+ ///
+ ///
+ /// Update auto renew request parameters.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task UpdateAutoRenewForInvoiceSectionAsync(this IBillingManagementClient operations, string billingAccountName, string invoiceSectionName, string productName, UpdateAutoRenewRequest body, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.UpdateAutoRenewForInvoiceSectionWithHttpMessagesAsync(billingAccountName, invoiceSectionName, productName, body, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingPeriodsOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingPeriodsOperationsExtensions.cs
deleted file mode 100644
index 4760a7e2bf18..000000000000
--- a/src/SDKs/Billing/Management.Billing/Generated/BillingPeriodsOperationsExtensions.cs
+++ /dev/null
@@ -1,171 +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 BillingPeriodsOperations.
- ///
- public static partial class BillingPeriodsOperationsExtensions
- {
- ///
- /// Lists the available billing periods for a subscription in reverse
- /// chronological order. This is only supported for Azure Web-Direct
- /// subscriptions. Other subscription types which were not purchased directly
- /// through the Azure web portal are not supported through this preview API.
- ///
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// May be used to filter billing periods by billingPeriodEndDate. The filter
- /// supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently
- /// support 'ne', 'or', or 'not'.
- ///
- ///
- /// Skiptoken is only used if a previous operation returned a partial result.
- /// If a previous response contains a nextLink element, the value of the
- /// nextLink element will include a skiptoken parameter that specifies a
- /// starting point to use for subsequent calls.
- ///
- ///
- /// May be used to limit the number of results to the most recent N billing
- /// periods.
- ///
- public static IPage List(this IBillingPeriodsOperations operations, string filter = default(string), string skiptoken = default(string), int? top = default(int?))
- {
- return operations.ListAsync(filter, skiptoken, top).GetAwaiter().GetResult();
- }
-
- ///
- /// Lists the available billing periods for a subscription in reverse
- /// chronological order. This is only supported for Azure Web-Direct
- /// subscriptions. Other subscription types which were not purchased directly
- /// through the Azure web portal are not supported through this preview API.
- ///
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// May be used to filter billing periods by billingPeriodEndDate. The filter
- /// supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently
- /// support 'ne', 'or', or 'not'.
- ///
- ///
- /// Skiptoken is only used if a previous operation returned a partial result.
- /// If a previous response contains a nextLink element, the value of the
- /// nextLink element will include a skiptoken parameter that specifies a
- /// starting point to use for subsequent calls.
- ///
- ///
- /// May be used to limit the number of results to the most recent N billing
- /// periods.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task> ListAsync(this IBillingPeriodsOperations operations, string filter = default(string), string skiptoken = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.ListWithHttpMessagesAsync(filter, skiptoken, top, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Gets a named billing period. This is only supported for Azure Web-Direct
- /// subscriptions. Other subscription types which were not purchased directly
- /// through the Azure web portal are not supported through this preview API.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The name of a BillingPeriod resource.
- ///
- public static BillingPeriod Get(this IBillingPeriodsOperations operations, string billingPeriodName)
- {
- return operations.GetAsync(billingPeriodName).GetAwaiter().GetResult();
- }
-
- ///
- /// Gets a named billing period. This is only supported for Azure Web-Direct
- /// subscriptions. Other subscription types which were not purchased directly
- /// through the Azure web portal are not supported through this preview API.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The name of a BillingPeriod resource.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task GetAsync(this IBillingPeriodsOperations operations, string billingPeriodName, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.GetWithHttpMessagesAsync(billingPeriodName, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Lists the available billing periods for a subscription in reverse
- /// chronological order. This is only supported for Azure Web-Direct
- /// subscriptions. Other subscription types which were not purchased directly
- /// through the Azure web portal are not supported through this preview API.
- ///
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The NextLink from the previous successful call to List operation.
- ///
- public static IPage ListNext(this IBillingPeriodsOperations operations, string nextPageLink)
- {
- return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult();
- }
-
- ///
- /// Lists the available billing periods for a subscription in reverse
- /// chronological order. This is only supported for Azure Web-Direct
- /// subscriptions. Other subscription types which were not purchased directly
- /// through the Azure web portal are not supported through this preview API.
- ///
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The NextLink from the previous successful call to List operation.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task> ListNextAsync(this IBillingPeriodsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- }
-}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingPermissionsOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingPermissionsOperations.cs
new file mode 100644
index 000000000000..4c69b8c7dba1
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingPermissionsOperations.cs
@@ -0,0 +1,240 @@
+//
+// 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;
+
+ ///
+ /// BillingProfileBillingPermissionsOperations operations.
+ ///
+ internal partial class BillingProfileBillingPermissionsOperations : IServiceOperations, IBillingProfileBillingPermissionsOperations
+ {
+ ///
+ /// Initializes a new instance of the BillingProfileBillingPermissionsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BillingProfileBillingPermissionsOperations(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 billingPermissions for the caller has for a billing account.
+ ///
+ ///
+ /// 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}/providers/Microsoft.Billing/billingPermissions").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/BillingProfileBillingPermissionsOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingPermissionsOperationsExtensions.cs
new file mode 100644
index 000000000000..e3a61bd24fc4
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingPermissionsOperationsExtensions.cs
@@ -0,0 +1,65 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for BillingProfileBillingPermissionsOperations.
+ ///
+ public static partial class BillingProfileBillingPermissionsOperationsExtensions
+ {
+ ///
+ /// Lists all billingPermissions for the caller has for a billing account.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ public static BillingPermissionsListResult List(this IBillingProfileBillingPermissionsOperations operations, string billingAccountName, string billingProfileName)
+ {
+ return operations.ListAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists all billingPermissions for the caller has for a billing account.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IBillingProfileBillingPermissionsOperations 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/BillingProfileBillingRoleAssignmentOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleAssignmentOperations.cs
new file mode 100644
index 000000000000..c5f50eafb4e1
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleAssignmentOperations.cs
@@ -0,0 +1,824 @@
+//
+// 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;
+
+ ///
+ /// BillingProfileBillingRoleAssignmentOperations operations.
+ ///
+ internal partial class BillingProfileBillingRoleAssignmentOperations : IServiceOperations, IBillingProfileBillingRoleAssignmentOperations
+ {
+ ///
+ /// Initializes a new instance of the BillingProfileBillingRoleAssignmentOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BillingProfileBillingRoleAssignmentOperations(BillingManagementClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the BillingManagementClient
+ ///
+ public BillingManagementClient Client { get; private set; }
+
+ ///
+ /// Get the role assignment for the caller on the Billing Profile
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// role assignment 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> GetWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string billingRoleAssignmentName, 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");
+ }
+ if (billingRoleAssignmentName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingRoleAssignmentName");
+ }
+ // 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("billingRoleAssignmentName", billingRoleAssignmentName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName));
+ _url = _url.Replace("{billingRoleAssignmentName}", System.Uri.EscapeDataString(billingRoleAssignmentName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Delete the role assignment on this Billing Profile
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// role assignment 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> DeleteWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string billingRoleAssignmentName, 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");
+ }
+ if (billingRoleAssignmentName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingRoleAssignmentName");
+ }
+ // 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("billingRoleAssignmentName", billingRoleAssignmentName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName));
+ _url = _url.Replace("{billingRoleAssignmentName}", System.Uri.EscapeDataString(billingRoleAssignmentName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ 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 role assignments on the Billing Profile
+ ///
+ ///
+ /// 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}/providers/Microsoft.Billing/billingRoleAssignments").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;
+ }
+
+ ///
+ /// The operation to add a role assignment to a billing profile.
+ ///
+ ///
+ /// 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> AddWithHttpMessagesAsync(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");
+ }
+ BillingRoleAssignmentPayload parameters = new BillingRoleAssignmentPayload();
+ // 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("parameters", parameters);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Add", 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}/providers/Microsoft.Billing/createBillingRoleAssignment").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("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(parameters != null)
+ {
+ _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 201)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 201)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleAssignmentOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleAssignmentOperationsExtensions.cs
new file mode 100644
index 000000000000..fa423fd5851b
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleAssignmentOperationsExtensions.cs
@@ -0,0 +1,197 @@
+//
+// 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 BillingProfileBillingRoleAssignmentOperations.
+ ///
+ public static partial class BillingProfileBillingRoleAssignmentOperationsExtensions
+ {
+ ///
+ /// Get the role assignment for the caller on the Billing Profile
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// role assignment id.
+ ///
+ public static BillingRoleAssignment Get(this IBillingProfileBillingRoleAssignmentOperations operations, string billingAccountName, string billingProfileName, string billingRoleAssignmentName)
+ {
+ return operations.GetAsync(billingAccountName, billingProfileName, billingRoleAssignmentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Get the role assignment for the caller on the Billing Profile
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// role assignment id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IBillingProfileBillingRoleAssignmentOperations operations, string billingAccountName, string billingProfileName, string billingRoleAssignmentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(billingAccountName, billingProfileName, billingRoleAssignmentName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Delete the role assignment on this Billing Profile
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// role assignment id.
+ ///
+ public static BillingRoleAssignment Delete(this IBillingProfileBillingRoleAssignmentOperations operations, string billingAccountName, string billingProfileName, string billingRoleAssignmentName)
+ {
+ return operations.DeleteAsync(billingAccountName, billingProfileName, billingRoleAssignmentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Delete the role assignment on this Billing Profile
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// role assignment id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteAsync(this IBillingProfileBillingRoleAssignmentOperations operations, string billingAccountName, string billingProfileName, string billingRoleAssignmentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.DeleteWithHttpMessagesAsync(billingAccountName, billingProfileName, billingRoleAssignmentName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Get the role assignments on the Billing Profile
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ public static BillingRoleAssignmentListResult List(this IBillingProfileBillingRoleAssignmentOperations operations, string billingAccountName, string billingProfileName)
+ {
+ return operations.ListAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Get the role assignments on the Billing Profile
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IBillingProfileBillingRoleAssignmentOperations operations, string billingAccountName, string billingProfileName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountName, billingProfileName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// The operation to add a role assignment to a billing profile.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ public static BillingRoleAssignmentListResult Add(this IBillingProfileBillingRoleAssignmentOperations operations, string billingAccountName, string billingProfileName)
+ {
+ return operations.AddAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// The operation to add a role assignment to a billing profile.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task AddAsync(this IBillingProfileBillingRoleAssignmentOperations operations, string billingAccountName, string billingProfileName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.AddWithHttpMessagesAsync(billingAccountName, billingProfileName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleDefinitionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleDefinitionOperations.cs
new file mode 100644
index 000000000000..e8618415b33c
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleDefinitionOperations.cs
@@ -0,0 +1,435 @@
+//
+// 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;
+
+ ///
+ /// BillingProfileBillingRoleDefinitionOperations operations.
+ ///
+ internal partial class BillingProfileBillingRoleDefinitionOperations : IServiceOperations, IBillingProfileBillingRoleDefinitionOperations
+ {
+ ///
+ /// Initializes a new instance of the BillingProfileBillingRoleDefinitionOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BillingProfileBillingRoleDefinitionOperations(BillingManagementClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the BillingManagementClient
+ ///
+ public BillingManagementClient Client { get; private set; }
+
+ ///
+ /// Gets the role definition for a role
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// role definition 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> GetWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string billingRoleDefinitionName, 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");
+ }
+ if (billingRoleDefinitionName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "billingRoleDefinitionName");
+ }
+ // 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("billingRoleDefinitionName", billingRoleDefinitionName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/billingRoleDefinitions/{billingRoleDefinitionName}").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName));
+ _url = _url.Replace("{billingRoleDefinitionName}", System.Uri.EscapeDataString(billingRoleDefinitionName));
+ 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;
+ }
+
+ ///
+ /// Lists the role definition for a Billing Profile
+ ///
+ ///
+ /// 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}/providers/Microsoft.Billing/billingRoleDefinitions").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/BillingProfileBillingRoleDefinitionOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleDefinitionOperationsExtensions.cs
new file mode 100644
index 000000000000..7fddfc1defe2
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfileBillingRoleDefinitionOperationsExtensions.cs
@@ -0,0 +1,111 @@
+//
+// 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 BillingProfileBillingRoleDefinitionOperations.
+ ///
+ public static partial class BillingProfileBillingRoleDefinitionOperationsExtensions
+ {
+ ///
+ /// Gets the role definition for a role
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// role definition id.
+ ///
+ public static BillingRoleDefinition Get(this IBillingProfileBillingRoleDefinitionOperations operations, string billingAccountName, string billingProfileName, string billingRoleDefinitionName)
+ {
+ return operations.GetAsync(billingAccountName, billingProfileName, billingRoleDefinitionName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets the role definition for a role
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// role definition id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IBillingProfileBillingRoleDefinitionOperations operations, string billingAccountName, string billingProfileName, string billingRoleDefinitionName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(billingAccountName, billingProfileName, billingRoleDefinitionName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Lists the role definition for a Billing Profile
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ public static BillingRoleDefinitionListResult List(this IBillingProfileBillingRoleDefinitionOperations operations, string billingAccountName, string billingProfileName)
+ {
+ return operations.ListAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists the role definition for a Billing Profile
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IBillingProfileBillingRoleDefinitionOperations 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/BillingProfilesByBillingAccountNameOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfilesByBillingAccountNameOperations.cs
new file mode 100644
index 000000000000..cf82722d2b9c
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfilesByBillingAccountNameOperations.cs
@@ -0,0 +1,239 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.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;
+
+ ///
+ /// BillingProfilesByBillingAccountNameOperations operations.
+ ///
+ internal partial class BillingProfilesByBillingAccountNameOperations : IServiceOperations, IBillingProfilesByBillingAccountNameOperations
+ {
+ ///
+ /// Initializes a new instance of the BillingProfilesByBillingAccountNameOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BillingProfilesByBillingAccountNameOperations(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 billing profiles for a user which that user has access to.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// May be used to expand the invoiceSections.
+ ///
+ ///
+ /// 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 expand = default(string), 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");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("billingAccountName", billingAccountName);
+ tracingParameters.Add("expand", expand);
+ 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").ToString();
+ _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (expand != null)
+ {
+ _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
+ }
+ 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/BillingProfilesByBillingAccountNameOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfilesByBillingAccountNameOperationsExtensions.cs
new file mode 100644
index 000000000000..64e0e2b630c6
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfilesByBillingAccountNameOperationsExtensions.cs
@@ -0,0 +1,65 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for BillingProfilesByBillingAccountNameOperations.
+ ///
+ public static partial class BillingProfilesByBillingAccountNameOperationsExtensions
+ {
+ ///
+ /// Lists all billing profiles for a user which that user has access to.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// May be used to expand the invoiceSections.
+ ///
+ public static BillingProfileListResult List(this IBillingProfilesByBillingAccountNameOperations operations, string billingAccountName, string expand = default(string))
+ {
+ return operations.ListAsync(billingAccountName, expand).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists all billing profiles for a user which that user has access to.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// May be used to expand the invoiceSections.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IBillingProfilesByBillingAccountNameOperations operations, string billingAccountName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountName, expand, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingProfilesOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingProfilesOperations.cs
new file mode 100644
index 000000000000..5c719c9629ed
--- /dev/null
+++ b/src/SDKs/Billing/Management.Billing/Generated/BillingProfilesOperations.cs
@@ -0,0 +1,486 @@
+//
+// 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;
+
+ ///
+ /// BillingProfilesOperations operations.
+ ///
+ internal partial class BillingProfilesOperations : IServiceOperations, IBillingProfilesOperations
+ {
+ ///
+ /// Initializes a new instance of the BillingProfilesOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BillingProfilesOperations(BillingManagementClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the BillingManagementClient
+ ///
+ public BillingManagementClient Client { get; private set; }
+
+ ///
+ /// Get the billing profile by id.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// May be used to expand the invoiceSections.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string expand = default(string), 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("expand", expand);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}").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 (expand != null)
+ {
+ _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
+ }
+ 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;
+ }
+
+ ///
+ /// The operation to update a billing profile.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// Parameters supplied to the update billing profile operation.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public async Task> UpdateWithHttpMessagesAsync(string billingAccountName, string billingProfileName, BillingProfile parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ // Send Request
+ AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(billingAccountName, billingProfileName, parameters, customHeaders, cancellationToken).ConfigureAwait(false);
+ return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// The operation to update a billing profile.
+ ///
+ ///
+ /// billing Account Id.
+ ///
+ ///
+ /// Billing Profile Id.
+ ///
+ ///
+ /// Parameters supplied to the update billing profile operation.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> BeginUpdateWithHttpMessagesAsync(string billingAccountName, string billingProfileName, BillingProfile parameters, Dictionary