diff --git a/src/SDKs/Billing/Management.Billing/Generated/AgreementsOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/AgreementsOperations.cs new file mode 100644 index 0000000000000..b7bfd8dccd112 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/AgreementsOperations.cs @@ -0,0 +1,433 @@ +// +// 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; + + /// + /// AgreementsOperations operations. + /// + internal partial class AgreementsOperations : IServiceOperations, IAgreementsOperations + { + /// + /// Initializes a new instance of the AgreementsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AgreementsOperations(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 agreements for a billing account. + /// + /// + /// billing Account Id. + /// + /// + /// May be used to expand the participants. + /// + /// + /// 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> ListByBillingAccountNameWithHttpMessagesAsync(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, "ListByBillingAccountName", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements").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; + } + + /// + /// Get the agreement by name. + /// + /// + /// billing Account Id. + /// + /// + /// Agreement Id. + /// + /// + /// May be used to expand the participants. + /// + /// + /// 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 agreementName, 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 (agreementName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "agreementName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("agreementName", agreementName); + 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}/agreements/{agreementName}").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{agreementName}", System.Uri.EscapeDataString(agreementName)); + 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/AgreementsOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/AgreementsOperationsExtensions.cs new file mode 100644 index 0000000000000..2657b2b3af171 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/AgreementsOperationsExtensions.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 AgreementsOperations. + /// + public static partial class AgreementsOperationsExtensions + { + /// + /// Lists all agreements for a billing account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// May be used to expand the participants. + /// + public static AgreementListResult ListByBillingAccountName(this IAgreementsOperations operations, string billingAccountName, string expand = default(string)) + { + return operations.ListByBillingAccountNameAsync(billingAccountName, expand).GetAwaiter().GetResult(); + } + + /// + /// Lists all agreements for a billing account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// May be used to expand the participants. + /// + /// + /// The cancellation token. + /// + public static async Task ListByBillingAccountNameAsync(this IAgreementsOperations operations, string billingAccountName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByBillingAccountNameWithHttpMessagesAsync(billingAccountName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the agreement by name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// Agreement Id. + /// + /// + /// May be used to expand the participants. + /// + public static Agreement Get(this IAgreementsOperations operations, string billingAccountName, string agreementName, string expand = default(string)) + { + return operations.GetAsync(billingAccountName, agreementName, expand).GetAwaiter().GetResult(); + } + + /// + /// Get the agreement by name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// Agreement Id. + /// + /// + /// May be used to expand the participants. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAgreementsOperations operations, string billingAccountName, string agreementName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(billingAccountName, agreementName, 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 738a043235d02..7f595c622db52 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs @@ -203,6 +203,16 @@ public partial class BillingManagementClient : ServiceClient 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. /// @@ -273,6 +283,11 @@ public partial class BillingManagementClient : ServiceClient public virtual IBillingProfileBillingRoleAssignmentOperations BillingProfileBillingRoleAssignment { get; private set; } + /// + /// Gets the IAgreementsOperations. + /// + public virtual IAgreementsOperations Agreements { get; private set; } + /// /// Initializes a new instance of the BillingManagementClient class. /// @@ -539,6 +554,8 @@ private void Initialize() 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); @@ -553,6 +570,7 @@ private void Initialize() BillingAccountBillingRoleAssignment = new BillingAccountBillingRoleAssignmentOperations(this); InvoiceSectionBillingRoleAssignment = new InvoiceSectionBillingRoleAssignmentOperations(this); BillingProfileBillingRoleAssignment = new BillingProfileBillingRoleAssignmentOperations(this); + Agreements = new AgreementsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); ApiVersion = "2018-11-01-preview"; AcceptLanguage = "en-US"; @@ -588,229 +606,6 @@ private void Initialize() DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); } - /// - /// Lists the transactions by billingProfileName for given start date and end - /// date. - /// - /// - /// - /// billing Account Id. - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to filter by transaction kind. The filter supports 'eq', 'lt', - /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or - /// 'not'. Tag filter is a key value pair string where key and value is - /// separated by a colon (:). - /// - /// - /// 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> TransactionsByBillingProfileWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string startDate, string endDate, string filter = default(string), 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 (ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); - } - if (startDate == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "startDate"); - } - if (endDate == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "endDate"); - } - // 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("startDate", startDate); - tracingParameters.Add("endDate", endDate); - tracingParameters.Add("filter", filter); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "TransactionsByBillingProfile", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/transactions").ToString(); - _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); - _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName)); - List _queryParameters = new List(); - if (ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion))); - } - if (startDate != null) - { - _queryParameters.Add(string.Format("startDate={0}", System.Uri.EscapeDataString(startDate))); - } - if (endDate != null) - { - _queryParameters.Add(string.Format("endDate={0}", System.Uri.EscapeDataString(endDate))); - } - if (filter != null) - { - _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); - } - 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 (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; - // 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 product by product id /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClientExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClientExtensions.cs index be5adee9aad04..a2fd45941a5a2 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClientExtensions.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClientExtensions.cs @@ -21,74 +21,6 @@ namespace Microsoft.Azure.Management.Billing /// public static partial class BillingManagementClientExtensions { - /// - /// Lists the transactions by billingProfileName for given start date and end - /// date. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// billing Account Id. - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to filter by transaction kind. The filter supports 'eq', 'lt', - /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or - /// 'not'. Tag filter is a key value pair string where key and value is - /// separated by a colon (:). - /// - public static TransactionsListResult TransactionsByBillingProfile(this IBillingManagementClient operations, string billingAccountName, string billingProfileName, string startDate, string endDate, string filter = default(string)) - { - return operations.TransactionsByBillingProfileAsync(billingAccountName, billingProfileName, startDate, endDate, filter).GetAwaiter().GetResult(); - } - - /// - /// Lists the transactions by billingProfileName for given start date and end - /// date. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// billing Account Id. - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to filter by transaction kind. The filter supports 'eq', 'lt', - /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or - /// 'not'. Tag filter is a key value pair string where key and value is - /// separated by a colon (:). - /// - /// - /// The cancellation token. - /// - public static async Task TransactionsByBillingProfileAsync(this IBillingManagementClient operations, string billingAccountName, string billingProfileName, string startDate, string endDate, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.TransactionsByBillingProfileWithHttpMessagesAsync(billingAccountName, billingProfileName, startDate, endDate, filter, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - /// /// Cancel product by product id /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/IAgreementsOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IAgreementsOperations.cs new file mode 100644 index 0000000000000..ad1ad24644a8a --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/IAgreementsOperations.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AgreementsOperations operations. + /// + public partial interface IAgreementsOperations + { + /// + /// Lists all agreements for a billing account. + /// + /// + /// billing Account Id. + /// + /// + /// May be used to expand the participants. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListByBillingAccountNameWithHttpMessagesAsync(string billingAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the agreement by name. + /// + /// + /// billing Account Id. + /// + /// + /// Agreement Id. + /// + /// + /// May be used to expand the participants. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string billingAccountName, string agreementName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs index 281322c3bbcdb..3d38f0b2ba5dc 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs @@ -200,6 +200,16 @@ public partial interface IBillingManagementClient : System.IDisposable /// ITransactionsByBillingAccountOperations TransactionsByBillingAccount { get; } + /// + /// Gets the ITransactionsByBillingProfileOperations. + /// + ITransactionsByBillingProfileOperations TransactionsByBillingProfile { get; } + + /// + /// Gets the ITransactionsByInvoiceSectionOperations. + /// + ITransactionsByInvoiceSectionOperations TransactionsByInvoiceSection { get; } + /// /// Gets the IPolicyOperations. /// @@ -271,34 +281,9 @@ public partial interface IBillingManagementClient : System.IDisposable IBillingProfileBillingRoleAssignmentOperations BillingProfileBillingRoleAssignment { get; } /// - /// Lists the transactions by billingProfileName for given start date - /// and end date. + /// Gets the IAgreementsOperations. /// - /// - /// billing Account Id. - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to filter by transaction kind. The filter supports - /// 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently - /// support 'ne', 'or', or 'not'. Tag filter is a key value pair string - /// where key and value is separated by a colon (:). - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task> TransactionsByBillingProfileWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string startDate, string endDate, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + IAgreementsOperations Agreements { get; } /// /// Cancel product by product id diff --git a/src/SDKs/Billing/Management.Billing/Generated/ITransactionsByBillingProfileOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/ITransactionsByBillingProfileOperations.cs new file mode 100644 index 0000000000000..26dca227f9be3 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/ITransactionsByBillingProfileOperations.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TransactionsByBillingProfileOperations operations. + /// + public partial interface ITransactionsByBillingProfileOperations + { + /// + /// Lists the transactions by billingProfileName for given start date + /// and end date. + /// + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile Id. + /// + /// + /// Start date + /// + /// + /// End date + /// + /// + /// May be used to filter by transaction kind. The filter supports + /// 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently + /// support 'ne', 'or', or 'not'. Tag filter is a key value pair string + /// where key and value is separated by a colon (:). + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string startDate, string endDate, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/ITransactionsByInvoiceSectionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/ITransactionsByInvoiceSectionOperations.cs new file mode 100644 index 0000000000000..5738a49854d0a --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/ITransactionsByInvoiceSectionOperations.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TransactionsByInvoiceSectionOperations operations. + /// + public partial interface ITransactionsByInvoiceSectionOperations + { + /// + /// Lists the transactions by invoiceSectionName for given start date + /// and end date. + /// + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection Id. + /// + /// + /// Start date + /// + /// + /// End date + /// + /// + /// May be used to filter by transaction kind. The filter supports + /// 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently + /// support 'ne', 'or', or 'not'. Tag filter is a key value pair string + /// where key and value is separated by a colon (:). + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, string startDate, string endDate, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/Agreement.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/Agreement.cs new file mode 100644 index 0000000000000..f34d3e86093b3 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/Models/Agreement.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An agreement resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class Agreement : Resource + { + /// + /// Initializes a new instance of the Agreement class. + /// + public Agreement() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Agreement class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// The link to the agreement. + /// Effective date. + /// Expiration date. + /// Participants or signer of the + /// agreement. + /// The agreement status + public Agreement(string id = default(string), string name = default(string), string type = default(string), string agreementLink = default(string), System.DateTime? effectiveDate = default(System.DateTime?), System.DateTime? expirationDate = default(System.DateTime?), IList participants = default(IList), string status = default(string)) + : base(id, name, type) + { + AgreementLink = agreementLink; + EffectiveDate = effectiveDate; + ExpirationDate = expirationDate; + Participants = participants; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the link to the agreement. + /// + [JsonProperty(PropertyName = "properties.agreementLink")] + public string AgreementLink { get; private set; } + + /// + /// Gets effective date. + /// + [JsonProperty(PropertyName = "properties.effectiveDate")] + public System.DateTime? EffectiveDate { get; private set; } + + /// + /// Gets expiration date. + /// + [JsonProperty(PropertyName = "properties.expirationDate")] + public System.DateTime? ExpirationDate { get; private set; } + + /// + /// Gets or sets participants or signer of the agreement. + /// + [JsonProperty(PropertyName = "properties.participants")] + public IList Participants { get; set; } + + /// + /// Gets the agreement status + /// + [JsonProperty(PropertyName = "properties.status")] + public string Status { get; private set; } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/AgreementListResult.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/AgreementListResult.cs new file mode 100644 index 0000000000000..a4ed77194a42b --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/Models/AgreementListResult.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of listing agreements. + /// + public partial class AgreementListResult + { + /// + /// Initializes a new instance of the AgreementListResult class. + /// + public AgreementListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AgreementListResult class. + /// + /// The list of agreements. + /// The link (url) to the next page of + /// results. + public AgreementListResult(IList value = default(IList), string nextLink = default(string)) + { + Value = value; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of agreements. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + /// + /// Gets the link (url) to the next page of results. + /// + [JsonProperty(PropertyName = "nextLink")] + public string NextLink { get; private set; } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/Participants.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/Participants.cs new file mode 100644 index 0000000000000..a5461b7cd5c0c --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/Models/Participants.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details about the participant or signer. + /// + public partial class Participants + { + /// + /// Initializes a new instance of the Participants class. + /// + public Participants() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Participants class. + /// + /// The signing status + /// The date when status got changed. + /// The email address of the participant or + /// signer. + public Participants(string status = default(string), System.DateTime? statusDate = default(System.DateTime?), string email = default(string)) + { + Status = status; + StatusDate = statusDate; + Email = email; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the signing status + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + /// + /// Gets the date when status got changed. + /// + [JsonProperty(PropertyName = "statusDate")] + public System.DateTime? StatusDate { get; private set; } + + /// + /// Gets the email address of the participant or signer. + /// + [JsonProperty(PropertyName = "email")] + public string Email { get; private set; } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/ProductDetails.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/ProductDetails.cs index 74aeb22109c2d..2ee4ec23bc1a3 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/Models/ProductDetails.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/Models/ProductDetails.cs @@ -29,7 +29,7 @@ public ProductDetails() /// /// Initializes a new instance of the ProductDetails class. /// - /// Type of the prouct to be transferred. + /// Type of the product to be transferred. /// Possible values include: 'AzureSubscription', /// 'AzureReservation' /// Id of product to be transferred. @@ -46,7 +46,7 @@ public ProductDetails(string productType = default(string), string productId = d partial void CustomInit(); /// - /// Gets or sets type of the prouct to be transferred. Possible values + /// Gets or sets type of the product to be transferred. Possible values /// include: 'AzureSubscription', 'AzureReservation' /// [JsonProperty(PropertyName = "productType")] diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/TransferDetails.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/TransferDetails.cs index a223ba2891c9a..ea1d76fa501e5 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/Models/TransferDetails.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/Models/TransferDetails.cs @@ -36,7 +36,7 @@ public TransferDetails() /// /// Transfer creation time. /// Transfer expiration time. - /// Target invoice setion Id. + /// Target invoice section Id. /// Target billing account Id. /// Overall transfer status. Possible /// values include: 'Pending', 'InProgress', 'Completed', @@ -84,7 +84,7 @@ public TransferDetails(System.DateTime? creationTime = default(System.DateTime?) public System.DateTime? ExpirationTime { get; private set; } /// - /// Gets target invoice setion Id. + /// Gets target invoice section Id. /// [JsonProperty(PropertyName = "properties.invoiceSectionId")] public string InvoiceSectionId { get; private set; } diff --git a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs index 6c9aaae260453..88adc38513fc4 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs @@ -19,6 +19,7 @@ internal static partial class SdkInfo { return new Tuple[] { + new Tuple("Billing", "Agreements", "2018-11-01-preview"), new Tuple("Billing", "AvailableBalanceByBillingProfile", "2018-11-01-preview"), new Tuple("Billing", "BillingAccountBillingPermissions", "2018-11-01-preview"), new Tuple("Billing", "BillingAccountBillingRoleAssignment", "2018-11-01-preview"), @@ -58,6 +59,7 @@ internal static partial class SdkInfo new Tuple("Billing", "RecipientTransfers", "2018-11-01-preview"), new Tuple("Billing", "TransactionsByBillingAccount", "2018-11-01-preview"), new Tuple("Billing", "TransactionsByBillingProfile", "2018-11-01-preview"), + new Tuple("Billing", "TransactionsByInvoiceSection", "2018-11-01-preview"), new Tuple("Billing", "Transfers", "2018-11-01-preview"), new Tuple("Billing", "UpdateAutoRenewForBillingAccount", "2018-11-01-preview"), new Tuple("Billing", "UpdateAutoRenewForInvoiceSection", "2018-11-01-preview"), diff --git a/src/SDKs/Billing/Management.Billing/Generated/TransactionsByBillingProfileOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/TransactionsByBillingProfileOperations.cs new file mode 100644 index 0000000000000..c7d1da5c9b5c1 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/TransactionsByBillingProfileOperations.cs @@ -0,0 +1,277 @@ +// +// 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; + + /// + /// TransactionsByBillingProfileOperations operations. + /// + internal partial class TransactionsByBillingProfileOperations : IServiceOperations, ITransactionsByBillingProfileOperations + { + /// + /// Initializes a new instance of the TransactionsByBillingProfileOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TransactionsByBillingProfileOperations(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 the transactions by billingProfileName for given start date and end + /// date. + /// + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile Id. + /// + /// + /// Start date + /// + /// + /// End date + /// + /// + /// May be used to filter by transaction kind. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. Tag filter is a key value pair string where key and value is + /// separated by a colon (:). + /// + /// + /// 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, string startDate, string endDate, string filter = default(string), 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"); + } + if (startDate == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "startDate"); + } + if (endDate == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endDate"); + } + // 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("startDate", startDate); + tracingParameters.Add("endDate", endDate); + tracingParameters.Add("filter", filter); + 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}/transactions").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 (startDate != null) + { + _queryParameters.Add(string.Format("startDate={0}", System.Uri.EscapeDataString(startDate))); + } + if (endDate != null) + { + _queryParameters.Add(string.Format("endDate={0}", System.Uri.EscapeDataString(endDate))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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/TransactionsByBillingProfileOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/TransactionsByBillingProfileOperationsExtensions.cs new file mode 100644 index 0000000000000..0160e8eab416a --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/TransactionsByBillingProfileOperationsExtensions.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TransactionsByBillingProfileOperations. + /// + public static partial class TransactionsByBillingProfileOperationsExtensions + { + /// + /// Lists the transactions by billingProfileName for given start date and end + /// date. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile Id. + /// + /// + /// Start date + /// + /// + /// End date + /// + /// + /// May be used to filter by transaction kind. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. Tag filter is a key value pair string where key and value is + /// separated by a colon (:). + /// + public static TransactionsListResult List(this ITransactionsByBillingProfileOperations operations, string billingAccountName, string billingProfileName, string startDate, string endDate, string filter = default(string)) + { + return operations.ListAsync(billingAccountName, billingProfileName, startDate, endDate, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists the transactions by billingProfileName for given start date and end + /// date. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// Billing Profile Id. + /// + /// + /// Start date + /// + /// + /// End date + /// + /// + /// May be used to filter by transaction kind. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. Tag filter is a key value pair string where key and value is + /// separated by a colon (:). + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this ITransactionsByBillingProfileOperations operations, string billingAccountName, string billingProfileName, string startDate, string endDate, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountName, billingProfileName, startDate, endDate, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/TransactionsByInvoiceSectionOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/TransactionsByInvoiceSectionOperations.cs new file mode 100644 index 0000000000000..64e10eb0b8c55 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/TransactionsByInvoiceSectionOperations.cs @@ -0,0 +1,277 @@ +// +// 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; + + /// + /// TransactionsByInvoiceSectionOperations operations. + /// + internal partial class TransactionsByInvoiceSectionOperations : IServiceOperations, ITransactionsByInvoiceSectionOperations + { + /// + /// Initializes a new instance of the TransactionsByInvoiceSectionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TransactionsByInvoiceSectionOperations(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 the transactions by invoiceSectionName for given start date and end + /// date. + /// + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection Id. + /// + /// + /// Start date + /// + /// + /// End date + /// + /// + /// May be used to filter by transaction kind. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. Tag filter is a key value pair string where key and value is + /// separated by a colon (:). + /// + /// + /// 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 invoiceSectionName, string startDate, string endDate, string filter = default(string), 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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (startDate == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "startDate"); + } + if (endDate == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endDate"); + } + // 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("startDate", startDate); + tracingParameters.Add("endDate", endDate); + tracingParameters.Add("filter", filter); + 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}/invoiceSections/{invoiceSectionName}/transactions").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{invoiceSectionName}", System.Uri.EscapeDataString(invoiceSectionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (startDate != null) + { + _queryParameters.Add(string.Format("startDate={0}", System.Uri.EscapeDataString(startDate))); + } + if (endDate != null) + { + _queryParameters.Add(string.Format("endDate={0}", System.Uri.EscapeDataString(endDate))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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/TransactionsByInvoiceSectionOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/TransactionsByInvoiceSectionOperationsExtensions.cs new file mode 100644 index 0000000000000..4e4ff770a277f --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/TransactionsByInvoiceSectionOperationsExtensions.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TransactionsByInvoiceSectionOperations. + /// + public static partial class TransactionsByInvoiceSectionOperationsExtensions + { + /// + /// Lists the transactions by invoiceSectionName for given start date and end + /// date. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection Id. + /// + /// + /// Start date + /// + /// + /// End date + /// + /// + /// May be used to filter by transaction kind. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. Tag filter is a key value pair string where key and value is + /// separated by a colon (:). + /// + public static TransactionsListResult List(this ITransactionsByInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName, string startDate, string endDate, string filter = default(string)) + { + return operations.ListAsync(billingAccountName, invoiceSectionName, startDate, endDate, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists the transactions by invoiceSectionName for given start date and end + /// date. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// InvoiceSection Id. + /// + /// + /// Start date + /// + /// + /// End date + /// + /// + /// May be used to filter by transaction kind. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. Tag filter is a key value pair string where key and value is + /// separated by a colon (:). + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this ITransactionsByInvoiceSectionOperations operations, string billingAccountName, string invoiceSectionName, string startDate, string endDate, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountName, invoiceSectionName, startDate, endDate, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}