diff --git a/src/SDKs/Consumption/AzSdk.RP.props b/src/SDKs/Consumption/AzSdk.RP.props index d134a7402ab4..871933d6804d 100644 --- a/src/SDKs/Consumption/AzSdk.RP.props +++ b/src/SDKs/Consumption/AzSdk.RP.props @@ -1,7 +1,7 @@ - Billing_2018-11-01-preview;Consumption_2018-11-01-preview; + Billing_2019-04-01-preview;Capacity_2019-04-01-preview;Consumption_2019-04-01-preview;Management_2019-04-01-preview; $(PackageTags);$(CommonTags);$(AzureApiTag); \ No newline at end of file diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/AggregatedCostOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/AggregatedCostOperations.cs new file mode 100644 index 000000000000..06f46593332a --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/AggregatedCostOperations.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.Consumption +{ + 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; + + /// + /// AggregatedCostOperations operations. + /// + internal partial class AggregatedCostOperations : IServiceOperations, IAggregatedCostOperations + { + /// + /// Initializes a new instance of the AggregatedCostOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AggregatedCostOperations(ConsumptionManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ConsumptionManagementClient + /// + public ConsumptionManagementClient Client { get; private set; } + + /// + /// Provides the aggregate cost of a management group and all child management + /// groups by current billing period. + /// + /// + /// + /// Azure Management Group ID. + /// + /// + /// May be used to filter aggregated cost by properties/usageStart (Utc time), + /// properties/usageEnd (Utc time). 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> GetByManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + 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("managementGroupId", managementGroupId); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetByManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost").ToString(); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + 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; + } + + /// + /// Provides the aggregate cost of a management group and all child management + /// groups by specified billing period + /// + /// + /// + /// Azure Management Group ID. + /// + /// + /// Billing Period Name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetForBillingPeriodByManagementGroupWithHttpMessagesAsync(string managementGroupId, string billingPeriodName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + if (billingPeriodName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingPeriodName"); + } + 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("managementGroupId", managementGroupId); + tracingParameters.Add("billingPeriodName", billingPeriodName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetForBillingPeriodByManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/Microsoft.Consumption/aggregatedcost").ToString(); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + _url = _url.Replace("{billingPeriodName}", System.Uri.EscapeDataString(billingPeriodName)); + 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/Consumption/Management.Consumption/Generated/AggregatedCostOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/AggregatedCostOperationsExtensions.cs new file mode 100644 index 000000000000..d3dc3db417f7 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/AggregatedCostOperationsExtensions.cs @@ -0,0 +1,121 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AggregatedCostOperations. + /// + public static partial class AggregatedCostOperationsExtensions + { + /// + /// Provides the aggregate cost of a management group and all child management + /// groups by current billing period. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure Management Group ID. + /// + /// + /// May be used to filter aggregated cost by properties/usageStart (Utc time), + /// properties/usageEnd (Utc time). 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 ManagementGroupAggregatedCostResult GetByManagementGroup(this IAggregatedCostOperations operations, string managementGroupId, string filter = default(string)) + { + return operations.GetByManagementGroupAsync(managementGroupId, filter).GetAwaiter().GetResult(); + } + + /// + /// Provides the aggregate cost of a management group and all child management + /// groups by current billing period. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure Management Group ID. + /// + /// + /// May be used to filter aggregated cost by properties/usageStart (Utc time), + /// properties/usageEnd (Utc time). 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 GetByManagementGroupAsync(this IAggregatedCostOperations operations, string managementGroupId, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetByManagementGroupWithHttpMessagesAsync(managementGroupId, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Provides the aggregate cost of a management group and all child management + /// groups by specified billing period + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure Management Group ID. + /// + /// + /// Billing Period Name. + /// + public static ManagementGroupAggregatedCostResult GetForBillingPeriodByManagementGroup(this IAggregatedCostOperations operations, string managementGroupId, string billingPeriodName) + { + return operations.GetForBillingPeriodByManagementGroupAsync(managementGroupId, billingPeriodName).GetAwaiter().GetResult(); + } + + /// + /// Provides the aggregate cost of a management group and all child management + /// groups by specified billing period + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure Management Group ID. + /// + /// + /// Billing Period Name. + /// + /// + /// The cancellation token. + /// + public static async Task GetForBillingPeriodByManagementGroupAsync(this IAggregatedCostOperations operations, string managementGroupId, string billingPeriodName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetForBillingPeriodByManagementGroupWithHttpMessagesAsync(managementGroupId, billingPeriodName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingProfileOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/BalancesOperations.cs similarity index 50% rename from src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingProfileOperations.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/BalancesOperations.cs index cca6ddd6ea9c..82d6e57578be 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingProfileOperations.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/BalancesOperations.cs @@ -23,12 +23,12 @@ namespace Microsoft.Azure.Management.Consumption using System.Threading.Tasks; /// - /// ChargesByBillingProfileOperations operations. + /// BalancesOperations operations. /// - internal partial class ChargesByBillingProfileOperations : IServiceOperations, IChargesByBillingProfileOperations + internal partial class BalancesOperations : IServiceOperations, IBalancesOperations { /// - /// Initializes a new instance of the ChargesByBillingProfileOperations class. + /// Initializes a new instance of the BalancesOperations class. /// /// /// Reference to the service client. @@ -36,7 +36,7 @@ internal partial class ChargesByBillingProfileOperations : IServiceOperations /// Thrown when a required parameter is null /// - internal ChargesByBillingProfileOperations(ConsumptionManagementClient client) + internal BalancesOperations(ConsumptionManagementClient client) { if (client == null) { @@ -51,24 +51,13 @@ internal ChargesByBillingProfileOperations(ConsumptionManagementClient client) public ConsumptionManagementClient Client { get; private set; } /// - /// Lists the charges by billing profile id for given start and end date. Start - /// and end date are used to determine the billing period. For current month, - /// the data will be provided from month to date. If there are no chages for a - /// month then that month will show all zeroes. + /// Gets the balances for a scope by billingAccountId. Balances are available + /// via this API only for May 1, 2014 or later. /// /// /// /// BillingAccount ID /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// /// /// Headers that will be added to request. /// @@ -90,27 +79,201 @@ internal ChargesByBillingProfileOperations(ConsumptionManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ListWithHttpMessagesAsync(string billingAccountId, string billingProfileId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetByBillingAccountWithHttpMessagesAsync(string billingAccountId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } if (billingAccountId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); } - if (billingProfileId == null) + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountId", billingAccountId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetByBillingAccount", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances").ToString(); + _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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) { - throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileId"); + ServiceClientTracing.Exit(_invocationId, _result); } + return _result; + } + + /// + /// Gets the balances for a scope by billing period and billingAccountId. + /// Balances are available via this API only for May 1, 2014 or later. + /// + /// + /// + /// BillingAccount ID + /// + /// + /// Billing Period Name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetForBillingPeriodByBillingAccountWithHttpMessagesAsync(string billingAccountId, string billingPeriodName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (startDate == null) + if (billingAccountId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "startDate"); + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); } - if (endDate == null) + if (billingPeriodName == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "endDate"); + throw new ValidationException(ValidationRules.CannotBeNull, "billingPeriodName"); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; @@ -120,30 +283,20 @@ internal ChargesByBillingProfileOperations(ConsumptionManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("billingAccountId", billingAccountId); - tracingParameters.Add("billingProfileId", billingProfileId); - tracingParameters.Add("startDate", startDate); - tracingParameters.Add("endDate", endDate); + tracingParameters.Add("billingPeriodName", billingPeriodName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetForBillingPeriodByBillingAccount", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/charges").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances").ToString(); _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); - _url = _url.Replace("{billingProfileId}", System.Uri.EscapeDataString(billingProfileId)); + _url = _url.Replace("{billingPeriodName}", System.Uri.EscapeDataString(billingPeriodName)); 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 (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); @@ -232,7 +385,7 @@ internal ChargesByBillingProfileOperations(ConsumptionManagementClient 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")) @@ -245,7 +398,7 @@ internal ChargesByBillingProfileOperations(ConsumptionManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/BalancesOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/BalancesOperationsExtensions.cs new file mode 100644 index 000000000000..1f21932cf3ae --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/BalancesOperationsExtensions.cs @@ -0,0 +1,107 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for BalancesOperations. + /// + public static partial class BalancesOperationsExtensions + { + /// + /// Gets the balances for a scope by billingAccountId. Balances are available + /// via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// BillingAccount ID + /// + public static Balance GetByBillingAccount(this IBalancesOperations operations, string billingAccountId) + { + return operations.GetByBillingAccountAsync(billingAccountId).GetAwaiter().GetResult(); + } + + /// + /// Gets the balances for a scope by billingAccountId. Balances are available + /// via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// BillingAccount ID + /// + /// + /// The cancellation token. + /// + public static async Task GetByBillingAccountAsync(this IBalancesOperations operations, string billingAccountId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetByBillingAccountWithHttpMessagesAsync(billingAccountId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the balances for a scope by billing period and billingAccountId. + /// Balances are available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// BillingAccount ID + /// + /// + /// Billing Period Name. + /// + public static Balance GetForBillingPeriodByBillingAccount(this IBalancesOperations operations, string billingAccountId, string billingPeriodName) + { + return operations.GetForBillingPeriodByBillingAccountAsync(billingAccountId, billingPeriodName).GetAwaiter().GetResult(); + } + + /// + /// Gets the balances for a scope by billing period and billingAccountId. + /// Balances are available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// BillingAccount ID + /// + /// + /// Billing Period Name. + /// + /// + /// The cancellation token. + /// + public static async Task GetForBillingPeriodByBillingAccountAsync(this IBalancesOperations operations, string billingAccountId, string billingPeriodName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetForBillingPeriodByBillingAccountWithHttpMessagesAsync(billingAccountId, billingPeriodName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/BillingProfilePricesheetOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/BillingProfilePricesheetOperations.cs deleted file mode 100644 index e635f89f2539..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/BillingProfilePricesheetOperations.cs +++ /dev/null @@ -1,275 +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.Consumption -{ - 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; - - /// - /// BillingProfilePricesheetOperations operations. - /// - internal partial class BillingProfilePricesheetOperations : IServiceOperations, IBillingProfilePricesheetOperations - { - /// - /// Initializes a new instance of the BillingProfilePricesheetOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal BillingProfilePricesheetOperations(ConsumptionManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the ConsumptionManagementClient - /// - public ConsumptionManagementClient Client { get; private set; } - - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// Azure Billing Account Id. - /// - /// - /// Azure Billing Profile Id. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> DownloadWithHttpMessagesAsync(string billingAccountId, string billingProfileId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDownloadWithHttpMessagesAsync(billingAccountId, billingProfileId, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// Azure Billing Account Id. - /// - /// - /// Azure 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> BeginDownloadWithHttpMessagesAsync(string billingAccountId, string billingProfileId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (billingAccountId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); - } - if (billingProfileId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("billingAccountId", billingAccountId); - tracingParameters.Add("billingProfileId", billingProfileId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDownload", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Consumption/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/pricesheet/default/download").ToString(); - _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); - _url = _url.Replace("{billingProfileId}", System.Uri.EscapeDataString(billingProfileId)); - 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; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - try - { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/BillingProfilePricesheetOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/BillingProfilePricesheetOperationsExtensions.cs deleted file mode 100644 index 91a279a79944..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/BillingProfilePricesheetOperationsExtensions.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for BillingProfilePricesheetOperations. - /// - public static partial class BillingProfilePricesheetOperationsExtensions - { - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// The operations group for this extension method. - /// - /// - /// Azure Billing Account Id. - /// - /// - /// Azure Billing Profile Id. - /// - public static PricesheetDownloadResponse Download(this IBillingProfilePricesheetOperations operations, string billingAccountId, string billingProfileId) - { - return operations.DownloadAsync(billingAccountId, billingProfileId).GetAwaiter().GetResult(); - } - - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// The operations group for this extension method. - /// - /// - /// Azure Billing Account Id. - /// - /// - /// Azure Billing Profile Id. - /// - /// - /// The cancellation token. - /// - public static async Task DownloadAsync(this IBillingProfilePricesheetOperations operations, string billingAccountId, string billingProfileId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.DownloadWithHttpMessagesAsync(billingAccountId, billingProfileId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// The operations group for this extension method. - /// - /// - /// Azure Billing Account Id. - /// - /// - /// Azure Billing Profile Id. - /// - public static PricesheetDownloadResponse BeginDownload(this IBillingProfilePricesheetOperations operations, string billingAccountId, string billingProfileId) - { - return operations.BeginDownloadAsync(billingAccountId, billingProfileId).GetAwaiter().GetResult(); - } - - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// The operations group for this extension method. - /// - /// - /// Azure Billing Account Id. - /// - /// - /// Azure Billing Profile Id. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDownloadAsync(this IBillingProfilePricesheetOperations operations, string billingAccountId, string billingProfileId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginDownloadWithHttpMessagesAsync(billingAccountId, billingProfileId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/BudgetsOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/BudgetsOperations.cs new file mode 100644 index 000000000000..24145668de18 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/BudgetsOperations.cs @@ -0,0 +1,1039 @@ +// +// 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.Consumption +{ + 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; + + /// + /// BudgetsOperations operations. + /// + internal partial class BudgetsOperations : IServiceOperations, IBudgetsOperations + { + /// + /// Initializes a new instance of the BudgetsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal BudgetsOperations(ConsumptionManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ConsumptionManagementClient + /// + public ConsumptionManagementClient Client { get; private set; } + + /// + /// Lists all budgets for the defined scope. + /// + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// 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 scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + 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("scope", scope); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/budgets").ToString(); + _url = _url.Replace("{scope}", scope); + 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; + } + + /// + /// Gets the budget for the scope by budget name. + /// + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string scope, string budgetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (budgetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "budgetName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("budgetName", budgetName); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/budgets/{budgetName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{budgetName}", System.Uri.EscapeDataString(budgetName)); + 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 create or update a budget. Update operation requires + /// latest eTag to be set in the request mandatorily. You may obtain the latest + /// eTag by performing a get operation. Create operation does not require eTag. + /// + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// Parameters supplied to the Create Budget 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> CreateOrUpdateWithHttpMessagesAsync(string scope, string budgetName, Budget parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (budgetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "budgetName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("budgetName", budgetName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/budgets/{budgetName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{budgetName}", System.Uri.EscapeDataString(budgetName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to delete a budget. + /// + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string scope, string budgetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (budgetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "budgetName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("budgetName", budgetName); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/budgets/{budgetName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{budgetName}", System.Uri.EscapeDataString(budgetName)); + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all budgets for the defined scope. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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/Consumption/Management.Consumption/Generated/BudgetsOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/BudgetsOperationsExtensions.cs new file mode 100644 index 000000000000..af57b5143cf4 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/BudgetsOperationsExtensions.cs @@ -0,0 +1,350 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for BudgetsOperations. + /// + public static partial class BudgetsOperationsExtensions + { + /// + /// Lists all budgets for the defined scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + public static IPage List(this IBudgetsOperations operations, string scope) + { + return operations.ListAsync(scope).GetAwaiter().GetResult(); + } + + /// + /// Lists all budgets for the defined scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IBudgetsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the budget for the scope by budget name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + public static Budget Get(this IBudgetsOperations operations, string scope, string budgetName) + { + return operations.GetAsync(scope, budgetName).GetAwaiter().GetResult(); + } + + /// + /// Gets the budget for the scope by budget name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IBudgetsOperations operations, string scope, string budgetName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scope, budgetName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to create or update a budget. Update operation requires + /// latest eTag to be set in the request mandatorily. You may obtain the latest + /// eTag by performing a get operation. Create operation does not require eTag. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// Parameters supplied to the Create Budget operation. + /// + public static Budget CreateOrUpdate(this IBudgetsOperations operations, string scope, string budgetName, Budget parameters) + { + return operations.CreateOrUpdateAsync(scope, budgetName, parameters).GetAwaiter().GetResult(); + } + + /// + /// The operation to create or update a budget. Update operation requires + /// latest eTag to be set in the request mandatorily. You may obtain the latest + /// eTag by performing a get operation. Create operation does not require eTag. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// Parameters supplied to the Create Budget operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IBudgetsOperations operations, string scope, string budgetName, Budget parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(scope, budgetName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to delete a budget. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + public static void Delete(this IBudgetsOperations operations, string scope, string budgetName) + { + operations.DeleteAsync(scope, budgetName).GetAwaiter().GetResult(); + } + + /// + /// The operation to delete a budget. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IBudgetsOperations operations, string scope, string budgetName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(scope, budgetName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all budgets for the defined scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IBudgetsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all budgets for the defined scope. + /// + /// + /// + /// 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 IBudgetsOperations 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/Consumption/Management.Consumption/Generated/ChargesByBillingAccountOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingAccountOperations.cs deleted file mode 100644 index b1815d12c0a1..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingAccountOperations.cs +++ /dev/null @@ -1,268 +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.Consumption -{ - 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; - - /// - /// ChargesByBillingAccountOperations operations. - /// - internal partial class ChargesByBillingAccountOperations : IServiceOperations, IChargesByBillingAccountOperations - { - /// - /// Initializes a new instance of the ChargesByBillingAccountOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal ChargesByBillingAccountOperations(ConsumptionManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the ConsumptionManagementClient - /// - public ConsumptionManagementClient Client { get; private set; } - - /// - /// Lists the charges by billingAccountId for given start and end date. Start - /// and end date are used to determine the billing period. For current month, - /// the data will be provided from month to date. If there are no chages for a - /// month then that month will show all zeroes. - /// - /// - /// - /// BillingAccount ID - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to group charges by properties/billingProfileId, or - /// properties/invoiceSectionId. - /// - /// - /// 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 billingAccountId, string startDate, string endDate, string apply = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (billingAccountId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - 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("billingAccountId", billingAccountId); - tracingParameters.Add("startDate", startDate); - tracingParameters.Add("endDate", endDate); - tracingParameters.Add("apply", apply); - 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/{billingAccountId}/providers/Microsoft.Consumption/charges").ToString(); - _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (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 (apply != null) - { - _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply))); - } - 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/Consumption/Management.Consumption/Generated/ChargesByBillingAccountOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingAccountOperationsExtensions.cs deleted file mode 100644 index 865d0a82b179..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingAccountOperationsExtensions.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ChargesByBillingAccountOperations. - /// - public static partial class ChargesByBillingAccountOperationsExtensions - { - /// - /// Lists the charges by billingAccountId for given start and end date. Start - /// and end date are used to determine the billing period. For current month, - /// the data will be provided from month to date. If there are no chages for a - /// month then that month will show all zeroes. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to group charges by properties/billingProfileId, or - /// properties/invoiceSectionId. - /// - public static ChargesListByBillingAccount List(this IChargesByBillingAccountOperations operations, string billingAccountId, string startDate, string endDate, string apply = default(string)) - { - return operations.ListAsync(billingAccountId, startDate, endDate, apply).GetAwaiter().GetResult(); - } - - /// - /// Lists the charges by billingAccountId for given start and end date. Start - /// and end date are used to determine the billing period. For current month, - /// the data will be provided from month to date. If there are no chages for a - /// month then that month will show all zeroes. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to group charges by properties/billingProfileId, or - /// properties/invoiceSectionId. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IChargesByBillingAccountOperations operations, string billingAccountId, string startDate, string endDate, string apply = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountId, startDate, endDate, apply, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingProfileOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingProfileOperationsExtensions.cs deleted file mode 100644 index 770d5ff2b493..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByBillingProfileOperationsExtensions.cs +++ /dev/null @@ -1,85 +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.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ChargesByBillingProfileOperations. - /// - public static partial class ChargesByBillingProfileOperationsExtensions - { - /// - /// Lists the charges by billing profile id for given start and end date. Start - /// and end date are used to determine the billing period. For current month, - /// the data will be provided from month to date. If there are no chages for a - /// month then that month will show all zeroes. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - public static ChargesListByBillingProfile List(this IChargesByBillingProfileOperations operations, string billingAccountId, string billingProfileId, string startDate, string endDate) - { - return operations.ListAsync(billingAccountId, billingProfileId, startDate, endDate).GetAwaiter().GetResult(); - } - - /// - /// Lists the charges by billing profile id for given start and end date. Start - /// and end date are used to determine the billing period. For current month, - /// the data will be provided from month to date. If there are no chages for a - /// month then that month will show all zeroes. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IChargesByBillingProfileOperations operations, string billingAccountId, string billingProfileId, string startDate, string endDate, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountId, billingProfileId, startDate, endDate, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByInvoiceSectionOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByInvoiceSectionOperations.cs deleted file mode 100644 index 6d0337c8a4eb..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByInvoiceSectionOperations.cs +++ /dev/null @@ -1,276 +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.Consumption -{ - 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; - - /// - /// ChargesByInvoiceSectionOperations operations. - /// - internal partial class ChargesByInvoiceSectionOperations : IServiceOperations, IChargesByInvoiceSectionOperations - { - /// - /// Initializes a new instance of the ChargesByInvoiceSectionOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal ChargesByInvoiceSectionOperations(ConsumptionManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the ConsumptionManagementClient - /// - public ConsumptionManagementClient Client { get; private set; } - - /// - /// Lists the charges by invoice section id for given start and end date. Start - /// and end date are used to determine the billing period. For current month, - /// the data will be provided from month to date. If there are no chages for a - /// month then that month will show all zeroes. - /// - /// - /// - /// BillingAccount ID - /// - /// - /// Invoice Section Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to group charges by properties/productName. - /// - /// - /// 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 billingAccountId, string invoiceSectionId, string startDate, string endDate, string apply = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (billingAccountId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); - } - if (invoiceSectionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "invoiceSectionId"); - } - 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("billingAccountId", billingAccountId); - tracingParameters.Add("invoiceSectionId", invoiceSectionId); - tracingParameters.Add("startDate", startDate); - tracingParameters.Add("endDate", endDate); - tracingParameters.Add("apply", apply); - 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/{billingAccountId}/invoiceSections/{invoiceSectionId}/providers/Microsoft.Consumption/charges").ToString(); - _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); - _url = _url.Replace("{invoiceSectionId}", System.Uri.EscapeDataString(invoiceSectionId)); - 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 (apply != null) - { - _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply))); - } - 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/Consumption/Management.Consumption/Generated/ChargesByInvoiceSectionOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByInvoiceSectionOperationsExtensions.cs deleted file mode 100644 index a83886630464..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesByInvoiceSectionOperationsExtensions.cs +++ /dev/null @@ -1,91 +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.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ChargesByInvoiceSectionOperations. - /// - public static partial class ChargesByInvoiceSectionOperationsExtensions - { - /// - /// Lists the charges by invoice section id for given start and end date. Start - /// and end date are used to determine the billing period. For current month, - /// the data will be provided from month to date. If there are no chages for a - /// month then that month will show all zeroes. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Invoice Section Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to group charges by properties/productName. - /// - public static ChargesListByInvoiceSection List(this IChargesByInvoiceSectionOperations operations, string billingAccountId, string invoiceSectionId, string startDate, string endDate, string apply = default(string)) - { - return operations.ListAsync(billingAccountId, invoiceSectionId, startDate, endDate, apply).GetAwaiter().GetResult(); - } - - /// - /// Lists the charges by invoice section id for given start and end date. Start - /// and end date are used to determine the billing period. For current month, - /// the data will be provided from month to date. If there are no chages for a - /// month then that month will show all zeroes. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Invoice Section Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to group charges by properties/productName. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IChargesByInvoiceSectionOperations operations, string billingAccountId, string invoiceSectionId, string startDate, string endDate, string apply = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountId, invoiceSectionId, startDate, endDate, apply, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/EventsByBillingProfileOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ChargesOperations.cs similarity index 75% rename from src/SDKs/Consumption/Management.Consumption/Generated/EventsByBillingProfileOperations.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/ChargesOperations.cs index 98aa303a40a8..6f1cd72d0302 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/EventsByBillingProfileOperations.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ChargesOperations.cs @@ -23,12 +23,12 @@ namespace Microsoft.Azure.Management.Consumption using System.Threading.Tasks; /// - /// EventsByBillingProfileOperations operations. + /// ChargesOperations operations. /// - internal partial class EventsByBillingProfileOperations : IServiceOperations, IEventsByBillingProfileOperations + internal partial class ChargesOperations : IServiceOperations, IChargesOperations { /// - /// Initializes a new instance of the EventsByBillingProfileOperations class. + /// Initializes a new instance of the ChargesOperations class. /// /// /// Reference to the service client. @@ -36,7 +36,7 @@ internal partial class EventsByBillingProfileOperations : IServiceOperations /// Thrown when a required parameter is null /// - internal EventsByBillingProfileOperations(ConsumptionManagementClient client) + internal ChargesOperations(ConsumptionManagementClient client) { if (client == null) { @@ -51,21 +51,26 @@ internal EventsByBillingProfileOperations(ConsumptionManagementClient client) public ConsumptionManagementClient Client { get; private set; } /// - /// Lists the events by billingAccountId and billingProfileId for given start - /// and end date. + /// Lists the charges based for the defined scope. /// /// - /// - /// BillingAccount ID + /// + /// The scope associated with usage details operations. This includes + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope. For department and enrollment accounts, you + /// can also add billing period to the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date + /// + /// May be used to filter charges by properties/usageEnd (Utc time), + /// properties/usageStart (Utc time). 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. @@ -88,28 +93,16 @@ internal EventsByBillingProfileOperations(ConsumptionManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ListWithHttpMessagesAsync(string billingAccountId, string billingProfileId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ListByScopeWithHttpMessagesAsync(string scope, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (billingAccountId == null) + if (scope == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); - } - if (billingProfileId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileId"); + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } 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; @@ -117,30 +110,23 @@ internal EventsByBillingProfileOperations(ConsumptionManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("billingAccountId", billingAccountId); - tracingParameters.Add("billingProfileId", billingProfileId); - tracingParameters.Add("startDate", startDate); - tracingParameters.Add("endDate", endDate); + tracingParameters.Add("scope", scope); + tracingParameters.Add("filter", filter); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListByScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events").ToString(); - _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); - _url = _url.Replace("{billingProfileId}", System.Uri.EscapeDataString(billingProfileId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/charges").ToString(); + _url = _url.Replace("{scope}", scope); 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) + if (filter != null) { - _queryParameters.Add(string.Format("endDate={0}", System.Uri.EscapeDataString(endDate))); + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); } if (_queryParameters.Count > 0) { @@ -230,7 +216,7 @@ internal EventsByBillingProfileOperations(ConsumptionManagementClient 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")) @@ -243,7 +229,7 @@ internal EventsByBillingProfileOperations(ConsumptionManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/ChargesOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ChargesOperationsExtensions.cs new file mode 100644 index 000000000000..9183e30378ad --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ChargesOperationsExtensions.cs @@ -0,0 +1,91 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ChargesOperations. + /// + public static partial class ChargesOperationsExtensions + { + /// + /// Lists the charges based for the defined scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope. For department and enrollment accounts, you + /// can also add billing period to the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// May be used to filter charges by properties/usageEnd (Utc time), + /// properties/usageStart (Utc time). 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 ChargeSummary ListByScope(this IChargesOperations operations, string scope, string filter = default(string)) + { + return operations.ListByScopeAsync(scope, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists the charges based for the defined scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope. For department and enrollment accounts, you + /// can also add billing period to the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// May be used to filter charges by properties/usageEnd (Utc time), + /// properties/usageStart (Utc time). 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 ListByScopeAsync(this IChargesOperations operations, string scope, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByScopeWithHttpMessagesAsync(scope, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/ConsumptionManagementClient.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ConsumptionManagementClient.cs index 687e86cd013e..5f4ccf5c72a2 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/ConsumptionManagementClient.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ConsumptionManagementClient.cs @@ -49,10 +49,15 @@ public partial class ConsumptionManagementClient : ServiceClient /// Version of the API to be used with the client request. The current version - /// is 2018-11-01-preview. + /// is 2019-04-01-preview. /// public string ApiVersion { get; private set; } + /// + /// Azure Subscription ID. + /// + public string SubscriptionId { get; set; } + /// /// The preferred language for the response. /// @@ -72,49 +77,69 @@ public partial class ConsumptionManagementClient : ServiceClient - /// Gets the IOperations. + /// Gets the IUsageDetailsOperations. /// - public virtual IOperations Operations { get; private set; } + public virtual IUsageDetailsOperations UsageDetails { get; private set; } /// - /// Gets the ICreditSummaryByBillingProfileOperations. + /// Gets the IMarketplacesOperations. /// - public virtual ICreditSummaryByBillingProfileOperations CreditSummaryByBillingProfile { get; private set; } + public virtual IMarketplacesOperations Marketplaces { get; private set; } /// - /// Gets the IEventsByBillingProfileOperations. + /// Gets the IBudgetsOperations. /// - public virtual IEventsByBillingProfileOperations EventsByBillingProfile { get; private set; } + public virtual IBudgetsOperations Budgets { get; private set; } /// - /// Gets the ILotsByBillingProfileOperations. + /// Gets the ITagsOperations. /// - public virtual ILotsByBillingProfileOperations LotsByBillingProfile { get; private set; } + public virtual ITagsOperations Tags { get; private set; } /// - /// Gets the IInvoicePricesheetOperations. + /// Gets the IChargesOperations. /// - public virtual IInvoicePricesheetOperations InvoicePricesheet { get; private set; } + public virtual IChargesOperations Charges { get; private set; } /// - /// Gets the IBillingProfilePricesheetOperations. + /// Gets the IBalancesOperations. /// - public virtual IBillingProfilePricesheetOperations BillingProfilePricesheet { get; private set; } + public virtual IBalancesOperations Balances { get; private set; } /// - /// Gets the IChargesByBillingAccountOperations. + /// Gets the IReservationsSummariesOperations. /// - public virtual IChargesByBillingAccountOperations ChargesByBillingAccount { get; private set; } + public virtual IReservationsSummariesOperations ReservationsSummaries { get; private set; } /// - /// Gets the IChargesByBillingProfileOperations. + /// Gets the IReservationsDetailsOperations. /// - public virtual IChargesByBillingProfileOperations ChargesByBillingProfile { get; private set; } + public virtual IReservationsDetailsOperations ReservationsDetails { get; private set; } + + /// + /// Gets the IReservationRecommendationsOperations. + /// + public virtual IReservationRecommendationsOperations ReservationRecommendations { get; private set; } + + /// + /// Gets the IPriceSheetOperations. + /// + public virtual IPriceSheetOperations PriceSheet { get; private set; } + + /// + /// Gets the IForecastsOperations. + /// + public virtual IForecastsOperations Forecasts { get; private set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } /// - /// Gets the IChargesByInvoiceSectionOperations. + /// Gets the IAggregatedCostOperations. /// - public virtual IChargesByInvoiceSectionOperations ChargesByInvoiceSection { get; private set; } + public virtual IAggregatedCostOperations AggregatedCost { get; private set; } /// /// Initializes a new instance of the ConsumptionManagementClient class. @@ -357,17 +382,21 @@ public ConsumptionManagementClient(System.Uri baseUri, ServiceClientCredentials /// private void Initialize() { + UsageDetails = new UsageDetailsOperations(this); + Marketplaces = new MarketplacesOperations(this); + Budgets = new BudgetsOperations(this); + Tags = new TagsOperations(this); + Charges = new ChargesOperations(this); + Balances = new BalancesOperations(this); + ReservationsSummaries = new ReservationsSummariesOperations(this); + ReservationsDetails = new ReservationsDetailsOperations(this); + ReservationRecommendations = new ReservationRecommendationsOperations(this); + PriceSheet = new PriceSheetOperations(this); + Forecasts = new ForecastsOperations(this); Operations = new Operations(this); - CreditSummaryByBillingProfile = new CreditSummaryByBillingProfileOperations(this); - EventsByBillingProfile = new EventsByBillingProfileOperations(this); - LotsByBillingProfile = new LotsByBillingProfileOperations(this); - InvoicePricesheet = new InvoicePricesheetOperations(this); - BillingProfilePricesheet = new BillingProfilePricesheetOperations(this); - ChargesByBillingAccount = new ChargesByBillingAccountOperations(this); - ChargesByBillingProfile = new ChargesByBillingProfileOperations(this); - ChargesByInvoiceSection = new ChargesByInvoiceSectionOperations(this); + AggregatedCost = new AggregatedCostOperations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2018-11-01-preview"; + ApiVersion = "2019-04-01-preview"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/CreditSummaryByBillingProfileOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/CreditSummaryByBillingProfileOperationsExtensions.cs deleted file mode 100644 index 5af489d05016..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/CreditSummaryByBillingProfileOperationsExtensions.cs +++ /dev/null @@ -1,69 +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.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CreditSummaryByBillingProfileOperations. - /// - public static partial class CreditSummaryByBillingProfileOperationsExtensions - { - /// - /// The credit summary by billingAccountId and billingProfileId for given start - /// and end date. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. - /// - public static CreditSummary Get(this ICreditSummaryByBillingProfileOperations operations, string billingAccountId, string billingProfileId) - { - return operations.GetAsync(billingAccountId, billingProfileId).GetAwaiter().GetResult(); - } - - /// - /// The credit summary by billingAccountId and billingProfileId for given start - /// and end date. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this ICreditSummaryByBillingProfileOperations operations, string billingAccountId, string billingProfileId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(billingAccountId, billingProfileId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/EventsByBillingProfileOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/EventsByBillingProfileOperationsExtensions.cs deleted file mode 100644 index 5b0ee0a7902e..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/EventsByBillingProfileOperationsExtensions.cs +++ /dev/null @@ -1,81 +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.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for EventsByBillingProfileOperations. - /// - public static partial class EventsByBillingProfileOperationsExtensions - { - /// - /// Lists the events by billingAccountId and billingProfileId for given start - /// and end date. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - public static Events List(this IEventsByBillingProfileOperations operations, string billingAccountId, string billingProfileId, string startDate, string endDate) - { - return operations.ListAsync(billingAccountId, billingProfileId, startDate, endDate).GetAwaiter().GetResult(); - } - - /// - /// Lists the events by billingAccountId and billingProfileId for given start - /// and end date. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IEventsByBillingProfileOperations operations, string billingAccountId, string billingProfileId, string startDate, string endDate, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountId, billingProfileId, startDate, endDate, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/LotsByBillingProfileOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ForecastsOperations.cs similarity index 82% rename from src/SDKs/Consumption/Management.Consumption/Generated/LotsByBillingProfileOperations.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/ForecastsOperations.cs index cb80611cfb72..e6b0aa3b31a4 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/LotsByBillingProfileOperations.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ForecastsOperations.cs @@ -12,6 +12,7 @@ namespace Microsoft.Azure.Management.Consumption { using Microsoft.Rest; using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; using Models; using Newtonsoft.Json; using System.Collections; @@ -23,12 +24,12 @@ namespace Microsoft.Azure.Management.Consumption using System.Threading.Tasks; /// - /// LotsByBillingProfileOperations operations. + /// ForecastsOperations operations. /// - internal partial class LotsByBillingProfileOperations : IServiceOperations, ILotsByBillingProfileOperations + internal partial class ForecastsOperations : IServiceOperations, IForecastsOperations { /// - /// Initializes a new instance of the LotsByBillingProfileOperations class. + /// Initializes a new instance of the ForecastsOperations class. /// /// /// Reference to the service client. @@ -36,7 +37,7 @@ internal partial class LotsByBillingProfileOperations : IServiceOperations /// Thrown when a required parameter is null /// - internal LotsByBillingProfileOperations(ConsumptionManagementClient client) + internal ForecastsOperations(ConsumptionManagementClient client) { if (client == null) { @@ -51,15 +52,11 @@ internal LotsByBillingProfileOperations(ConsumptionManagementClient client) public ConsumptionManagementClient Client { get; private set; } /// - /// Lists the lots by billingAccountId and billingProfileId for given start and - /// end date. + /// Lists the forecast charges by subscriptionId. /// /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. + /// + /// OData parameters to apply to the operation. /// /// /// Headers that will be added to request. @@ -82,20 +79,16 @@ internal LotsByBillingProfileOperations(ConsumptionManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ListWithHttpMessagesAsync(string billingAccountId, string billingProfileId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (billingAccountId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); - } - if (billingProfileId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileId"); - } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -103,17 +96,23 @@ internal LotsByBillingProfileOperations(ConsumptionManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("billingAccountId", billingAccountId); - tracingParameters.Add("billingProfileId", billingProfileId); + tracingParameters.Add("odataQuery", odataQuery); 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/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots").ToString(); - _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); - _url = _url.Replace("{billingProfileId}", System.Uri.EscapeDataString(billingProfileId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Consumption/forecasts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } if (Client.ApiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); @@ -206,7 +205,7 @@ internal LotsByBillingProfileOperations(ConsumptionManagementClient 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")) @@ -219,7 +218,7 @@ internal LotsByBillingProfileOperations(ConsumptionManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/LotsByBillingProfileOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ForecastsOperationsExtensions.cs similarity index 53% rename from src/SDKs/Consumption/Management.Consumption/Generated/LotsByBillingProfileOperationsExtensions.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/ForecastsOperationsExtensions.cs index fbaffe1fa149..a131026558b6 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/LotsByBillingProfileOperationsExtensions.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ForecastsOperationsExtensions.cs @@ -12,54 +12,49 @@ namespace Microsoft.Azure.Management.Consumption { using Microsoft.Rest; using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; using Models; + using System.Collections; + using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; /// - /// Extension methods for LotsByBillingProfileOperations. + /// Extension methods for ForecastsOperations. /// - public static partial class LotsByBillingProfileOperationsExtensions + public static partial class ForecastsOperationsExtensions { /// - /// Lists the lots by billingAccountId and billingProfileId for given start and - /// end date. + /// Lists the forecast charges by subscriptionId. /// /// /// /// The operations group for this extension method. /// - /// - /// BillingAccount ID + /// + /// OData parameters to apply to the operation. /// - /// - /// Billing Profile Id. - /// - public static Lots List(this ILotsByBillingProfileOperations operations, string billingAccountId, string billingProfileId) + public static IEnumerable List(this IForecastsOperations operations, ODataQuery odataQuery = default(ODataQuery)) { - return operations.ListAsync(billingAccountId, billingProfileId).GetAwaiter().GetResult(); + return operations.ListAsync(odataQuery).GetAwaiter().GetResult(); } /// - /// Lists the lots by billingAccountId and billingProfileId for given start and - /// end date. + /// Lists the forecast charges by subscriptionId. /// /// /// /// The operations group for this extension method. /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. + /// + /// OData parameters to apply to the operation. /// /// /// The cancellation token. /// - public static async Task ListAsync(this ILotsByBillingProfileOperations operations, string billingAccountId, string billingProfileId, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListAsync(this IForecastsOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListWithHttpMessagesAsync(billingAccountId, billingProfileId, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.ListWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IAggregatedCostOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IAggregatedCostOperations.cs new file mode 100644 index 000000000000..3d10ce32b94d --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IAggregatedCostOperations.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AggregatedCostOperations operations. + /// + public partial interface IAggregatedCostOperations + { + /// + /// Provides the aggregate cost of a management group and all child + /// management groups by current billing period. + /// + /// + /// + /// Azure Management Group ID. + /// + /// + /// May be used to filter aggregated cost by properties/usageStart (Utc + /// time), properties/usageEnd (Utc time). 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> GetByManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Provides the aggregate cost of a management group and all child + /// management groups by specified billing period + /// + /// + /// + /// Azure Management Group ID. + /// + /// + /// Billing Period Name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetForBillingPeriodByManagementGroupWithHttpMessagesAsync(string managementGroupId, string billingPeriodName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IInvoicePricesheetOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IBalancesOperations.cs similarity index 64% rename from src/SDKs/Consumption/Management.Consumption/Generated/IInvoicePricesheetOperations.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/IBalancesOperations.cs index 6fc082c252f1..b64b92001e05 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/IInvoicePricesheetOperations.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IBalancesOperations.cs @@ -19,18 +19,17 @@ namespace Microsoft.Azure.Management.Consumption using System.Threading.Tasks; /// - /// InvoicePricesheetOperations operations. + /// BalancesOperations operations. /// - public partial interface IInvoicePricesheetOperations + public partial interface IBalancesOperations { /// - /// Get pricesheet data for invoice id (invoiceName). + /// Gets the balances for a scope by billingAccountId. Balances are + /// available via this API only for May 1, 2014 or later. + /// /// /// - /// Azure Billing Account Id. - /// - /// - /// The name of an invoice resource. + /// BillingAccount ID /// /// /// The headers that will be added to request. @@ -47,15 +46,18 @@ public partial interface IInvoicePricesheetOperations /// /// Thrown when a required parameter is null /// - Task> DownloadWithHttpMessagesAsync(string billingAccountId, string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> GetByBillingAccountWithHttpMessagesAsync(string billingAccountId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Get pricesheet data for invoice id (invoiceName). + /// Gets the balances for a scope by billing period and + /// billingAccountId. Balances are available via this API only for May + /// 1, 2014 or later. + /// /// /// - /// Azure Billing Account Id. + /// BillingAccount ID /// - /// - /// The name of an invoice resource. + /// + /// Billing Period Name. /// /// /// The headers that will be added to request. @@ -72,6 +74,6 @@ public partial interface IInvoicePricesheetOperations /// /// Thrown when a required parameter is null /// - Task> BeginDownloadWithHttpMessagesAsync(string billingAccountId, string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> GetForBillingPeriodByBillingAccountWithHttpMessagesAsync(string billingAccountId, string billingPeriodName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IBudgetsOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IBudgetsOperations.cs new file mode 100644 index 000000000000..6e5fcfd6f474 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IBudgetsOperations.cs @@ -0,0 +1,214 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// BudgetsOperations operations. + /// + public partial interface IBudgetsOperations + { + /// + /// Lists all budgets for the defined scope. + /// + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// 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 scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the budget for the scope by budget name. + /// + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string scope, string budgetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to create or update a budget. Update operation + /// requires latest eTag to be set in the request mandatorily. You may + /// obtain the latest eTag by performing a get operation. Create + /// operation does not require eTag. + /// + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// Parameters supplied to the Create Budget operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string scope, string budgetName, Budget parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to delete a budget. + /// + /// + /// + /// The scope associated with budget operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope. + /// + /// + /// Budget Name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string scope, string budgetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all budgets for the defined scope. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IChargesByBillingProfileOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IChargesByBillingProfileOperations.cs deleted file mode 100644 index ef0aa9745cab..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/IChargesByBillingProfileOperations.cs +++ /dev/null @@ -1,63 +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.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ChargesByBillingProfileOperations operations. - /// - public partial interface IChargesByBillingProfileOperations - { - /// - /// Lists the charges by billing profile id for given start and end - /// date. Start and end date are used to determine the billing period. - /// For current month, the data will be provided from month to date. If - /// there are no chages for a month then that month will show all - /// zeroes. - /// - /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// 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 billingAccountId, string billingProfileId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IChargesByInvoiceSectionOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IChargesByInvoiceSectionOperations.cs deleted file mode 100644 index 82deacc0990e..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/IChargesByInvoiceSectionOperations.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ChargesByInvoiceSectionOperations operations. - /// - public partial interface IChargesByInvoiceSectionOperations - { - /// - /// Lists the charges by invoice section id for given start and end - /// date. Start and end date are used to determine the billing period. - /// For current month, the data will be provided from month to date. If - /// there are no chages for a month then that month will show all - /// zeroes. - /// - /// - /// - /// BillingAccount ID - /// - /// - /// Invoice Section Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to group charges by properties/productName. - /// - /// - /// 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 billingAccountId, string invoiceSectionId, string startDate, string endDate, string apply = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IChargesOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IChargesOperations.cs new file mode 100644 index 000000000000..2504a13be935 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IChargesOperations.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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ChargesOperations operations. + /// + public partial interface IChargesOperations + { + /// + /// Lists the charges based for the defined scope. + /// + /// + /// + /// The scope associated with usage details operations. This includes + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope. For department and enrollment + /// accounts, you can also add billing period to the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. + /// For e.g. to specify billing period at department scope use + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// May be used to filter charges by properties/usageEnd (Utc time), + /// properties/usageStart (Utc time). 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> ListByScopeWithHttpMessagesAsync(string scope, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IConsumptionManagementClient.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IConsumptionManagementClient.cs index e2c4c4de2e23..e222d81ba322 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/IConsumptionManagementClient.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IConsumptionManagementClient.cs @@ -43,10 +43,15 @@ public partial interface IConsumptionManagementClient : System.IDisposable /// /// Version of the API to be used with the client request. The current - /// version is 2018-11-01-preview. + /// version is 2019-04-01-preview. /// string ApiVersion { get; } + /// + /// Azure Subscription ID. + /// + string SubscriptionId { get; set; } + /// /// The preferred language for the response. /// @@ -67,49 +72,69 @@ public partial interface IConsumptionManagementClient : System.IDisposable /// - /// Gets the IOperations. + /// Gets the IUsageDetailsOperations. /// - IOperations Operations { get; } + IUsageDetailsOperations UsageDetails { get; } /// - /// Gets the ICreditSummaryByBillingProfileOperations. + /// Gets the IMarketplacesOperations. /// - ICreditSummaryByBillingProfileOperations CreditSummaryByBillingProfile { get; } + IMarketplacesOperations Marketplaces { get; } /// - /// Gets the IEventsByBillingProfileOperations. + /// Gets the IBudgetsOperations. /// - IEventsByBillingProfileOperations EventsByBillingProfile { get; } + IBudgetsOperations Budgets { get; } /// - /// Gets the ILotsByBillingProfileOperations. + /// Gets the ITagsOperations. /// - ILotsByBillingProfileOperations LotsByBillingProfile { get; } + ITagsOperations Tags { get; } /// - /// Gets the IInvoicePricesheetOperations. + /// Gets the IChargesOperations. /// - IInvoicePricesheetOperations InvoicePricesheet { get; } + IChargesOperations Charges { get; } /// - /// Gets the IBillingProfilePricesheetOperations. + /// Gets the IBalancesOperations. /// - IBillingProfilePricesheetOperations BillingProfilePricesheet { get; } + IBalancesOperations Balances { get; } /// - /// Gets the IChargesByBillingAccountOperations. + /// Gets the IReservationsSummariesOperations. /// - IChargesByBillingAccountOperations ChargesByBillingAccount { get; } + IReservationsSummariesOperations ReservationsSummaries { get; } /// - /// Gets the IChargesByBillingProfileOperations. + /// Gets the IReservationsDetailsOperations. /// - IChargesByBillingProfileOperations ChargesByBillingProfile { get; } + IReservationsDetailsOperations ReservationsDetails { get; } + + /// + /// Gets the IReservationRecommendationsOperations. + /// + IReservationRecommendationsOperations ReservationRecommendations { get; } + + /// + /// Gets the IPriceSheetOperations. + /// + IPriceSheetOperations PriceSheet { get; } + + /// + /// Gets the IForecastsOperations. + /// + IForecastsOperations Forecasts { get; } + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } /// - /// Gets the IChargesByInvoiceSectionOperations. + /// Gets the IAggregatedCostOperations. /// - IChargesByInvoiceSectionOperations ChargesByInvoiceSection { get; } + IAggregatedCostOperations AggregatedCost { get; } } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/ICreditSummaryByBillingProfileOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ICreditSummaryByBillingProfileOperations.cs deleted file mode 100644 index 0cc2ec0c64aa..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/ICreditSummaryByBillingProfileOperations.cs +++ /dev/null @@ -1,54 +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.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CreditSummaryByBillingProfileOperations operations. - /// - public partial interface ICreditSummaryByBillingProfileOperations - { - /// - /// The credit summary by billingAccountId and billingProfileId for - /// given start and end date. - /// - /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string billingAccountId, string billingProfileId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IEventsByBillingProfileOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IEventsByBillingProfileOperations.cs deleted file mode 100644 index f9ab85fe602d..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/IEventsByBillingProfileOperations.cs +++ /dev/null @@ -1,60 +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.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// EventsByBillingProfileOperations operations. - /// - public partial interface IEventsByBillingProfileOperations - { - /// - /// Lists the events by billingAccountId and billingProfileId for given - /// start and end date. - /// - /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// 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 billingAccountId, string billingProfileId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/ILotsByBillingProfileOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IForecastsOperations.cs similarity index 69% rename from src/SDKs/Consumption/Management.Consumption/Generated/ILotsByBillingProfileOperations.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/IForecastsOperations.cs index b7b03a95a81b..348fe562c412 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/ILotsByBillingProfileOperations.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IForecastsOperations.cs @@ -12,6 +12,7 @@ namespace Microsoft.Azure.Management.Consumption { using Microsoft.Rest; using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; using Models; using System.Collections; using System.Collections.Generic; @@ -19,20 +20,16 @@ namespace Microsoft.Azure.Management.Consumption using System.Threading.Tasks; /// - /// LotsByBillingProfileOperations operations. + /// ForecastsOperations operations. /// - public partial interface ILotsByBillingProfileOperations + public partial interface IForecastsOperations { /// - /// Lists the lots by billingAccountId and billingProfileId for given - /// start and end date. + /// Lists the forecast charges by subscriptionId. /// /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. + /// + /// OData parameters to apply to the operation. /// /// /// The headers that will be added to request. @@ -49,6 +46,6 @@ public partial interface ILotsByBillingProfileOperations /// /// Thrown when a required parameter is null /// - Task> ListWithHttpMessagesAsync(string billingAccountId, string billingProfileId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IMarketplacesOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IMarketplacesOperations.cs new file mode 100644 index 000000000000..78a4d29037a9 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IMarketplacesOperations.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MarketplacesOperations operations. + /// + public partial interface IMarketplacesOperations + { + /// + /// Lists the marketplaces for a scope at the defined scope. + /// Marketplaces are available via this API only for May 1, 2014 or + /// later. + /// + /// + /// + /// The scope associated with marketplace operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for + /// Department scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope. For subscription, billing account, + /// department, enrollment account and ManagementGroup, you can also + /// add billing period to the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. + /// For e.g. to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// 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. + /// + /// + /// 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 scope, ODataQuery odataQuery = default(ODataQuery), string skiptoken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the marketplaces for a scope at the defined scope. + /// Marketplaces are available via this API only for May 1, 2014 or + /// later. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IPriceSheetOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IPriceSheetOperations.cs new file mode 100644 index 000000000000..06289b05f713 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IPriceSheetOperations.cs @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PriceSheetOperations operations. + /// + public partial interface IPriceSheetOperations + { + /// + /// Gets the price sheet for a scope by subscriptionId. Price sheet is + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// May be used to expand the properties/meterDetails within a price + /// sheet. By default, these fields are not included when returning + /// price sheet. + /// + /// + /// 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 top N results. + /// + /// + /// 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 expand = default(string), string skiptoken = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the price sheet for a scope by subscriptionId and billing + /// period. Price sheet is available via this API only for May 1, 2014 + /// or later. + /// + /// + /// + /// Billing Period Name. + /// + /// + /// May be used to expand the properties/meterDetails within a price + /// sheet. By default, these fields are not included when returning + /// price sheet. + /// + /// + /// 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 top N results. + /// + /// + /// 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> GetByBillingPeriodWithHttpMessagesAsync(string billingPeriodName, string expand = default(string), string skiptoken = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IBillingProfilePricesheetOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IReservationRecommendationsOperations.cs similarity index 63% rename from src/SDKs/Consumption/Management.Consumption/Generated/IBillingProfilePricesheetOperations.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/IReservationRecommendationsOperations.cs index d60b8b363778..9c9af6f5a790 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/IBillingProfilePricesheetOperations.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IReservationRecommendationsOperations.cs @@ -19,18 +19,17 @@ namespace Microsoft.Azure.Management.Consumption using System.Threading.Tasks; /// - /// BillingProfilePricesheetOperations operations. + /// ReservationRecommendationsOperations operations. /// - public partial interface IBillingProfilePricesheetOperations + public partial interface IReservationRecommendationsOperations { /// - /// Get pricesheet data for invoice id (invoiceName). + /// List of recommendations for purchasing reserved instances. + /// /// - /// - /// Azure Billing Account Id. - /// - /// - /// Azure Billing Profile Id. + /// + /// May be used to filter reservationRecommendations by + /// properties/scope and properties/lookBackPeriod. /// /// /// The headers that will be added to request. @@ -47,15 +46,13 @@ public partial interface IBillingProfilePricesheetOperations /// /// Thrown when a required parameter is null /// - Task> DownloadWithHttpMessagesAsync(string billingAccountId, string billingProfileId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListWithHttpMessagesAsync(string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Get pricesheet data for invoice id (invoiceName). + /// List of recommendations for purchasing reserved instances. + /// /// - /// - /// Azure Billing Account Id. - /// - /// - /// Azure Billing Profile Id. + /// + /// The NextLink from the previous successful call to List operation. /// /// /// The headers that will be added to request. @@ -72,6 +69,6 @@ public partial interface IBillingProfilePricesheetOperations /// /// Thrown when a required parameter is null /// - Task> BeginDownloadWithHttpMessagesAsync(string billingAccountId, string billingProfileId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IReservationsDetailsOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IReservationsDetailsOperations.cs new file mode 100644 index 000000000000..d3ff2f1edd4d --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IReservationsDetailsOperations.cs @@ -0,0 +1,130 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ReservationsDetailsOperations operations. + /// + public partial interface IReservationsDetailsOperations + { + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// Order Id of the reservation + /// + /// + /// Filter reservation details by date range. The properties/UsageDate + /// for start date and end date. The filter supports 'le' and 'ge' + /// + /// + /// 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>> ListByReservationOrderWithHttpMessagesAsync(string reservationOrderId, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// Order Id of the reservation + /// + /// + /// Id of the reservation + /// + /// + /// Filter reservation details by date range. The properties/UsageDate + /// for start date and end date. The filter supports 'le' and 'ge' + /// + /// + /// 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>> ListByReservationOrderAndReservationWithHttpMessagesAsync(string reservationOrderId, string reservationId, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByReservationOrderNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByReservationOrderAndReservationNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IReservationsSummariesOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IReservationsSummariesOperations.cs new file mode 100644 index 000000000000..dc422c9c9743 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IReservationsSummariesOperations.cs @@ -0,0 +1,138 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ReservationsSummariesOperations operations. + /// + public partial interface IReservationsSummariesOperations + { + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// Order Id of the reservation + /// + /// + /// Can be daily or monthly. Possible values include: 'DailyGrain', + /// 'MonthlyGrain' + /// + /// + /// Required only for daily grain. The properties/UsageDate for start + /// date and end date. The filter supports 'le' and 'ge' + /// + /// + /// 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>> ListByReservationOrderWithHttpMessagesAsync(string reservationOrderId, string grain, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// Order Id of the reservation + /// + /// + /// Id of the reservation + /// + /// + /// Can be daily or monthly. Possible values include: 'DailyGrain', + /// 'MonthlyGrain' + /// + /// + /// Required only for daily grain. The properties/UsageDate for start + /// date and end date. The filter supports 'le' and 'ge' + /// + /// + /// 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>> ListByReservationOrderAndReservationWithHttpMessagesAsync(string reservationOrderId, string reservationId, string grain, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByReservationOrderNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByReservationOrderAndReservationNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IChargesByBillingAccountOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ITagsOperations.cs similarity index 55% rename from src/SDKs/Consumption/Management.Consumption/Generated/IChargesByBillingAccountOperations.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/ITagsOperations.cs index 0df31fa1eb97..7ed8213de366 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/IChargesByBillingAccountOperations.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ITagsOperations.cs @@ -19,30 +19,27 @@ namespace Microsoft.Azure.Management.Consumption using System.Threading.Tasks; /// - /// ChargesByBillingAccountOperations operations. + /// TagsOperations operations. /// - public partial interface IChargesByBillingAccountOperations + public partial interface ITagsOperations { /// - /// Lists the charges by billingAccountId for given start and end date. - /// Start and end date are used to determine the billing period. For - /// current month, the data will be provided from month to date. If - /// there are no chages for a month then that month will show all - /// zeroes. + /// Get all available tag keys for the defined scope /// /// - /// - /// BillingAccount ID - /// - /// - /// Start date - /// - /// - /// End date - /// - /// - /// May be used to group charges by properties/billingProfileId, or - /// properties/invoiceSectionId. + /// + /// The scope associated with tags operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope.. /// /// /// The headers that will be added to request. @@ -59,6 +56,6 @@ public partial interface IChargesByBillingAccountOperations /// /// Thrown when a required parameter is null /// - Task> ListWithHttpMessagesAsync(string billingAccountId, string startDate, string endDate, string apply = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> GetWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/IUsageDetailsOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/IUsageDetailsOperations.cs new file mode 100644 index 000000000000..1ad611d71276 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/IUsageDetailsOperations.cs @@ -0,0 +1,205 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// UsageDetailsOperations operations. + /// + public partial interface IUsageDetailsOperations + { + /// + /// Lists the usage details for the defined scope. Usage details are + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for + /// Department scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope. For subscription, billing account, + /// department, enrollment account and management group, you can also + /// add billing period to the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. + /// For e.g. to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// May be used to expand the properties/additionalInfo or + /// properties/meterDetails within a list of usage details. By default, + /// these fields are not included when listing usage details. + /// + /// + /// May be used to filter usageDetails by properties/resourceGroup, + /// properties/resourceName, properties/resourceId, + /// properties/chargeType, properties/reservationId or tags. 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 (:). + /// + /// + /// 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 + /// usageDetails. + /// + /// + /// Allows to select different type of cost/usage records. Possible + /// values include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + /// + /// 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 scope, string expand = default(string), string filter = default(string), string skiptoken = default(string), int? top = default(int?), string metric = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Download usage details data. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for + /// Department scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope. For subscription, billing account, + /// department, enrollment account and management group, you can also + /// add billing period to the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. + /// For e.g. to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// Allows to select different type of cost/usage records. Possible + /// values include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + /// + /// 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> DownloadWithHttpMessagesAsync(string scope, string metric = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Download usage details data. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for + /// Department scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope. For subscription, billing account, + /// department, enrollment account and management group, you can also + /// add billing period to the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. + /// For e.g. to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// Allows to select different type of cost/usage records. Possible + /// values include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + /// + /// 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> BeginDownloadWithHttpMessagesAsync(string scope, string metric = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the usage details for the defined scope. Usage details are + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/InvoicePricesheetOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/InvoicePricesheetOperationsExtensions.cs deleted file mode 100644 index 55848d63e306..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/InvoicePricesheetOperationsExtensions.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Consumption -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for InvoicePricesheetOperations. - /// - public static partial class InvoicePricesheetOperationsExtensions - { - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// The operations group for this extension method. - /// - /// - /// Azure Billing Account Id. - /// - /// - /// The name of an invoice resource. - /// - public static PricesheetDownloadResponse Download(this IInvoicePricesheetOperations operations, string billingAccountId, string invoiceName) - { - return operations.DownloadAsync(billingAccountId, invoiceName).GetAwaiter().GetResult(); - } - - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// The operations group for this extension method. - /// - /// - /// Azure Billing Account Id. - /// - /// - /// The name of an invoice resource. - /// - /// - /// The cancellation token. - /// - public static async Task DownloadAsync(this IInvoicePricesheetOperations operations, string billingAccountId, string invoiceName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.DownloadWithHttpMessagesAsync(billingAccountId, invoiceName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// The operations group for this extension method. - /// - /// - /// Azure Billing Account Id. - /// - /// - /// The name of an invoice resource. - /// - public static PricesheetDownloadResponse BeginDownload(this IInvoicePricesheetOperations operations, string billingAccountId, string invoiceName) - { - return operations.BeginDownloadAsync(billingAccountId, invoiceName).GetAwaiter().GetResult(); - } - - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// The operations group for this extension method. - /// - /// - /// Azure Billing Account Id. - /// - /// - /// The name of an invoice resource. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDownloadAsync(this IInvoicePricesheetOperations operations, string billingAccountId, string invoiceName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginDownloadWithHttpMessagesAsync(billingAccountId, invoiceName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/MarketplacesOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/MarketplacesOperations.cs new file mode 100644 index 000000000000..d858ca0213eb --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/MarketplacesOperations.cs @@ -0,0 +1,443 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// MarketplacesOperations operations. + /// + internal partial class MarketplacesOperations : IServiceOperations, IMarketplacesOperations + { + /// + /// Initializes a new instance of the MarketplacesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MarketplacesOperations(ConsumptionManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ConsumptionManagementClient + /// + public ConsumptionManagementClient Client { get; private set; } + + /// + /// Lists the marketplaces for a scope at the defined scope. Marketplaces are + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The scope associated with marketplace operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and ManagementGroup, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// 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. + /// + /// + /// 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 scope, ODataQuery odataQuery = default(ODataQuery), string skiptoken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + 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("odataQuery", odataQuery); + tracingParameters.Add("skiptoken", skiptoken); + tracingParameters.Add("scope", scope); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/marketplaces").ToString(); + _url = _url.Replace("{scope}", scope); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + if (skiptoken != null) + { + _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken))); + } + 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 marketplaces for a scope at the defined scope. Marketplaces are + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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/Consumption/Management.Consumption/Generated/MarketplacesOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/MarketplacesOperationsExtensions.cs new file mode 100644 index 000000000000..0d7f5e675967 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/MarketplacesOperationsExtensions.cs @@ -0,0 +1,152 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MarketplacesOperations. + /// + public static partial class MarketplacesOperationsExtensions + { + /// + /// Lists the marketplaces for a scope at the defined scope. Marketplaces are + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with marketplace operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and ManagementGroup, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// 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. + /// + public static IPage List(this IMarketplacesOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery), string skiptoken = default(string)) + { + return operations.ListAsync(scope, odataQuery, skiptoken).GetAwaiter().GetResult(); + } + + /// + /// Lists the marketplaces for a scope at the defined scope. Marketplaces are + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with marketplace operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and ManagementGroup, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IMarketplacesOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery), string skiptoken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(scope, odataQuery, skiptoken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the marketplaces for a scope at the defined scope. Marketplaces are + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IMarketplacesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the marketplaces for a scope at the defined scope. Marketplaces are + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// 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 IMarketplacesOperations 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/Consumption/Management.Consumption/Generated/Models/Address.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Address.cs deleted file mode 100644 index 2378a6006315..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Address.cs +++ /dev/null @@ -1,108 +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.Consumption.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Address details. - /// - public partial class Address - { - /// - /// Initializes a new instance of the Address class. - /// - public Address() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Address class. - /// - /// Address Line1. - /// Address Line2. - /// Address Line3. - /// Address City. - /// Address Region. - /// Country code uses ISO2, 2-digit - /// format.. - /// Postal Code. - /// Phone Number. - public Address(string addressLine1 = default(string), string addressLine2 = default(string), string addressLine3 = default(string), string city = default(string), string region = default(string), string country = default(string), string postalCode = default(string), string phoneNumber = default(string)) - { - AddressLine1 = addressLine1; - AddressLine2 = addressLine2; - AddressLine3 = addressLine3; - City = city; - Region = region; - Country = country; - PostalCode = postalCode; - PhoneNumber = phoneNumber; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets address Line1. - /// - [JsonProperty(PropertyName = "addressLine1")] - public string AddressLine1 { get; set; } - - /// - /// Gets or sets address Line2. - /// - [JsonProperty(PropertyName = "addressLine2")] - public string AddressLine2 { get; set; } - - /// - /// Gets or sets address Line3. - /// - [JsonProperty(PropertyName = "addressLine3")] - public string AddressLine3 { get; set; } - - /// - /// Gets or sets address City. - /// - [JsonProperty(PropertyName = "city")] - public string City { get; set; } - - /// - /// Gets or sets address Region. - /// - [JsonProperty(PropertyName = "region")] - public string Region { get; set; } - - /// - /// Gets or sets country code uses ISO2, 2-digit format.. - /// - [JsonProperty(PropertyName = "country")] - public string Country { get; set; } - - /// - /// Gets or sets postal Code. - /// - [JsonProperty(PropertyName = "postalCode")] - public string PostalCode { get; set; } - - /// - /// Gets or sets phone Number. - /// - [JsonProperty(PropertyName = "phoneNumber")] - public string PhoneNumber { get; set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Balance.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Balance.cs new file mode 100644 index 000000000000..72871f81e602 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Balance.cs @@ -0,0 +1,185 @@ +// +// 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.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A balance resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class Balance : Resource + { + /// + /// Initializes a new instance of the Balance class. + /// + public Balance() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Balance class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + /// The ISO currency in which the meter is + /// charged, for example, USD. + /// The beginning balance for the + /// billing period. + /// The ending balance for the billing + /// period (for open periods this will be updated daily). + /// Total new purchase amount. + /// Total adjustment amount. + /// Total Commitment usage. + /// Overage for Azure services. + /// Charges Billed + /// separately. + /// serviceOverage + + /// chargesBilledSeparately. + /// Azure service commitment + total + /// Overage. + /// Total charges for + /// Azure Marketplace. + /// The billing frequency. Possible + /// values include: 'Month', 'Quarter', 'Year' + /// Price is hidden or not. + /// List of new purchases. + /// List of Adjustments (Promo credit, + /// SIE credit etc.). + public Balance(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string currency = default(string), decimal? beginningBalance = default(decimal?), decimal? endingBalance = default(decimal?), decimal? newPurchases = default(decimal?), decimal? adjustments = default(decimal?), decimal? utilized = default(decimal?), decimal? serviceOverage = default(decimal?), decimal? chargesBilledSeparately = default(decimal?), decimal? totalOverage = default(decimal?), decimal? totalUsage = default(decimal?), decimal? azureMarketplaceServiceCharges = default(decimal?), string billingFrequency = default(string), bool? priceHidden = default(bool?), IList newPurchasesDetails = default(IList), IList adjustmentDetails = default(IList)) + : base(id, name, type, tags) + { + Currency = currency; + BeginningBalance = beginningBalance; + EndingBalance = endingBalance; + NewPurchases = newPurchases; + Adjustments = adjustments; + Utilized = utilized; + ServiceOverage = serviceOverage; + ChargesBilledSeparately = chargesBilledSeparately; + TotalOverage = totalOverage; + TotalUsage = totalUsage; + AzureMarketplaceServiceCharges = azureMarketplaceServiceCharges; + BillingFrequency = billingFrequency; + PriceHidden = priceHidden; + NewPurchasesDetails = newPurchasesDetails; + AdjustmentDetails = adjustmentDetails; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the ISO currency in which the meter is charged, for example, + /// USD. + /// + [JsonProperty(PropertyName = "properties.currency")] + public string Currency { get; private set; } + + /// + /// Gets the beginning balance for the billing period. + /// + [JsonProperty(PropertyName = "properties.beginningBalance")] + public decimal? BeginningBalance { get; private set; } + + /// + /// Gets the ending balance for the billing period (for open periods + /// this will be updated daily). + /// + [JsonProperty(PropertyName = "properties.endingBalance")] + public decimal? EndingBalance { get; private set; } + + /// + /// Gets total new purchase amount. + /// + [JsonProperty(PropertyName = "properties.newPurchases")] + public decimal? NewPurchases { get; private set; } + + /// + /// Gets total adjustment amount. + /// + [JsonProperty(PropertyName = "properties.adjustments")] + public decimal? Adjustments { get; private set; } + + /// + /// Gets total Commitment usage. + /// + [JsonProperty(PropertyName = "properties.utilized")] + public decimal? Utilized { get; private set; } + + /// + /// Gets overage for Azure services. + /// + [JsonProperty(PropertyName = "properties.serviceOverage")] + public decimal? ServiceOverage { get; private set; } + + /// + /// Gets charges Billed separately. + /// + [JsonProperty(PropertyName = "properties.chargesBilledSeparately")] + public decimal? ChargesBilledSeparately { get; private set; } + + /// + /// Gets serviceOverage + chargesBilledSeparately. + /// + [JsonProperty(PropertyName = "properties.totalOverage")] + public decimal? TotalOverage { get; private set; } + + /// + /// Gets azure service commitment + total Overage. + /// + [JsonProperty(PropertyName = "properties.totalUsage")] + public decimal? TotalUsage { get; private set; } + + /// + /// Gets total charges for Azure Marketplace. + /// + [JsonProperty(PropertyName = "properties.azureMarketplaceServiceCharges")] + public decimal? AzureMarketplaceServiceCharges { get; private set; } + + /// + /// Gets or sets the billing frequency. Possible values include: + /// 'Month', 'Quarter', 'Year' + /// + [JsonProperty(PropertyName = "properties.billingFrequency")] + public string BillingFrequency { get; set; } + + /// + /// Gets price is hidden or not. + /// + [JsonProperty(PropertyName = "properties.priceHidden")] + public bool? PriceHidden { get; private set; } + + /// + /// Gets list of new purchases. + /// + [JsonProperty(PropertyName = "properties.newPurchasesDetails")] + public IList NewPurchasesDetails { get; private set; } + + /// + /// Gets list of Adjustments (Promo credit, SIE credit etc.). + /// + [JsonProperty(PropertyName = "properties.adjustmentDetails")] + public IList AdjustmentDetails { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListByInvoiceSection.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BalancePropertiesAdjustmentDetailsItem.cs similarity index 50% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListByInvoiceSection.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/BalancePropertiesAdjustmentDetailsItem.cs index a9cc50be6e90..e94c86b6802d 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListByInvoiceSection.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BalancePropertiesAdjustmentDetailsItem.cs @@ -11,34 +11,28 @@ namespace Microsoft.Azure.Management.Consumption.Models { using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; using System.Linq; - /// - /// Result of listing charge summary by invoiceSection. It contains a list - /// of available change summaries in reverse chronological order by billing - /// period. - /// - public partial class ChargesListByInvoiceSection + public partial class BalancePropertiesAdjustmentDetailsItem { /// - /// Initializes a new instance of the ChargesListByInvoiceSection - /// class. + /// Initializes a new instance of the + /// BalancePropertiesAdjustmentDetailsItem class. /// - public ChargesListByInvoiceSection() + public BalancePropertiesAdjustmentDetailsItem() { CustomInit(); } /// - /// Initializes a new instance of the ChargesListByInvoiceSection - /// class. + /// Initializes a new instance of the + /// BalancePropertiesAdjustmentDetailsItem class. /// - /// The list of charge summary by - /// invoiceSection. - public ChargesListByInvoiceSection(IList value = default(IList)) + /// the name of new adjustment. + /// the value of new adjustment. + public BalancePropertiesAdjustmentDetailsItem(string name = default(string), decimal? value = default(decimal?)) { + Name = name; Value = value; CustomInit(); } @@ -49,10 +43,16 @@ public ChargesListByInvoiceSection() partial void CustomInit(); /// - /// Gets the list of charge summary by invoiceSection. + /// Gets the name of new adjustment. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the value of new adjustment. /// [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } + public decimal? Value { get; private set; } } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/BalancePropertiesNewPurchasesDetailsItem.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BalancePropertiesNewPurchasesDetailsItem.cs new file mode 100644 index 000000000000..c17e75f627bf --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BalancePropertiesNewPurchasesDetailsItem.cs @@ -0,0 +1,58 @@ +// +// 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.Consumption.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class BalancePropertiesNewPurchasesDetailsItem + { + /// + /// Initializes a new instance of the + /// BalancePropertiesNewPurchasesDetailsItem class. + /// + public BalancePropertiesNewPurchasesDetailsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// BalancePropertiesNewPurchasesDetailsItem class. + /// + /// the name of new purchase. + /// the value of new purchase. + public BalancePropertiesNewPurchasesDetailsItem(string name = default(string), decimal? value = default(decimal?)) + { + Name = name; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of new purchase. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the value of new purchase. + /// + [JsonProperty(PropertyName = "value")] + public decimal? Value { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingAccount.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingAccount.cs deleted file mode 100644 index 078d4a828e03..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingAccount.cs +++ /dev/null @@ -1,155 +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.Consumption.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A billing account resource. - /// - [Rest.Serialization.JsonTransformation] - public partial class BillingAccount : Resource - { - /// - /// Initializes a new instance of the BillingAccount class. - /// - public BillingAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BillingAccount class. - /// - /// Resource Id. - /// Resource name. - /// Resource type. - /// Resource tags. - /// The Company this billing account belongs - /// to. - /// The billing account Type. Possible values - /// include: 'CommerceRoot', 'Enrollment' - /// The address associated with billing - /// account. - /// The ISO currency, for example, - /// USD. - /// The country associated with billing - /// account. - /// Agreements associated with billing - /// account - /// The invoiceSections associated to the - /// billing account. - /// The billing profiles associated to - /// the billing account. - /// The details about the associated - /// legacy enrollment. By default this is not populated, unless it's - /// specified in $expand. - /// The departments associated to the - /// enrollment. - /// The accounts associated to the - /// enrollment. - public BillingAccount(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string company = default(string), string accountType = default(string), Address address = default(Address), string defaultCurrency = default(string), string country = default(string), string agreements = default(string), IList invoiceSections = default(IList), IList billingProfiles = default(IList), Enrollment enrollmentDetails = default(Enrollment), IList departments = default(IList), IList enrollmentAccounts = default(IList)) - : base(id, name, type, tags) - { - Company = company; - AccountType = accountType; - Address = address; - DefaultCurrency = defaultCurrency; - Country = country; - Agreements = agreements; - InvoiceSections = invoiceSections; - BillingProfiles = billingProfiles; - EnrollmentDetails = enrollmentDetails; - Departments = departments; - EnrollmentAccounts = enrollmentAccounts; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the Company this billing account belongs to. - /// - [JsonProperty(PropertyName = "properties.company")] - public string Company { get; private set; } - - /// - /// Gets the billing account Type. Possible values include: - /// 'CommerceRoot', 'Enrollment' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public string AccountType { get; private set; } - - /// - /// Gets or sets the address associated with billing account. - /// - [JsonProperty(PropertyName = "properties.address")] - public Address Address { get; set; } - - /// - /// Gets the ISO currency, for example, USD. - /// - [JsonProperty(PropertyName = "properties.defaultCurrency")] - public string DefaultCurrency { get; private set; } - - /// - /// Gets the country associated with billing account. - /// - [JsonProperty(PropertyName = "properties.country")] - public string Country { get; private set; } - - /// - /// Gets agreements associated with billing account - /// - [JsonProperty(PropertyName = "properties.agreements")] - public string Agreements { get; private set; } - - /// - /// Gets the invoiceSections associated to the billing account. - /// - [JsonProperty(PropertyName = "properties.invoiceSections")] - public IList InvoiceSections { get; private set; } - - /// - /// Gets the billing profiles associated to the billing account. - /// - [JsonProperty(PropertyName = "properties.billingProfiles")] - public IList BillingProfiles { get; private set; } - - /// - /// Gets the details about the associated legacy enrollment. By default - /// this is not populated, unless it's specified in $expand. - /// - [JsonProperty(PropertyName = "properties.enrollmentDetails")] - public Enrollment EnrollmentDetails { get; private set; } - - /// - /// Gets the departments associated to the enrollment. - /// - [JsonProperty(PropertyName = "properties.departments")] - public IList Departments { get; private set; } - - /// - /// Gets the accounts associated to the enrollment. - /// - [JsonProperty(PropertyName = "properties.enrollmentAccounts")] - public IList EnrollmentAccounts { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/EventType.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingFrequency.cs similarity index 65% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/EventType.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingFrequency.cs index 7ac8d06ba0d9..985b2d6c6735 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/EventType.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingFrequency.cs @@ -12,12 +12,12 @@ namespace Microsoft.Azure.Management.Consumption.Models { /// - /// Defines values for EventType. + /// Defines values for BillingFrequency. /// - public static class EventType + public static class BillingFrequency { - public const string NewCredit = "NewCredit"; - public const string ExpiredCredit = "ExpiredCredit"; - public const string SettledCharges = "SettledCharges"; + public const string Month = "Month"; + public const string Quarter = "Quarter"; + public const string Year = "Year"; } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingProfile.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingProfile.cs deleted file mode 100644 index 9e641c174032..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingProfile.cs +++ /dev/null @@ -1,109 +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.Consumption.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A billing profile resource. - /// - [Rest.Serialization.JsonTransformation] - public partial class BillingProfile : Resource - { - /// - /// Initializes a new instance of the BillingProfile class. - /// - public BillingProfile() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BillingProfile class. - /// - /// Resource Id. - /// Resource name. - /// Resource type. - /// Resource tags. - /// The billing profile name. - /// Purchase order number. - /// Billing address. - /// Billing contact. - /// Email invoice. - /// Invoice day. - /// Currency on the billing profile. - public BillingProfile(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string displayName = default(string), string poNumber = default(string), Address billingAddress = default(Address), string billingContact = default(string), bool? emailInvoice = default(bool?), int? invoiceDay = default(int?), string currency = default(string)) - : base(id, name, type, tags) - { - DisplayName = displayName; - PoNumber = poNumber; - BillingAddress = billingAddress; - BillingContact = billingContact; - EmailInvoice = emailInvoice; - InvoiceDay = invoiceDay; - Currency = currency; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the billing profile name. - /// - [JsonProperty(PropertyName = "properties.displayName")] - public string DisplayName { get; set; } - - /// - /// Gets or sets purchase order number. - /// - [JsonProperty(PropertyName = "properties.poNumber")] - public string PoNumber { get; set; } - - /// - /// Gets or sets billing address. - /// - [JsonProperty(PropertyName = "properties.billingAddress")] - public Address BillingAddress { get; set; } - - /// - /// Gets billing contact. - /// - [JsonProperty(PropertyName = "properties.billingContact")] - public string BillingContact { get; private set; } - - /// - /// Gets email invoice. - /// - [JsonProperty(PropertyName = "properties.emailInvoice")] - public bool? EmailInvoice { get; private set; } - - /// - /// Gets invoice day. - /// - [JsonProperty(PropertyName = "properties.invoiceDay")] - public int? InvoiceDay { get; private set; } - - /// - /// Gets currency on the billing profile. - /// - [JsonProperty(PropertyName = "properties.currency")] - public string Currency { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingProfilePricesheetDownloadHeaders.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingProfilePricesheetDownloadHeaders.cs deleted file mode 100644 index 834f26b1a264..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/BillingProfilePricesheetDownloadHeaders.cs +++ /dev/null @@ -1,85 +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.Consumption.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines headers for Download operation. - /// - public partial class BillingProfilePricesheetDownloadHeaders - { - /// - /// Initializes a new instance of the - /// BillingProfilePricesheetDownloadHeaders class. - /// - public BillingProfilePricesheetDownloadHeaders() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// BillingProfilePricesheetDownloadHeaders class. - /// - /// GET this URL to retrieve the status of the - /// asynchronous operation. - /// The amount of delay to use while the - /// status of the operation is checked. The value is expressed in - /// seconds. - /// To get the progress of the - /// operation, call GET operation on the URL in Azure-AsyncOperation - /// header field. - /// The operation entity Id GUID. - public BillingProfilePricesheetDownloadHeaders(string location = default(string), string retryAfter = default(string), string azureAsyncOperation = default(string), string oDataEntityId = default(string)) - { - Location = location; - RetryAfter = retryAfter; - AzureAsyncOperation = azureAsyncOperation; - ODataEntityId = oDataEntityId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets GET this URL to retrieve the status of the - /// asynchronous operation. - /// - [JsonProperty(PropertyName = "Location")] - public string Location { get; set; } - - /// - /// Gets or sets the amount of delay to use while the status of the - /// operation is checked. The value is expressed in seconds. - /// - [JsonProperty(PropertyName = "Retry-After")] - public string RetryAfter { get; set; } - - /// - /// Gets or sets to get the progress of the operation, call GET - /// operation on the URL in Azure-AsyncOperation header field. - /// - [JsonProperty(PropertyName = "Azure-AsyncOperation")] - public string AzureAsyncOperation { get; set; } - - /// - /// Gets or sets the operation entity Id GUID. - /// - [JsonProperty(PropertyName = "OData-EntityId")] - public string ODataEntityId { get; set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/LotSource.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Bound.cs similarity index 69% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/LotSource.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/Bound.cs index 0e9762ff5f07..284a4856d6e0 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/LotSource.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Bound.cs @@ -12,11 +12,11 @@ namespace Microsoft.Azure.Management.Consumption.Models { /// - /// Defines values for LotSource. + /// Defines values for Bound. /// - public static class LotSource + public static class Bound { - public const string PurchasedCredit = "PurchasedCredit"; - public const string PromotionalCredit = "PromotionalCredit"; + public const string Upper = "Upper"; + public const string Lower = "Lower"; } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Budget.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Budget.cs new file mode 100644 index 000000000000..fb09003f4ac6 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Budget.cs @@ -0,0 +1,174 @@ +// +// 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.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A budget resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class Budget : ProxyResource + { + /// + /// Initializes a new instance of the Budget class. + /// + public Budget() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Budget class. + /// + /// The category of the budget, whether the + /// budget tracks cost or usage. Possible values include: 'Cost', + /// 'Usage' + /// The total amount of cost to track with the + /// budget + /// The time covered by a budget. Tracking of + /// the amount will be reset based on the time grain. Possible values + /// include: 'Monthly', 'Quarterly', 'Annually' + /// Has start and end date of the budget. The + /// start date must be first of the month and should be less than the + /// end date. Budget start date must be on or after June 1, 2017. + /// Future start date should not be more than three months. Past start + /// date should be selected within the timegrain period. There are no + /// restrictions on the end date. + /// Resource Id. + /// Resource name. + /// Resource type. + /// eTag of the resource. To handle concurrent + /// update scenario, this field will be used to determine whether the + /// user is updating the latest version or not. + /// May be used to filter budgets by resource + /// group, resource, or meter. + /// The current amount of cost which is + /// being tracked for a budget. + /// Dictionary of notifications associated + /// with the budget. Budget can have up to five notifications. + public Budget(string category, decimal amount, string timeGrain, BudgetTimePeriod timePeriod, string id = default(string), string name = default(string), string type = default(string), string eTag = default(string), Filters filters = default(Filters), CurrentSpend currentSpend = default(CurrentSpend), IDictionary notifications = default(IDictionary)) + : base(id, name, type, eTag) + { + Category = category; + Amount = amount; + TimeGrain = timeGrain; + TimePeriod = timePeriod; + Filters = filters; + CurrentSpend = currentSpend; + Notifications = notifications; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the category of the budget, whether the budget tracks + /// cost or usage. Possible values include: 'Cost', 'Usage' + /// + [JsonProperty(PropertyName = "properties.category")] + public string Category { get; set; } + + /// + /// Gets or sets the total amount of cost to track with the budget + /// + [JsonProperty(PropertyName = "properties.amount")] + public decimal Amount { get; set; } + + /// + /// Gets or sets the time covered by a budget. Tracking of the amount + /// will be reset based on the time grain. Possible values include: + /// 'Monthly', 'Quarterly', 'Annually' + /// + [JsonProperty(PropertyName = "properties.timeGrain")] + public string TimeGrain { get; set; } + + /// + /// Gets or sets has start and end date of the budget. The start date + /// must be first of the month and should be less than the end date. + /// Budget start date must be on or after June 1, 2017. Future start + /// date should not be more than three months. Past start date should + /// be selected within the timegrain period. There are no restrictions + /// on the end date. + /// + [JsonProperty(PropertyName = "properties.timePeriod")] + public BudgetTimePeriod TimePeriod { get; set; } + + /// + /// Gets or sets may be used to filter budgets by resource group, + /// resource, or meter. + /// + [JsonProperty(PropertyName = "properties.filters")] + public Filters Filters { get; set; } + + /// + /// Gets the current amount of cost which is being tracked for a + /// budget. + /// + [JsonProperty(PropertyName = "properties.currentSpend")] + public CurrentSpend CurrentSpend { get; private set; } + + /// + /// Gets or sets dictionary of notifications associated with the + /// budget. Budget can have up to five notifications. + /// + [JsonProperty(PropertyName = "properties.notifications")] + public IDictionary Notifications { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Category == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Category"); + } + if (TimeGrain == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TimeGrain"); + } + if (TimePeriod == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TimePeriod"); + } + if (TimePeriod != null) + { + TimePeriod.Validate(); + } + if (Filters != null) + { + Filters.Validate(); + } + if (Notifications != null) + { + foreach (var valueElement in Notifications.Values) + { + if (valueElement != null) + { + valueElement.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/BudgetTimePeriod.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BudgetTimePeriod.cs new file mode 100644 index 000000000000..07497211fee5 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/BudgetTimePeriod.cs @@ -0,0 +1,71 @@ +// +// 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.Consumption.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The start and end date for a budget. + /// + public partial class BudgetTimePeriod + { + /// + /// Initializes a new instance of the BudgetTimePeriod class. + /// + public BudgetTimePeriod() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BudgetTimePeriod class. + /// + /// The start date for the budget. + /// The end date for the budget. If not provided, + /// we default this to 10 years from the start date. + public BudgetTimePeriod(System.DateTime startDate, System.DateTime? endDate = default(System.DateTime?)) + { + StartDate = startDate; + EndDate = endDate; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start date for the budget. + /// + [JsonProperty(PropertyName = "startDate")] + public System.DateTime StartDate { get; set; } + + /// + /// Gets or sets the end date for the budget. If not provided, we + /// default this to 10 years from the start date. + /// + [JsonProperty(PropertyName = "endDate")] + public System.DateTime? EndDate { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/CategoryType.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/CategoryType.cs new file mode 100644 index 000000000000..90ec91af4a81 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/CategoryType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + + /// + /// Defines values for CategoryType. + /// + public static class CategoryType + { + public const string Cost = "Cost"; + public const string Usage = "Usage"; + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummaryByInvoiceSection.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummary.cs similarity index 52% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummaryByInvoiceSection.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummary.cs index ec1eddf59ded..6c1b990582cb 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummaryByInvoiceSection.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummary.cs @@ -18,43 +18,36 @@ namespace Microsoft.Azure.Management.Consumption.Models using System.Linq; /// - /// A charge summary resource by invoiceSection. + /// A charge summary resource. /// [Rest.Serialization.JsonTransformation] - public partial class ChargeSummaryByInvoiceSection : Resource + public partial class ChargeSummary : Resource { /// - /// Initializes a new instance of the ChargeSummaryByInvoiceSection - /// class. + /// Initializes a new instance of the ChargeSummary class. /// - public ChargeSummaryByInvoiceSection() + public ChargeSummary() { CustomInit(); } /// - /// Initializes a new instance of the ChargeSummaryByInvoiceSection - /// class. + /// Initializes a new instance of the ChargeSummary class. /// /// Resource Id. /// Resource name. /// Resource type. /// Resource tags. /// The id of the billing period resource - /// that the usage belongs to. - /// Billing period start date. - /// Billing period end date. + /// that the charge belongs to. + /// Usage start date. + /// Usage end date. /// Azure Charges. /// Charges Billed /// separately. /// Marketplace Charges. - /// The id of the billing account - /// resource that the charge belongs to. - /// The id of the billing profile - /// resource that the charge belongs to. - /// The id of the invoice section - /// resource that the charge belongs to. - public ChargeSummaryByInvoiceSection(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string billingPeriodId = default(string), string usageStart = default(string), string usageEnd = default(string), Amount azureCharges = default(Amount), Amount chargesBilledSeparately = default(Amount), Amount marketplaceCharges = default(Amount), string billingAccountId = default(string), string billingProfileId = default(string), string invoiceSectionId = default(string)) + /// Currency Code + public ChargeSummary(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string billingPeriodId = default(string), string usageStart = default(string), string usageEnd = default(string), decimal? azureCharges = default(decimal?), decimal? chargesBilledSeparately = default(decimal?), decimal? marketplaceCharges = default(decimal?), string currency = default(string)) : base(id, name, type, tags) { BillingPeriodId = billingPeriodId; @@ -63,9 +56,7 @@ public ChargeSummaryByInvoiceSection() AzureCharges = azureCharges; ChargesBilledSeparately = chargesBilledSeparately; MarketplaceCharges = marketplaceCharges; - BillingAccountId = billingAccountId; - BillingProfileId = billingProfileId; - InvoiceSectionId = invoiceSectionId; + Currency = currency; CustomInit(); } @@ -75,20 +66,20 @@ public ChargeSummaryByInvoiceSection() partial void CustomInit(); /// - /// Gets the id of the billing period resource that the usage belongs + /// Gets the id of the billing period resource that the charge belongs /// to. /// [JsonProperty(PropertyName = "properties.billingPeriodId")] public string BillingPeriodId { get; private set; } /// - /// Gets billing period start date. + /// Gets usage start date. /// [JsonProperty(PropertyName = "properties.usageStart")] public string UsageStart { get; private set; } /// - /// Gets billing period end date. + /// Gets Usage end date. /// [JsonProperty(PropertyName = "properties.usageEnd")] public string UsageEnd { get; private set; } @@ -97,40 +88,25 @@ public ChargeSummaryByInvoiceSection() /// Gets azure Charges. /// [JsonProperty(PropertyName = "properties.azureCharges")] - public Amount AzureCharges { get; private set; } + public decimal? AzureCharges { get; private set; } /// /// Gets charges Billed separately. /// [JsonProperty(PropertyName = "properties.chargesBilledSeparately")] - public Amount ChargesBilledSeparately { get; private set; } + public decimal? ChargesBilledSeparately { get; private set; } /// /// Gets marketplace Charges. /// [JsonProperty(PropertyName = "properties.marketplaceCharges")] - public Amount MarketplaceCharges { get; private set; } + public decimal? MarketplaceCharges { get; private set; } /// - /// Gets the id of the billing account resource that the charge belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.billingAccountId")] - public string BillingAccountId { get; private set; } - - /// - /// Gets the id of the billing profile resource that the charge belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.billingProfileId")] - public string BillingProfileId { get; private set; } - - /// - /// Gets the id of the invoice section resource that the charge belongs - /// to. + /// Gets currency Code /// - [JsonProperty(PropertyName = "properties.invoiceSectionId")] - public string InvoiceSectionId { get; private set; } + [JsonProperty(PropertyName = "properties.currency")] + public string Currency { get; private set; } } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummaryByBillingAccount.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummaryByBillingAccount.cs deleted file mode 100644 index 41f9ef9fac77..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummaryByBillingAccount.cs +++ /dev/null @@ -1,136 +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.Consumption.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A charge summary resource by billing account. - /// - [Rest.Serialization.JsonTransformation] - public partial class ChargeSummaryByBillingAccount : Resource - { - /// - /// Initializes a new instance of the ChargeSummaryByBillingAccount - /// class. - /// - public ChargeSummaryByBillingAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ChargeSummaryByBillingAccount - /// class. - /// - /// Resource Id. - /// Resource name. - /// Resource type. - /// Resource tags. - /// The id of the billing period resource - /// that the usage belongs to. - /// Billing period start date. - /// Billing period end date. - /// Azure Charges. - /// Charges Billed - /// separately. - /// Marketplace Charges. - /// The id of the billing account - /// resource that the charge belongs to. - /// The id of the billing profile - /// resource that the charge belongs to. - /// The id of the invoice section - /// resource that the charge belongs to. - public ChargeSummaryByBillingAccount(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string billingPeriodId = default(string), string usageStart = default(string), string usageEnd = default(string), Amount azureCharges = default(Amount), Amount chargesBilledSeparately = default(Amount), Amount marketplaceCharges = default(Amount), string billingAccountId = default(string), string billingProfileId = default(string), string invoiceSectionId = default(string)) - : base(id, name, type, tags) - { - BillingPeriodId = billingPeriodId; - UsageStart = usageStart; - UsageEnd = usageEnd; - AzureCharges = azureCharges; - ChargesBilledSeparately = chargesBilledSeparately; - MarketplaceCharges = marketplaceCharges; - BillingAccountId = billingAccountId; - BillingProfileId = billingProfileId; - InvoiceSectionId = invoiceSectionId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the id of the billing period resource that the usage belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.billingPeriodId")] - public string BillingPeriodId { get; private set; } - - /// - /// Gets billing period start date. - /// - [JsonProperty(PropertyName = "properties.usageStart")] - public string UsageStart { get; private set; } - - /// - /// Gets billing period end date. - /// - [JsonProperty(PropertyName = "properties.usageEnd")] - public string UsageEnd { get; private set; } - - /// - /// Gets azure Charges. - /// - [JsonProperty(PropertyName = "properties.azureCharges")] - public Amount AzureCharges { get; private set; } - - /// - /// Gets charges Billed separately. - /// - [JsonProperty(PropertyName = "properties.chargesBilledSeparately")] - public Amount ChargesBilledSeparately { get; private set; } - - /// - /// Gets marketplace Charges. - /// - [JsonProperty(PropertyName = "properties.marketplaceCharges")] - public Amount MarketplaceCharges { get; private set; } - - /// - /// Gets the id of the billing account resource that the charge belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.billingAccountId")] - public string BillingAccountId { get; private set; } - - /// - /// Gets the id of the billing profile resource that the charge belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.billingProfileId")] - public string BillingProfileId { get; private set; } - - /// - /// Gets the id of the invoice section resource that the charge belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.invoiceSectionId")] - public string InvoiceSectionId { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummaryByBillingProfile.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummaryByBillingProfile.cs deleted file mode 100644 index 0cacb54090ad..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeSummaryByBillingProfile.cs +++ /dev/null @@ -1,136 +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.Consumption.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A charge summary resource by billing profile. - /// - [Rest.Serialization.JsonTransformation] - public partial class ChargeSummaryByBillingProfile : Resource - { - /// - /// Initializes a new instance of the ChargeSummaryByBillingProfile - /// class. - /// - public ChargeSummaryByBillingProfile() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ChargeSummaryByBillingProfile - /// class. - /// - /// Resource Id. - /// Resource name. - /// Resource type. - /// Resource tags. - /// The id of the billing period resource - /// that the usage belongs to. - /// Billing period start date. - /// Billing period end date. - /// Azure Charges. - /// Charges Billed - /// separately. - /// Marketplace Charges. - /// The id of the billing account - /// resource that the charge belongs to. - /// The id of the billing profile - /// resource that the charge belongs to. - /// The id of the invoice section - /// resource that the charge belongs to. - public ChargeSummaryByBillingProfile(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string billingPeriodId = default(string), string usageStart = default(string), string usageEnd = default(string), Amount azureCharges = default(Amount), Amount chargesBilledSeparately = default(Amount), Amount marketplaceCharges = default(Amount), string billingAccountId = default(string), string billingProfileId = default(string), string invoiceSectionId = default(string)) - : base(id, name, type, tags) - { - BillingPeriodId = billingPeriodId; - UsageStart = usageStart; - UsageEnd = usageEnd; - AzureCharges = azureCharges; - ChargesBilledSeparately = chargesBilledSeparately; - MarketplaceCharges = marketplaceCharges; - BillingAccountId = billingAccountId; - BillingProfileId = billingProfileId; - InvoiceSectionId = invoiceSectionId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the id of the billing period resource that the usage belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.billingPeriodId")] - public string BillingPeriodId { get; private set; } - - /// - /// Gets billing period start date. - /// - [JsonProperty(PropertyName = "properties.usageStart")] - public string UsageStart { get; private set; } - - /// - /// Gets billing period end date. - /// - [JsonProperty(PropertyName = "properties.usageEnd")] - public string UsageEnd { get; private set; } - - /// - /// Gets azure Charges. - /// - [JsonProperty(PropertyName = "properties.azureCharges")] - public Amount AzureCharges { get; private set; } - - /// - /// Gets charges Billed separately. - /// - [JsonProperty(PropertyName = "properties.chargesBilledSeparately")] - public Amount ChargesBilledSeparately { get; private set; } - - /// - /// Gets marketplace Charges. - /// - [JsonProperty(PropertyName = "properties.marketplaceCharges")] - public Amount MarketplaceCharges { get; private set; } - - /// - /// Gets the id of the billing account resource that the charge belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.billingAccountId")] - public string BillingAccountId { get; private set; } - - /// - /// Gets the id of the billing profile resource that the charge belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.billingProfileId")] - public string BillingProfileId { get; private set; } - - /// - /// Gets the id of the invoice section resource that the charge belongs - /// to. - /// - [JsonProperty(PropertyName = "properties.invoiceSectionId")] - public string InvoiceSectionId { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeType.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeType.cs new file mode 100644 index 000000000000..8c2a453cb0be --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargeType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + + /// + /// Defines values for ChargeType. + /// + public static class ChargeType + { + public const string Actual = "Actual"; + public const string Forecast = "Forecast"; + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListByBillingAccount.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListByBillingAccount.cs deleted file mode 100644 index f8cf97f2cfb6..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListByBillingAccount.cs +++ /dev/null @@ -1,58 +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.Consumption.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Result of listing charge summary by billing account. It contains a list - /// of available change summaries in reverse chronological order by billing - /// period. - /// - public partial class ChargesListByBillingAccount - { - /// - /// Initializes a new instance of the ChargesListByBillingAccount - /// class. - /// - public ChargesListByBillingAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ChargesListByBillingAccount - /// class. - /// - /// The list of charge summary by billing - /// account. - public ChargesListByBillingAccount(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of charge summary by billing account. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListByBillingProfile.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListByBillingProfile.cs deleted file mode 100644 index cf8b27d1d321..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListByBillingProfile.cs +++ /dev/null @@ -1,58 +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.Consumption.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Result of listing charge summary by billing profile. It contains a list - /// of available change summaries in reverse chronological order by billing - /// period. - /// - public partial class ChargesListByBillingProfile - { - /// - /// Initializes a new instance of the ChargesListByBillingProfile - /// class. - /// - public ChargesListByBillingProfile() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ChargesListByBillingProfile - /// class. - /// - /// The list of charge summary by billing - /// profile. - public ChargesListByBillingProfile(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of charge summary by billing profile. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Events.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListResult.cs similarity index 66% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/Events.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListResult.cs index 8c4d90434ee2..20742faade5f 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Events.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ChargesListResult.cs @@ -16,23 +16,23 @@ namespace Microsoft.Azure.Management.Consumption.Models using System.Linq; /// - /// Result of listing event summary. + /// Result of listing charge summary. /// - public partial class Events + public partial class ChargesListResult { /// - /// Initializes a new instance of the Events class. + /// Initializes a new instance of the ChargesListResult class. /// - public Events() + public ChargesListResult() { CustomInit(); } /// - /// Initializes a new instance of the Events class. + /// Initializes a new instance of the ChargesListResult class. /// - /// The list of event summary. - public Events(IList value = default(IList)) + /// The list of charge summary + public ChargesListResult(IList value = default(IList)) { Value = value; CustomInit(); @@ -44,10 +44,10 @@ public Events() partial void CustomInit(); /// - /// Gets the list of event summary. + /// Gets the list of charge summary /// [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } + public IList Value { get; private set; } } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/CreditBalanceSummary.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/CreditBalanceSummary.cs deleted file mode 100644 index 917c716f3a3d..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/CreditBalanceSummary.cs +++ /dev/null @@ -1,59 +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.Consumption.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Summary of credit balances. - /// - public partial class CreditBalanceSummary - { - /// - /// Initializes a new instance of the CreditBalanceSummary class. - /// - public CreditBalanceSummary() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CreditBalanceSummary class. - /// - /// Estimated balance. - /// Current balance. - public CreditBalanceSummary(Amount estimatedBalance = default(Amount), Amount currentBalance = default(Amount)) - { - EstimatedBalance = estimatedBalance; - CurrentBalance = currentBalance; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets estimated balance. - /// - [JsonProperty(PropertyName = "estimatedBalance")] - public Amount EstimatedBalance { get; private set; } - - /// - /// Gets current balance. - /// - [JsonProperty(PropertyName = "currentBalance")] - public Amount CurrentBalance { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/CreditSummary.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/CreditSummary.cs deleted file mode 100644 index 81a34ee77404..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/CreditSummary.cs +++ /dev/null @@ -1,89 +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.Consumption.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A credit summary resource. - /// - [Rest.Serialization.JsonTransformation] - public partial class CreditSummary : Resource - { - /// - /// Initializes a new instance of the CreditSummary class. - /// - public CreditSummary() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CreditSummary class. - /// - /// Resource Id. - /// Resource name. - /// Resource type. - /// Resource tags. - /// Summary of balances associated with - /// this credit summary. - /// Pending Credit - /// Adjustments. - /// Expired Credit. - /// Pending Eligible - /// Charges. - public CreditSummary(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), CreditBalanceSummary balanceSummary = default(CreditBalanceSummary), Amount pendingCreditAdjustments = default(Amount), Amount expiredCredit = default(Amount), Amount pendingEligibleCharges = default(Amount)) - : base(id, name, type, tags) - { - BalanceSummary = balanceSummary; - PendingCreditAdjustments = pendingCreditAdjustments; - ExpiredCredit = expiredCredit; - PendingEligibleCharges = pendingEligibleCharges; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets summary of balances associated with this credit - /// summary. - /// - [JsonProperty(PropertyName = "properties.balanceSummary")] - public CreditBalanceSummary BalanceSummary { get; set; } - - /// - /// Gets pending Credit Adjustments. - /// - [JsonProperty(PropertyName = "properties.pendingCreditAdjustments")] - public Amount PendingCreditAdjustments { get; private set; } - - /// - /// Gets expired Credit. - /// - [JsonProperty(PropertyName = "properties.expiredCredit")] - public Amount ExpiredCredit { get; private set; } - - /// - /// Gets pending Eligible Charges. - /// - [JsonProperty(PropertyName = "properties.pendingEligibleCharges")] - public Amount PendingEligibleCharges { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/CurrentSpend.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/CurrentSpend.cs new file mode 100644 index 000000000000..812dc4168539 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/CurrentSpend.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.Consumption.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The current amount of cost which is being tracked for a budget. + /// + public partial class CurrentSpend + { + /// + /// Initializes a new instance of the CurrentSpend class. + /// + public CurrentSpend() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CurrentSpend class. + /// + /// The total amount of cost which is being + /// tracked by the budget. + /// The unit of measure for the budget + /// amount. + public CurrentSpend(decimal? amount = default(decimal?), string unit = default(string)) + { + Amount = amount; + Unit = unit; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the total amount of cost which is being tracked by the budget. + /// + [JsonProperty(PropertyName = "amount")] + public decimal? Amount { get; private set; } + + /// + /// Gets the unit of measure for the budget amount. + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Datagrain.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Datagrain.cs new file mode 100644 index 000000000000..13b043b8f862 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Datagrain.cs @@ -0,0 +1,28 @@ +// +// 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.Consumption.Models +{ + + /// + /// Defines values for Datagrain. + /// + public static class Datagrain + { + /// + /// Daily grain of data + /// + public const string DailyGrain = "daily"; + /// + /// Monthly grain of data + /// + public const string MonthlyGrain = "monthly"; + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Department.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Department.cs deleted file mode 100644 index d60d8dfc033a..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Department.cs +++ /dev/null @@ -1,88 +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.Consumption.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A department resource. - /// - [Rest.Serialization.JsonTransformation] - public partial class Department : Resource - { - /// - /// Initializes a new instance of the Department class. - /// - public Department() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Department class. - /// - /// Resource Id. - /// Resource name. - /// Resource type. - /// Resource tags. - /// The name for department. - /// The cost center name. - /// The status for department. - /// Associated enrollment accounts. By - /// default this is not populated, unless it's specified in - /// $expand. - public Department(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string departmentName = default(string), string costCenter = default(string), string status = default(string), IList enrollmentAccounts = default(IList)) - : base(id, name, type, tags) - { - DepartmentName = departmentName; - CostCenter = costCenter; - Status = status; - EnrollmentAccounts = enrollmentAccounts; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name for department. - /// - [JsonProperty(PropertyName = "properties.departmentName")] - public string DepartmentName { get; set; } - - /// - /// Gets or sets the cost center name. - /// - [JsonProperty(PropertyName = "properties.costCenter")] - public string CostCenter { get; set; } - - /// - /// Gets or sets the status for department. - /// - [JsonProperty(PropertyName = "properties.status")] - public string Status { get; set; } - - /// - /// Gets or sets associated enrollment accounts. By default this is not - /// populated, unless it's specified in $expand. - /// - [JsonProperty(PropertyName = "properties.enrollmentAccounts")] - public IList EnrollmentAccounts { get; set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Enrollment.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Enrollment.cs deleted file mode 100644 index 5a8be6f0e896..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Enrollment.cs +++ /dev/null @@ -1,117 +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.Consumption.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Current entity level details - /// - public partial class Enrollment - { - /// - /// Initializes a new instance of the Enrollment class. - /// - public Enrollment() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Enrollment class. - /// - /// Enrollment Start Date - /// Enrollment End Date - /// The currency associated with - /// enrollment - /// The channel for Enrollment - /// The attributes associated with legacy - /// enrollment. - /// The language for Enrollment - /// The countryCode for Enrollment - /// Enrollment status - /// Enrollment billing cycle - public Enrollment(System.DateTime? startDate = default(System.DateTime?), System.DateTime? endDate = default(System.DateTime?), string currency = default(string), string channel = default(string), EnrollmentPolicies policies = default(EnrollmentPolicies), string language = default(string), string countryCode = default(string), string status = default(string), string billingCylce = default(string)) - { - StartDate = startDate; - EndDate = endDate; - Currency = currency; - Channel = channel; - Policies = policies; - Language = language; - CountryCode = countryCode; - Status = status; - BillingCylce = billingCylce; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets enrollment Start Date - /// - [JsonProperty(PropertyName = "startDate")] - public System.DateTime? StartDate { get; private set; } - - /// - /// Gets enrollment End Date - /// - [JsonProperty(PropertyName = "endDate")] - public System.DateTime? EndDate { get; private set; } - - /// - /// Gets the currency associated with enrollment - /// - [JsonProperty(PropertyName = "currency")] - public string Currency { get; private set; } - - /// - /// Gets the channel for Enrollment - /// - [JsonProperty(PropertyName = "channel")] - public string Channel { get; private set; } - - /// - /// Gets the attributes associated with legacy enrollment. - /// - [JsonProperty(PropertyName = "policies")] - public EnrollmentPolicies Policies { get; private set; } - - /// - /// Gets the language for Enrollment - /// - [JsonProperty(PropertyName = "language")] - public string Language { get; private set; } - - /// - /// Gets the countryCode for Enrollment - /// - [JsonProperty(PropertyName = "countryCode")] - public string CountryCode { get; private set; } - - /// - /// Gets enrollment status - /// - [JsonProperty(PropertyName = "status")] - public string Status { get; private set; } - - /// - /// Gets enrollment billing cycle - /// - [JsonProperty(PropertyName = "billingCylce")] - public string BillingCylce { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/EnrollmentAccount.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/EnrollmentAccount.cs deleted file mode 100644 index d175865f793d..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/EnrollmentAccount.cs +++ /dev/null @@ -1,111 +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.Consumption.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// An account resource. - /// - [Rest.Serialization.JsonTransformation] - public partial class EnrollmentAccount : Resource - { - /// - /// Initializes a new instance of the EnrollmentAccount class. - /// - public EnrollmentAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EnrollmentAccount class. - /// - /// Resource Id. - /// Resource name. - /// Resource type. - /// Resource tags. - /// The account name. - /// The cost center name. - /// The account owner - /// The status for account. - /// Account Start Date - /// Account End Date - /// Associated department. By default this is - /// not populated, unless it's specified in $expand. - public EnrollmentAccount(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string accountName = default(string), string costCenter = default(string), string accountOwner = default(string), string status = default(string), System.DateTime? startDate = default(System.DateTime?), System.DateTime? endDate = default(System.DateTime?), Department department = default(Department)) - : base(id, name, type, tags) - { - AccountName = accountName; - CostCenter = costCenter; - AccountOwner = accountOwner; - Status = status; - StartDate = startDate; - EndDate = endDate; - Department = department; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the account name. - /// - [JsonProperty(PropertyName = "properties.accountName")] - public string AccountName { get; set; } - - /// - /// Gets or sets the cost center name. - /// - [JsonProperty(PropertyName = "properties.costCenter")] - public string CostCenter { get; set; } - - /// - /// Gets or sets the account owner - /// - [JsonProperty(PropertyName = "properties.accountOwner")] - public string AccountOwner { get; set; } - - /// - /// Gets or sets the status for account. - /// - [JsonProperty(PropertyName = "properties.status")] - public string Status { get; set; } - - /// - /// Gets or sets account Start Date - /// - [JsonProperty(PropertyName = "properties.startDate")] - public System.DateTime? StartDate { get; set; } - - /// - /// Gets or sets account End Date - /// - [JsonProperty(PropertyName = "properties.endDate")] - public System.DateTime? EndDate { get; set; } - - /// - /// Gets or sets associated department. By default this is not - /// populated, unless it's specified in $expand. - /// - [JsonProperty(PropertyName = "properties.department")] - public Department Department { get; set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/EnrollmentPolicies.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/EnrollmentPolicies.cs deleted file mode 100644 index 414b7a2d3c2e..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/EnrollmentPolicies.cs +++ /dev/null @@ -1,79 +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.Consumption.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The attributes associated with legacy enrollment - /// - public partial class EnrollmentPolicies - { - /// - /// Initializes a new instance of the EnrollmentPolicies class. - /// - public EnrollmentPolicies() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EnrollmentPolicies class. - /// - /// The accountOwnerViewCharges - /// flag for Enrollment - /// The - /// departmentAdminViewCharges flag for Enrollment - /// The marketplaces flag for - /// Enrollment - /// The reserved instances flag - /// for Enrollment - public EnrollmentPolicies(bool? accountOwnerViewCharges = default(bool?), bool? departmentAdminViewCharges = default(bool?), bool? marketplacesEnabled = default(bool?), bool? reservedInstancesEnabled = default(bool?)) - { - AccountOwnerViewCharges = accountOwnerViewCharges; - DepartmentAdminViewCharges = departmentAdminViewCharges; - MarketplacesEnabled = marketplacesEnabled; - ReservedInstancesEnabled = reservedInstancesEnabled; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the accountOwnerViewCharges flag for Enrollment - /// - [JsonProperty(PropertyName = "accountOwnerViewCharges")] - public bool? AccountOwnerViewCharges { get; private set; } - - /// - /// Gets the departmentAdminViewCharges flag for Enrollment - /// - [JsonProperty(PropertyName = "departmentAdminViewCharges")] - public bool? DepartmentAdminViewCharges { get; private set; } - - /// - /// Gets the marketplaces flag for Enrollment - /// - [JsonProperty(PropertyName = "marketplacesEnabled")] - public bool? MarketplacesEnabled { get; private set; } - - /// - /// Gets the reserved instances flag for Enrollment - /// - [JsonProperty(PropertyName = "reservedInstancesEnabled")] - public bool? ReservedInstancesEnabled { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/EventSummary.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/EventSummary.cs deleted file mode 100644 index 17d468a4d2fb..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/EventSummary.cs +++ /dev/null @@ -1,127 +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.Consumption.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// An event summary resource. - /// - [Rest.Serialization.JsonTransformation] - public partial class EventSummary : Resource - { - /// - /// Initializes a new instance of the EventSummary class. - /// - public EventSummary() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EventSummary class. - /// - /// Resource Id. - /// Resource name. - /// Resource type. - /// Resource tags. - /// Transaction Date. - /// Transaction description. - /// New Credit. - /// Credit Adjustments. - /// Credit Expired. - /// Credit Eligible Charges. - /// Closed Balance. - /// The type of event. Possible values include: - /// 'NewCredit', 'ExpiredCredit', 'SettledCharges' - /// Invoice Number. - public EventSummary(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), System.DateTime? transactionDate = default(System.DateTime?), string description = default(string), Amount newCredit = default(Amount), Amount adjustments = default(Amount), Amount creditExpired = default(Amount), Amount charges = default(Amount), Amount closedBalance = default(Amount), string eventType = default(string), string invoiceNumber = default(string)) - : base(id, name, type, tags) - { - TransactionDate = transactionDate; - Description = description; - NewCredit = newCredit; - Adjustments = adjustments; - CreditExpired = creditExpired; - Charges = charges; - ClosedBalance = closedBalance; - EventType = eventType; - InvoiceNumber = invoiceNumber; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets transaction Date. - /// - [JsonProperty(PropertyName = "properties.transactionDate")] - public System.DateTime? TransactionDate { get; private set; } - - /// - /// Gets transaction description. - /// - [JsonProperty(PropertyName = "properties.description")] - public string Description { get; private set; } - - /// - /// Gets new Credit. - /// - [JsonProperty(PropertyName = "properties.newCredit")] - public Amount NewCredit { get; private set; } - - /// - /// Gets credit Adjustments. - /// - [JsonProperty(PropertyName = "properties.adjustments")] - public Amount Adjustments { get; private set; } - - /// - /// Gets credit Expired. - /// - [JsonProperty(PropertyName = "properties.creditExpired")] - public Amount CreditExpired { get; private set; } - - /// - /// Gets credit Eligible Charges. - /// - [JsonProperty(PropertyName = "properties.charges")] - public Amount Charges { get; private set; } - - /// - /// Gets closed Balance. - /// - [JsonProperty(PropertyName = "properties.closedBalance")] - public Amount ClosedBalance { get; private set; } - - /// - /// Gets or sets the type of event. Possible values include: - /// 'NewCredit', 'ExpiredCredit', 'SettledCharges' - /// - [JsonProperty(PropertyName = "properties.eventType")] - public string EventType { get; set; } - - /// - /// Gets invoice Number. - /// - [JsonProperty(PropertyName = "properties.invoiceNumber")] - public string InvoiceNumber { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Filters.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Filters.cs new file mode 100644 index 000000000000..aac9c62be1ec --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Filters.cs @@ -0,0 +1,124 @@ +// +// 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.Consumption.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// May be used to filter budgets by resource group, resource, or meter. + /// + public partial class Filters + { + /// + /// Initializes a new instance of the Filters class. + /// + public Filters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Filters class. + /// + /// The list of filters on resource + /// groups, allowed at subscription level only. + /// The list of filters on resources. + /// The list of filters on meters (GUID), + /// mandatory for budgets of usage category. + /// The dictionary of filters on tags. + public Filters(IList resourceGroups = default(IList), IList resources = default(IList), IList meters = default(IList), IDictionary> tags = default(IDictionary>)) + { + ResourceGroups = resourceGroups; + Resources = resources; + Meters = meters; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of filters on resource groups, allowed at + /// subscription level only. + /// + [JsonProperty(PropertyName = "resourceGroups")] + public IList ResourceGroups { get; set; } + + /// + /// Gets or sets the list of filters on resources. + /// + [JsonProperty(PropertyName = "resources")] + public IList Resources { get; set; } + + /// + /// Gets or sets the list of filters on meters (GUID), mandatory for + /// budgets of usage category. + /// + [JsonProperty(PropertyName = "meters")] + public IList Meters { get; set; } + + /// + /// Gets or sets the dictionary of filters on tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary> Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ResourceGroups != null) + { + if (ResourceGroups.Count > 10) + { + throw new ValidationException(ValidationRules.MaxItems, "ResourceGroups", 10); + } + if (ResourceGroups.Count < 0) + { + throw new ValidationException(ValidationRules.MinItems, "ResourceGroups", 0); + } + } + if (Resources != null) + { + if (Resources.Count > 10) + { + throw new ValidationException(ValidationRules.MaxItems, "Resources", 10); + } + if (Resources.Count < 0) + { + throw new ValidationException(ValidationRules.MinItems, "Resources", 0); + } + } + if (Meters != null) + { + if (Meters.Count > 10) + { + throw new ValidationException(ValidationRules.MaxItems, "Meters", 10); + } + if (Meters.Count < 0) + { + throw new ValidationException(ValidationRules.MinItems, "Meters", 0); + } + } + } + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Forecast.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Forecast.cs new file mode 100644 index 000000000000..d6b13b42b0dc --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Forecast.cs @@ -0,0 +1,110 @@ +// +// 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.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A forecast resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class Forecast : Resource + { + /// + /// Initializes a new instance of the Forecast class. + /// + public Forecast() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Forecast class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + /// The usage date of the forecast. + /// The granularity of forecast. Possible values + /// include: 'Daily', 'Monthly', 'Yearly' + /// The amount of charge + /// The ISO currency in which the meter is + /// charged, for example, USD. + /// The type of the charge. Could be actual or + /// forecast. Possible values include: 'Actual', 'Forecast' + /// The details about the forecast + /// confidence levels. This is populated only when chargeType is + /// Forecast. + public Forecast(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string usageDate = default(string), string grain = default(string), decimal? charge = default(decimal?), string currency = default(string), string chargeType = default(string), IList confidenceLevels = default(IList)) + : base(id, name, type, tags) + { + UsageDate = usageDate; + Grain = grain; + Charge = charge; + Currency = currency; + ChargeType = chargeType; + ConfidenceLevels = confidenceLevels; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the usage date of the forecast. + /// + [JsonProperty(PropertyName = "properties.usageDate")] + public string UsageDate { get; private set; } + + /// + /// Gets or sets the granularity of forecast. Possible values include: + /// 'Daily', 'Monthly', 'Yearly' + /// + [JsonProperty(PropertyName = "properties.grain")] + public string Grain { get; set; } + + /// + /// Gets the amount of charge + /// + [JsonProperty(PropertyName = "properties.charge")] + public decimal? Charge { get; private set; } + + /// + /// Gets the ISO currency in which the meter is charged, for example, + /// USD. + /// + [JsonProperty(PropertyName = "properties.currency")] + public string Currency { get; private set; } + + /// + /// Gets or sets the type of the charge. Could be actual or forecast. + /// Possible values include: 'Actual', 'Forecast' + /// + [JsonProperty(PropertyName = "properties.chargeType")] + public string ChargeType { get; set; } + + /// + /// Gets the details about the forecast confidence levels. This is + /// populated only when chargeType is Forecast. + /// + [JsonProperty(PropertyName = "properties.confidenceLevels")] + public IList ConfidenceLevels { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ForecastPropertiesConfidenceLevelsItem.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ForecastPropertiesConfidenceLevelsItem.cs new file mode 100644 index 000000000000..3f020ff52b8a --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ForecastPropertiesConfidenceLevelsItem.cs @@ -0,0 +1,71 @@ +// +// 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.Consumption.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ForecastPropertiesConfidenceLevelsItem + { + /// + /// Initializes a new instance of the + /// ForecastPropertiesConfidenceLevelsItem class. + /// + public ForecastPropertiesConfidenceLevelsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ForecastPropertiesConfidenceLevelsItem class. + /// + /// The percentage level of the + /// confidence + /// The boundary of the percentage, values could be + /// 'Upper' or 'Lower'. Possible values include: 'Upper', + /// 'Lower' + /// The amount of forecast within the percentage + /// level + public ForecastPropertiesConfidenceLevelsItem(decimal? percentage = default(decimal?), string bound = default(string), decimal? value = default(decimal?)) + { + Percentage = percentage; + Bound = bound; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the percentage level of the confidence + /// + [JsonProperty(PropertyName = "percentage")] + public decimal? Percentage { get; private set; } + + /// + /// Gets or sets the boundary of the percentage, values could be + /// 'Upper' or 'Lower'. Possible values include: 'Upper', 'Lower' + /// + [JsonProperty(PropertyName = "bound")] + public string Bound { get; set; } + + /// + /// Gets the amount of forecast within the percentage level + /// + [JsonProperty(PropertyName = "value")] + public decimal? Value { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Grain.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Grain.cs new file mode 100644 index 000000000000..67fe8ed62673 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Grain.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + + /// + /// Defines values for Grain. + /// + public static class Grain + { + public const string Daily = "Daily"; + public const string Monthly = "Monthly"; + public const string Yearly = "Yearly"; + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/LotSummary.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/LotSummary.cs deleted file mode 100644 index eab58dd8d393..000000000000 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/LotSummary.cs +++ /dev/null @@ -1,103 +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.Consumption.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A lot summary resource. - /// - [Rest.Serialization.JsonTransformation] - public partial class LotSummary : Resource - { - /// - /// Initializes a new instance of the LotSummary class. - /// - public LotSummary() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the LotSummary class. - /// - /// Resource Id. - /// Resource name. - /// Resource type. - /// Resource tags. - /// Original Amount. - /// Closed Balance. - /// Lot source. Possible values include: - /// 'PurchasedCredit', 'PromotionalCredit' - /// Start Date. - /// Expiration Date. - /// PO Number. - public LotSummary(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), Amount originalAmount = default(Amount), Amount closedBalance = default(Amount), string source = default(string), System.DateTime? startDate = default(System.DateTime?), System.DateTime? expirationDate = default(System.DateTime?), string poNumber = default(string)) - : base(id, name, type, tags) - { - OriginalAmount = originalAmount; - ClosedBalance = closedBalance; - Source = source; - StartDate = startDate; - ExpirationDate = expirationDate; - PoNumber = poNumber; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets original Amount. - /// - [JsonProperty(PropertyName = "properties.originalAmount")] - public Amount OriginalAmount { get; private set; } - - /// - /// Gets closed Balance. - /// - [JsonProperty(PropertyName = "properties.closedBalance")] - public Amount ClosedBalance { get; private set; } - - /// - /// Gets lot source. Possible values include: 'PurchasedCredit', - /// 'PromotionalCredit' - /// - [JsonProperty(PropertyName = "properties.source")] - public string Source { get; private set; } - - /// - /// Gets start Date. - /// - [JsonProperty(PropertyName = "properties.startDate")] - public System.DateTime? StartDate { get; private set; } - - /// - /// Gets expiration Date. - /// - [JsonProperty(PropertyName = "properties.expirationDate")] - public System.DateTime? ExpirationDate { get; private set; } - - /// - /// Gets PO Number. - /// - [JsonProperty(PropertyName = "properties.poNumber")] - public string PoNumber { get; private set; } - - } -} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ManagementGroupAggregatedCostResult.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ManagementGroupAggregatedCostResult.cs new file mode 100644 index 000000000000..2608ac234d8b --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ManagementGroupAggregatedCostResult.cs @@ -0,0 +1,146 @@ +// +// 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.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A management group aggregated cost resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class ManagementGroupAggregatedCostResult : Resource + { + /// + /// Initializes a new instance of the + /// ManagementGroupAggregatedCostResult class. + /// + public ManagementGroupAggregatedCostResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ManagementGroupAggregatedCostResult class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + /// The id of the billing period resource + /// that the aggregated cost belongs to. + /// The start of the date time range covered + /// by aggregated cost. + /// The end of the date time range covered by + /// the aggregated cost. + /// Azure Charges. + /// Marketplace Charges. + /// Charges Billed + /// Separately. + /// The ISO currency in which the meter is + /// charged, for example, USD. + /// Children of a management group + /// List of subscription Guids + /// included in the calculation of aggregated cost + /// List of subscription Guids + /// excluded from the calculation of aggregated cost + public ManagementGroupAggregatedCostResult(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string billingPeriodId = default(string), System.DateTime? usageStart = default(System.DateTime?), System.DateTime? usageEnd = default(System.DateTime?), decimal? azureCharges = default(decimal?), decimal? marketplaceCharges = default(decimal?), decimal? chargesBilledSeparately = default(decimal?), string currency = default(string), IList children = default(IList), IList includedSubscriptions = default(IList), IList excludedSubscriptions = default(IList)) + : base(id, name, type, tags) + { + BillingPeriodId = billingPeriodId; + UsageStart = usageStart; + UsageEnd = usageEnd; + AzureCharges = azureCharges; + MarketplaceCharges = marketplaceCharges; + ChargesBilledSeparately = chargesBilledSeparately; + Currency = currency; + Children = children; + IncludedSubscriptions = includedSubscriptions; + ExcludedSubscriptions = excludedSubscriptions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the id of the billing period resource that the aggregated cost + /// belongs to. + /// + [JsonProperty(PropertyName = "properties.billingPeriodId")] + public string BillingPeriodId { get; private set; } + + /// + /// Gets the start of the date time range covered by aggregated cost. + /// + [JsonProperty(PropertyName = "properties.usageStart")] + public System.DateTime? UsageStart { get; private set; } + + /// + /// Gets the end of the date time range covered by the aggregated cost. + /// + [JsonProperty(PropertyName = "properties.usageEnd")] + public System.DateTime? UsageEnd { get; private set; } + + /// + /// Gets azure Charges. + /// + [JsonProperty(PropertyName = "properties.azureCharges")] + public decimal? AzureCharges { get; private set; } + + /// + /// Gets marketplace Charges. + /// + [JsonProperty(PropertyName = "properties.marketplaceCharges")] + public decimal? MarketplaceCharges { get; private set; } + + /// + /// Gets charges Billed Separately. + /// + [JsonProperty(PropertyName = "properties.chargesBilledSeparately")] + public decimal? ChargesBilledSeparately { get; private set; } + + /// + /// Gets the ISO currency in which the meter is charged, for example, + /// USD. + /// + [JsonProperty(PropertyName = "properties.currency")] + public string Currency { get; private set; } + + /// + /// Gets or sets children of a management group + /// + [JsonProperty(PropertyName = "properties.children")] + public IList Children { get; set; } + + /// + /// Gets or sets list of subscription Guids included in the calculation + /// of aggregated cost + /// + [JsonProperty(PropertyName = "properties.includedSubscriptions")] + public IList IncludedSubscriptions { get; set; } + + /// + /// Gets or sets list of subscription Guids excluded from the + /// calculation of aggregated cost + /// + [JsonProperty(PropertyName = "properties.excludedSubscriptions")] + public IList ExcludedSubscriptions { get; set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Marketplace.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Marketplace.cs new file mode 100644 index 000000000000..3ad1b5295df0 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Marketplace.cs @@ -0,0 +1,268 @@ +// +// 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.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An marketplace resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class Marketplace : Resource + { + /// + /// Initializes a new instance of the Marketplace class. + /// + public Marketplace() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Marketplace class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + /// The id of the billing period resource + /// that the usage belongs to. + /// The start of the date time range covered + /// by the usage detail. + /// The end of the date time range covered by + /// the usage detail. + /// The marketplace resource rate. + /// The type of offer. + /// The name of resource group. + /// The order number. + /// The name of the resource instance that + /// the usage is about. + /// The uri of the resource instance that the + /// usage is about. + /// The ISO currency in which the meter is + /// charged, for example, USD. + /// The quantity of usage. + /// The unit of measure. + /// The amount of cost before tax. + /// The estimated usage is subject to + /// change. + /// The meter id (GUID). + /// Subscription guid. + /// Subscription name. + /// Account name. + /// Department name. + /// Consumed service name. + /// The cost center of this department if it + /// is a department and a costcenter exists + /// Additional details of this usage + /// item. By default this is not populated, unless it's specified in + /// $expand. + /// The name of publisher. + /// The name of plan. + /// Flag indicating whether this is a + /// recurring charge or not. + public Marketplace(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string billingPeriodId = default(string), System.DateTime? usageStart = default(System.DateTime?), System.DateTime? usageEnd = default(System.DateTime?), decimal? resourceRate = default(decimal?), string offerName = default(string), string resourceGroup = default(string), string orderNumber = default(string), string instanceName = default(string), string instanceId = default(string), string currency = default(string), decimal? consumedQuantity = default(decimal?), string unitOfMeasure = default(string), decimal? pretaxCost = default(decimal?), bool? isEstimated = default(bool?), System.Guid? meterId = default(System.Guid?), System.Guid? subscriptionGuid = default(System.Guid?), string subscriptionName = default(string), string accountName = default(string), string departmentName = default(string), string consumedService = default(string), string costCenter = default(string), string additionalProperties = default(string), string publisherName = default(string), string planName = default(string), bool? isRecurringCharge = default(bool?)) + : base(id, name, type, tags) + { + BillingPeriodId = billingPeriodId; + UsageStart = usageStart; + UsageEnd = usageEnd; + ResourceRate = resourceRate; + OfferName = offerName; + ResourceGroup = resourceGroup; + OrderNumber = orderNumber; + InstanceName = instanceName; + InstanceId = instanceId; + Currency = currency; + ConsumedQuantity = consumedQuantity; + UnitOfMeasure = unitOfMeasure; + PretaxCost = pretaxCost; + IsEstimated = isEstimated; + MeterId = meterId; + SubscriptionGuid = subscriptionGuid; + SubscriptionName = subscriptionName; + AccountName = accountName; + DepartmentName = departmentName; + ConsumedService = consumedService; + CostCenter = costCenter; + AdditionalProperties = additionalProperties; + PublisherName = publisherName; + PlanName = planName; + IsRecurringCharge = isRecurringCharge; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the id of the billing period resource that the usage belongs + /// to. + /// + [JsonProperty(PropertyName = "properties.billingPeriodId")] + public string BillingPeriodId { get; private set; } + + /// + /// Gets the start of the date time range covered by the usage detail. + /// + [JsonProperty(PropertyName = "properties.usageStart")] + public System.DateTime? UsageStart { get; private set; } + + /// + /// Gets the end of the date time range covered by the usage detail. + /// + [JsonProperty(PropertyName = "properties.usageEnd")] + public System.DateTime? UsageEnd { get; private set; } + + /// + /// Gets the marketplace resource rate. + /// + [JsonProperty(PropertyName = "properties.resourceRate")] + public decimal? ResourceRate { get; private set; } + + /// + /// Gets the type of offer. + /// + [JsonProperty(PropertyName = "properties.offerName")] + public string OfferName { get; private set; } + + /// + /// Gets the name of resource group. + /// + [JsonProperty(PropertyName = "properties.resourceGroup")] + public string ResourceGroup { get; private set; } + + /// + /// Gets the order number. + /// + [JsonProperty(PropertyName = "properties.orderNumber")] + public string OrderNumber { get; private set; } + + /// + /// Gets the name of the resource instance that the usage is about. + /// + [JsonProperty(PropertyName = "properties.instanceName")] + public string InstanceName { get; private set; } + + /// + /// Gets the uri of the resource instance that the usage is about. + /// + [JsonProperty(PropertyName = "properties.instanceId")] + public string InstanceId { get; private set; } + + /// + /// Gets the ISO currency in which the meter is charged, for example, + /// USD. + /// + [JsonProperty(PropertyName = "properties.currency")] + public string Currency { get; private set; } + + /// + /// Gets the quantity of usage. + /// + [JsonProperty(PropertyName = "properties.consumedQuantity")] + public decimal? ConsumedQuantity { get; private set; } + + /// + /// Gets the unit of measure. + /// + [JsonProperty(PropertyName = "properties.unitOfMeasure")] + public string UnitOfMeasure { get; private set; } + + /// + /// Gets the amount of cost before tax. + /// + [JsonProperty(PropertyName = "properties.pretaxCost")] + public decimal? PretaxCost { get; private set; } + + /// + /// Gets the estimated usage is subject to change. + /// + [JsonProperty(PropertyName = "properties.isEstimated")] + public bool? IsEstimated { get; private set; } + + /// + /// Gets the meter id (GUID). + /// + [JsonProperty(PropertyName = "properties.meterId")] + public System.Guid? MeterId { get; private set; } + + /// + /// Gets subscription guid. + /// + [JsonProperty(PropertyName = "properties.subscriptionGuid")] + public System.Guid? SubscriptionGuid { get; private set; } + + /// + /// Gets subscription name. + /// + [JsonProperty(PropertyName = "properties.subscriptionName")] + public string SubscriptionName { get; private set; } + + /// + /// Gets account name. + /// + [JsonProperty(PropertyName = "properties.accountName")] + public string AccountName { get; private set; } + + /// + /// Gets department name. + /// + [JsonProperty(PropertyName = "properties.departmentName")] + public string DepartmentName { get; private set; } + + /// + /// Gets consumed service name. + /// + [JsonProperty(PropertyName = "properties.consumedService")] + public string ConsumedService { get; private set; } + + /// + /// Gets the cost center of this department if it is a department and a + /// costcenter exists + /// + [JsonProperty(PropertyName = "properties.costCenter")] + public string CostCenter { get; private set; } + + /// + /// Gets additional details of this usage item. By default this is not + /// populated, unless it's specified in $expand. + /// + [JsonProperty(PropertyName = "properties.additionalProperties")] + public string AdditionalProperties { get; private set; } + + /// + /// Gets the name of publisher. + /// + [JsonProperty(PropertyName = "properties.publisherName")] + public string PublisherName { get; private set; } + + /// + /// Gets the name of plan. + /// + [JsonProperty(PropertyName = "properties.planName")] + public string PlanName { get; private set; } + + /// + /// Gets flag indicating whether this is a recurring charge or not. + /// + [JsonProperty(PropertyName = "properties.isRecurringCharge")] + public bool? IsRecurringCharge { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/MeterDetails.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/MeterDetails.cs new file mode 100644 index 000000000000..48a04c7f60ba --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/MeterDetails.cs @@ -0,0 +1,124 @@ +// +// 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.Consumption.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of the meter detail. + /// + public partial class MeterDetails + { + /// + /// Initializes a new instance of the MeterDetails class. + /// + public MeterDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MeterDetails class. + /// + /// The name of the meter, within the given + /// meter category + /// The category of the meter, for example, + /// 'Cloud services', 'Networking', etc.. + /// The subcategory of the meter, for + /// example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + /// The unit in which the meter consumption is + /// charged, for example, 'Hours', 'GB', etc. + /// The location in which the Azure service + /// is available. + /// The total included quantity + /// associated with the offer. + /// The pretax listing price. + /// The name of the service. + /// The service tier. + public MeterDetails(string meterName = default(string), string meterCategory = default(string), string meterSubCategory = default(string), string unit = default(string), string meterLocation = default(string), decimal? totalIncludedQuantity = default(decimal?), decimal? pretaxStandardRate = default(decimal?), string serviceName = default(string), string serviceTier = default(string)) + { + MeterName = meterName; + MeterCategory = meterCategory; + MeterSubCategory = meterSubCategory; + Unit = unit; + MeterLocation = meterLocation; + TotalIncludedQuantity = totalIncludedQuantity; + PretaxStandardRate = pretaxStandardRate; + ServiceName = serviceName; + ServiceTier = serviceTier; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of the meter, within the given meter category + /// + [JsonProperty(PropertyName = "meterName")] + public string MeterName { get; private set; } + + /// + /// Gets the category of the meter, for example, 'Cloud services', + /// 'Networking', etc.. + /// + [JsonProperty(PropertyName = "meterCategory")] + public string MeterCategory { get; private set; } + + /// + /// Gets the subcategory of the meter, for example, 'A6 Cloud + /// services', 'ExpressRoute (IXP)', etc.. + /// + [JsonProperty(PropertyName = "meterSubCategory")] + public string MeterSubCategory { get; private set; } + + /// + /// Gets the unit in which the meter consumption is charged, for + /// example, 'Hours', 'GB', etc. + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; private set; } + + /// + /// Gets the location in which the Azure service is available. + /// + [JsonProperty(PropertyName = "meterLocation")] + public string MeterLocation { get; private set; } + + /// + /// Gets the total included quantity associated with the offer. + /// + [JsonProperty(PropertyName = "totalIncludedQuantity")] + public decimal? TotalIncludedQuantity { get; private set; } + + /// + /// Gets the pretax listing price. + /// + [JsonProperty(PropertyName = "pretaxStandardRate")] + public decimal? PretaxStandardRate { get; private set; } + + /// + /// Gets the name of the service. + /// + [JsonProperty(PropertyName = "serviceName")] + public string ServiceName { get; private set; } + + /// + /// Gets the service tier. + /// + [JsonProperty(PropertyName = "serviceTier")] + public string ServiceTier { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/MeterDetailsResponse.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/MeterDetailsResponse.cs new file mode 100644 index 000000000000..1a720c4fdb91 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/MeterDetailsResponse.cs @@ -0,0 +1,90 @@ +// +// 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.Consumption.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of the meter detail. + /// + public partial class MeterDetailsResponse + { + /// + /// Initializes a new instance of the MeterDetailsResponse class. + /// + public MeterDetailsResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MeterDetailsResponse class. + /// + /// The name of the meter, within the given + /// meter category + /// The category of the meter, for example, + /// 'Cloud services', 'Networking', etc.. + /// The subcategory of the meter, for + /// example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + /// The unit in which the meter consumption + /// is charged, for example, 'Hours', 'GB', etc. + /// The service family. + public MeterDetailsResponse(string meterName = default(string), string meterCategory = default(string), string meterSubCategory = default(string), string unitOfMeasure = default(string), string serviceFamily = default(string)) + { + MeterName = meterName; + MeterCategory = meterCategory; + MeterSubCategory = meterSubCategory; + UnitOfMeasure = unitOfMeasure; + ServiceFamily = serviceFamily; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of the meter, within the given meter category + /// + [JsonProperty(PropertyName = "meterName")] + public string MeterName { get; private set; } + + /// + /// Gets the category of the meter, for example, 'Cloud services', + /// 'Networking', etc.. + /// + [JsonProperty(PropertyName = "meterCategory")] + public string MeterCategory { get; private set; } + + /// + /// Gets the subcategory of the meter, for example, 'A6 Cloud + /// services', 'ExpressRoute (IXP)', etc.. + /// + [JsonProperty(PropertyName = "meterSubCategory")] + public string MeterSubCategory { get; private set; } + + /// + /// Gets the unit in which the meter consumption is charged, for + /// example, 'Hours', 'GB', etc. + /// + [JsonProperty(PropertyName = "unitOfMeasure")] + public string UnitOfMeasure { get; private set; } + + /// + /// Gets the service family. + /// + [JsonProperty(PropertyName = "serviceFamily")] + public string ServiceFamily { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Metrictype.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Metrictype.cs new file mode 100644 index 000000000000..98d5158bc61e --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Metrictype.cs @@ -0,0 +1,32 @@ +// +// 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.Consumption.Models +{ + + /// + /// Defines values for Metrictype. + /// + public static class Metrictype + { + /// + /// Actual cost data. + /// + public const string ActualCostMetricType = "actualcost"; + /// + /// Amortized cost data. + /// + public const string AmortizedCostMetricType = "amortizedcost"; + /// + /// Usage data. + /// + public const string UsageMetricType = "usage"; + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Notification.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Notification.cs new file mode 100644 index 000000000000..bc6befaaaa59 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Notification.cs @@ -0,0 +1,147 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The notification associated with a budget. + /// + public partial class Notification + { + /// + /// Initializes a new instance of the Notification class. + /// + public Notification() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Notification class. + /// + /// The notification is enabled or not. + /// The comparison operator. Possible + /// values include: 'EqualTo', 'GreaterThan', + /// 'GreaterThanOrEqualTo' + /// Threshold value associated with a + /// notification. Notification is sent when the cost exceeded the + /// threshold. It is always percent and has to be between 0 and + /// 1000. + /// Email addresses to send the budget + /// notification to when the threshold is exceeded. + /// Contact roles to send the budget + /// notification to when the threshold is exceeded. + /// Action groups to send the budget + /// notification to when the threshold is exceeded. + public Notification(bool enabled, string operatorProperty, decimal threshold, IList contactEmails, IList contactRoles = default(IList), IList contactGroups = default(IList)) + { + Enabled = enabled; + OperatorProperty = operatorProperty; + Threshold = threshold; + ContactEmails = contactEmails; + ContactRoles = contactRoles; + ContactGroups = contactGroups; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the notification is enabled or not. + /// + [JsonProperty(PropertyName = "enabled")] + public bool Enabled { get; set; } + + /// + /// Gets or sets the comparison operator. Possible values include: + /// 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo' + /// + [JsonProperty(PropertyName = "operator")] + public string OperatorProperty { get; set; } + + /// + /// Gets or sets threshold value associated with a notification. + /// Notification is sent when the cost exceeded the threshold. It is + /// always percent and has to be between 0 and 1000. + /// + [JsonProperty(PropertyName = "threshold")] + public decimal Threshold { get; set; } + + /// + /// Gets or sets email addresses to send the budget notification to + /// when the threshold is exceeded. + /// + [JsonProperty(PropertyName = "contactEmails")] + public IList ContactEmails { get; set; } + + /// + /// Gets or sets contact roles to send the budget notification to when + /// the threshold is exceeded. + /// + [JsonProperty(PropertyName = "contactRoles")] + public IList ContactRoles { get; set; } + + /// + /// Gets or sets action groups to send the budget notification to when + /// the threshold is exceeded. + /// + [JsonProperty(PropertyName = "contactGroups")] + public IList ContactGroups { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (OperatorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); + } + if (ContactEmails == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ContactEmails"); + } + if (ContactEmails != null) + { + if (ContactEmails.Count > 50) + { + throw new ValidationException(ValidationRules.MaxItems, "ContactEmails", 50); + } + if (ContactEmails.Count < 1) + { + throw new ValidationException(ValidationRules.MinItems, "ContactEmails", 1); + } + } + if (ContactGroups != null) + { + if (ContactGroups.Count > 50) + { + throw new ValidationException(ValidationRules.MaxItems, "ContactGroups", 50); + } + if (ContactGroups.Count < 0) + { + throw new ValidationException(ValidationRules.MinItems, "ContactGroups", 0); + } + } + } + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/OperatorType.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/OperatorType.cs new file mode 100644 index 000000000000..6208be911b9c --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/OperatorType.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + + /// + /// Defines values for OperatorType. + /// + public static class OperatorType + { + public const string EqualTo = "EqualTo"; + public const string GreaterThan = "GreaterThan"; + public const string GreaterThanOrEqualTo = "GreaterThanOrEqualTo"; + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Page1.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Page1.cs new file mode 100644 index 000000000000..f95faac9d172 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Page1.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page1 : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/PriceSheetProperties.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/PriceSheetProperties.cs new file mode 100644 index 000000000000..28b88485ca38 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/PriceSheetProperties.cs @@ -0,0 +1,120 @@ +// +// 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.Consumption.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of the price sheet. + /// + public partial class PriceSheetProperties + { + /// + /// Initializes a new instance of the PriceSheetProperties class. + /// + public PriceSheetProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PriceSheetProperties class. + /// + /// The id of the billing period resource + /// that the usage belongs to. + /// The meter id (GUID) + /// The details about the meter. By default + /// this is not populated, unless it's specified in $expand. + /// Unit of measure + /// Included quality for an + /// offer + /// Part Number + /// Unit Price + /// Currency Code + /// Offer Id + public PriceSheetProperties(string billingPeriodId = default(string), System.Guid? meterId = default(System.Guid?), MeterDetails meterDetails = default(MeterDetails), string unitOfMeasure = default(string), decimal? includedQuantity = default(decimal?), string partNumber = default(string), decimal? unitPrice = default(decimal?), string currencyCode = default(string), string offerId = default(string)) + { + BillingPeriodId = billingPeriodId; + MeterId = meterId; + MeterDetails = meterDetails; + UnitOfMeasure = unitOfMeasure; + IncludedQuantity = includedQuantity; + PartNumber = partNumber; + UnitPrice = unitPrice; + CurrencyCode = currencyCode; + OfferId = offerId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the id of the billing period resource that the usage belongs + /// to. + /// + [JsonProperty(PropertyName = "billingPeriodId")] + public string BillingPeriodId { get; private set; } + + /// + /// Gets the meter id (GUID) + /// + [JsonProperty(PropertyName = "meterId")] + public System.Guid? MeterId { get; private set; } + + /// + /// Gets the details about the meter. By default this is not populated, + /// unless it's specified in $expand. + /// + [JsonProperty(PropertyName = "meterDetails")] + public MeterDetails MeterDetails { get; private set; } + + /// + /// Gets unit of measure + /// + [JsonProperty(PropertyName = "unitOfMeasure")] + public string UnitOfMeasure { get; private set; } + + /// + /// Gets included quality for an offer + /// + [JsonProperty(PropertyName = "includedQuantity")] + public decimal? IncludedQuantity { get; private set; } + + /// + /// Gets part Number + /// + [JsonProperty(PropertyName = "partNumber")] + public string PartNumber { get; private set; } + + /// + /// Gets unit Price + /// + [JsonProperty(PropertyName = "unitPrice")] + public decimal? UnitPrice { get; private set; } + + /// + /// Gets currency Code + /// + [JsonProperty(PropertyName = "currencyCode")] + public string CurrencyCode { get; private set; } + + /// + /// Gets offer Id + /// + [JsonProperty(PropertyName = "offerId")] + public string OfferId { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/InvoiceSection.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/PriceSheetResult.cs similarity index 52% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/InvoiceSection.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/PriceSheetResult.cs index 257aeb4ed5e0..e1aa3923a539 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/InvoiceSection.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/PriceSheetResult.cs @@ -18,34 +18,34 @@ namespace Microsoft.Azure.Management.Consumption.Models using System.Linq; /// - /// An InvoiceSection resource. + /// An pricesheet resource. /// [Rest.Serialization.JsonTransformation] - public partial class InvoiceSection : Resource + public partial class PriceSheetResult : Resource { /// - /// Initializes a new instance of the InvoiceSection class. + /// Initializes a new instance of the PriceSheetResult class. /// - public InvoiceSection() + public PriceSheetResult() { CustomInit(); } /// - /// Initializes a new instance of the InvoiceSection class. + /// Initializes a new instance of the PriceSheetResult class. /// /// Resource Id. /// Resource name. /// Resource type. /// Resource tags. - /// The name of the InvoiceSection. - /// The billing profiles associated to - /// the billing account. - public InvoiceSection(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string displayName = default(string), IList billingProfiles = default(IList)) + /// Price sheet + /// The link (url) to the next page of + /// results. + public PriceSheetResult(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList pricesheets = default(IList), string nextLink = default(string)) : base(id, name, type, tags) { - DisplayName = displayName; - BillingProfiles = billingProfiles; + Pricesheets = pricesheets; + NextLink = nextLink; CustomInit(); } @@ -55,17 +55,16 @@ public InvoiceSection() partial void CustomInit(); /// - /// Gets or sets the name of the InvoiceSection. + /// Gets price sheet /// - [JsonProperty(PropertyName = "properties.displayName")] - public string DisplayName { get; set; } + [JsonProperty(PropertyName = "properties.pricesheets")] + public IList Pricesheets { get; private set; } /// - /// Gets or sets the billing profiles associated to the billing - /// account. + /// Gets the link (url) to the next page of results. /// - [JsonProperty(PropertyName = "properties.billingProfiles")] - public IList BillingProfiles { get; set; } + [JsonProperty(PropertyName = "properties.nextLink")] + public string NextLink { get; private set; } } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ReservationDetail.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ReservationDetail.cs new file mode 100644 index 000000000000..f3903d5f9cb8 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ReservationDetail.cs @@ -0,0 +1,146 @@ +// +// 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.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// reservation detail resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class ReservationDetail : Resource + { + /// + /// Initializes a new instance of the ReservationDetail class. + /// + public ReservationDetail() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReservationDetail class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + /// The reservation order ID is the + /// identifier for a reservation purchase. Each reservation order ID + /// represents a single purchase transaction. A reservation order + /// contains reservations. The reservation order specifies the VM size + /// and region for the reservations. + /// The reservation ID is the identifier of + /// a reservation within a reservation order. Each reservation is the + /// grouping for applying the benefit scope and also specifies the + /// number of instances to which the reservation benefit can be applied + /// to. + /// This is the ARM Sku name. It can be used to + /// join with the serviceType field in additional info in usage + /// records. + /// This is the total hours reserved for + /// the day. E.g. if reservation for 1 instance was made on 1 PM, this + /// will be 11 hours for that day and 24 hours from subsequent + /// days. + /// The date on which consumption + /// occurred. + /// This is the total hours used by the + /// instance. + /// This identifier is the name of the + /// resource or the fully qualified Resource ID. + /// This is the total count of + /// instances that are reserved for the reservationId. + public ReservationDetail(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string reservationOrderId = default(string), string reservationId = default(string), string skuName = default(string), decimal? reservedHours = default(decimal?), System.DateTime? usageDate = default(System.DateTime?), decimal? usedHours = default(decimal?), string instanceId = default(string), decimal? totalReservedQuantity = default(decimal?)) + : base(id, name, type, tags) + { + ReservationOrderId = reservationOrderId; + ReservationId = reservationId; + SkuName = skuName; + ReservedHours = reservedHours; + UsageDate = usageDate; + UsedHours = usedHours; + InstanceId = instanceId; + TotalReservedQuantity = totalReservedQuantity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the reservation order ID is the identifier for a reservation + /// purchase. Each reservation order ID represents a single purchase + /// transaction. A reservation order contains reservations. The + /// reservation order specifies the VM size and region for the + /// reservations. + /// + [JsonProperty(PropertyName = "properties.reservationOrderId")] + public string ReservationOrderId { get; private set; } + + /// + /// Gets the reservation ID is the identifier of a reservation within a + /// reservation order. Each reservation is the grouping for applying + /// the benefit scope and also specifies the number of instances to + /// which the reservation benefit can be applied to. + /// + [JsonProperty(PropertyName = "properties.reservationId")] + public string ReservationId { get; private set; } + + /// + /// Gets this is the ARM Sku name. It can be used to join with the + /// serviceType field in additional info in usage records. + /// + [JsonProperty(PropertyName = "properties.skuName")] + public string SkuName { get; private set; } + + /// + /// Gets this is the total hours reserved for the day. E.g. if + /// reservation for 1 instance was made on 1 PM, this will be 11 hours + /// for that day and 24 hours from subsequent days. + /// + [JsonProperty(PropertyName = "properties.reservedHours")] + public decimal? ReservedHours { get; private set; } + + /// + /// Gets the date on which consumption occurred. + /// + [JsonProperty(PropertyName = "properties.usageDate")] + public System.DateTime? UsageDate { get; private set; } + + /// + /// Gets this is the total hours used by the instance. + /// + [JsonProperty(PropertyName = "properties.usedHours")] + public decimal? UsedHours { get; private set; } + + /// + /// Gets this identifier is the name of the resource or the fully + /// qualified Resource ID. + /// + [JsonProperty(PropertyName = "properties.instanceId")] + public string InstanceId { get; private set; } + + /// + /// Gets this is the total count of instances that are reserved for the + /// reservationId. + /// + [JsonProperty(PropertyName = "properties.totalReservedQuantity")] + public decimal? TotalReservedQuantity { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ReservationRecommendation.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ReservationRecommendation.cs new file mode 100644 index 000000000000..7bf72c60b372 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ReservationRecommendation.cs @@ -0,0 +1,175 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Reservation recommendation resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class ReservationRecommendation + { + /// + /// Initializes a new instance of the ReservationRecommendation class. + /// + public ReservationRecommendation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReservationRecommendation class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + /// Resource location + /// Resource sku + /// The number of days of usage to look + /// back for recommendation. + /// The meter id (GUID) + /// RI recommendations in one or three year + /// terms. + /// The total amount of cost + /// without reserved instances. + /// Recommended quality for reserved + /// instances. + /// The total amount of + /// cost with reserved instances. + /// Total estimated savings with reserved + /// instances. + /// The usage date for looking + /// back. + /// Shared or single recommendation. + public ReservationRecommendation(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string location = default(string), string sku = default(string), string lookBackPeriod = default(string), System.Guid? meterId = default(System.Guid?), string term = default(string), decimal? costWithNoReservedInstances = default(decimal?), decimal? recommendedQuantity = default(decimal?), decimal? totalCostWithReservedInstances = default(decimal?), decimal? netSavings = default(decimal?), System.DateTime? firstUsageDate = default(System.DateTime?), string scope = default(string)) + { + Id = id; + Name = name; + Type = type; + Tags = tags; + Location = location; + Sku = sku; + LookBackPeriod = lookBackPeriod; + MeterId = meterId; + Term = term; + CostWithNoReservedInstances = costWithNoReservedInstances; + RecommendedQuantity = recommendedQuantity; + TotalCostWithReservedInstances = totalCostWithReservedInstances; + NetSavings = netSavings; + FirstUsageDate = firstUsageDate; + Scope = scope; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets resource name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; private set; } + + /// + /// Gets resource location + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; private set; } + + /// + /// Gets resource sku + /// + [JsonProperty(PropertyName = "sku")] + public string Sku { get; private set; } + + /// + /// Gets the number of days of usage to look back for recommendation. + /// + [JsonProperty(PropertyName = "properties.lookBackPeriod")] + public string LookBackPeriod { get; private set; } + + /// + /// Gets the meter id (GUID) + /// + [JsonProperty(PropertyName = "properties.meterId")] + public System.Guid? MeterId { get; private set; } + + /// + /// Gets RI recommendations in one or three year terms. + /// + [JsonProperty(PropertyName = "properties.term")] + public string Term { get; private set; } + + /// + /// Gets the total amount of cost without reserved instances. + /// + [JsonProperty(PropertyName = "properties.costWithNoReservedInstances")] + public decimal? CostWithNoReservedInstances { get; private set; } + + /// + /// Gets recommended quality for reserved instances. + /// + [JsonProperty(PropertyName = "properties.recommendedQuantity")] + public decimal? RecommendedQuantity { get; private set; } + + /// + /// Gets the total amount of cost with reserved instances. + /// + [JsonProperty(PropertyName = "properties.totalCostWithReservedInstances")] + public decimal? TotalCostWithReservedInstances { get; private set; } + + /// + /// Gets total estimated savings with reserved instances. + /// + [JsonProperty(PropertyName = "properties.netSavings")] + public decimal? NetSavings { get; private set; } + + /// + /// Gets the usage date for looking back. + /// + [JsonProperty(PropertyName = "properties.firstUsageDate")] + public System.DateTime? FirstUsageDate { get; private set; } + + /// + /// Gets shared or single recommendation. + /// + [JsonProperty(PropertyName = "properties.scope")] + public string Scope { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/ReservationSummary.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ReservationSummary.cs new file mode 100644 index 000000000000..d38076dcb31b --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ReservationSummary.cs @@ -0,0 +1,165 @@ +// +// 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.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// reservation summary resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class ReservationSummary : Resource + { + /// + /// Initializes a new instance of the ReservationSummary class. + /// + public ReservationSummary() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReservationSummary class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + /// The reservation order ID is the + /// identifier for a reservation purchase. Each reservation order ID + /// represents a single purchase transaction. A reservation order + /// contains reservations. The reservation order specifies the VM size + /// and region for the reservations. + /// The reservation ID is the identifier of + /// a reservation within a reservation order. Each reservation is the + /// grouping for applying the benefit scope and also specifies the + /// number of instances to which the reservation benefit can be applied + /// to. + /// This is the ARM Sku name. It can be used to + /// join with the serviceType field in additional info in usage + /// records. + /// This is the total hours reserved. E.g. + /// if reservation for 1 instance was made on 1 PM, this will be 11 + /// hours for that day and 24 hours from subsequent days + /// Data corresponding to the utilization + /// record. If the grain of data is monthly, it will be first day of + /// month. + /// Total used hours by the reservation + /// This is the minimum hourly + /// utilization in the usage time (day or month). E.g. if usage record + /// corresponds to 12/10/2017 and on that for hour 4 and 5, utilization + /// was 10%, this field will return 10% for that day + /// This is average utilization + /// for the entire time range. (day or month depending on the + /// grain) + /// This is the maximum hourly + /// utilization in the usage time (day or month). E.g. if usage record + /// corresponds to 12/10/2017 and on that for hour 4 and 5, utilization + /// was 100%, this field will return 100% for that day. + public ReservationSummary(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string reservationOrderId = default(string), string reservationId = default(string), string skuName = default(string), decimal? reservedHours = default(decimal?), System.DateTime? usageDate = default(System.DateTime?), decimal? usedHours = default(decimal?), decimal? minUtilizationPercentage = default(decimal?), decimal? avgUtilizationPercentage = default(decimal?), decimal? maxUtilizationPercentage = default(decimal?)) + : base(id, name, type, tags) + { + ReservationOrderId = reservationOrderId; + ReservationId = reservationId; + SkuName = skuName; + ReservedHours = reservedHours; + UsageDate = usageDate; + UsedHours = usedHours; + MinUtilizationPercentage = minUtilizationPercentage; + AvgUtilizationPercentage = avgUtilizationPercentage; + MaxUtilizationPercentage = maxUtilizationPercentage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the reservation order ID is the identifier for a reservation + /// purchase. Each reservation order ID represents a single purchase + /// transaction. A reservation order contains reservations. The + /// reservation order specifies the VM size and region for the + /// reservations. + /// + [JsonProperty(PropertyName = "properties.reservationOrderId")] + public string ReservationOrderId { get; private set; } + + /// + /// Gets the reservation ID is the identifier of a reservation within a + /// reservation order. Each reservation is the grouping for applying + /// the benefit scope and also specifies the number of instances to + /// which the reservation benefit can be applied to. + /// + [JsonProperty(PropertyName = "properties.reservationId")] + public string ReservationId { get; private set; } + + /// + /// Gets this is the ARM Sku name. It can be used to join with the + /// serviceType field in additional info in usage records. + /// + [JsonProperty(PropertyName = "properties.skuName")] + public string SkuName { get; private set; } + + /// + /// Gets this is the total hours reserved. E.g. if reservation for 1 + /// instance was made on 1 PM, this will be 11 hours for that day and + /// 24 hours from subsequent days + /// + [JsonProperty(PropertyName = "properties.reservedHours")] + public decimal? ReservedHours { get; private set; } + + /// + /// Gets data corresponding to the utilization record. If the grain of + /// data is monthly, it will be first day of month. + /// + [JsonProperty(PropertyName = "properties.usageDate")] + public System.DateTime? UsageDate { get; private set; } + + /// + /// Gets total used hours by the reservation + /// + [JsonProperty(PropertyName = "properties.usedHours")] + public decimal? UsedHours { get; private set; } + + /// + /// Gets this is the minimum hourly utilization in the usage time (day + /// or month). E.g. if usage record corresponds to 12/10/2017 and on + /// that for hour 4 and 5, utilization was 10%, this field will return + /// 10% for that day + /// + [JsonProperty(PropertyName = "properties.minUtilizationPercentage")] + public decimal? MinUtilizationPercentage { get; private set; } + + /// + /// Gets this is average utilization for the entire time range. (day or + /// month depending on the grain) + /// + [JsonProperty(PropertyName = "properties.avgUtilizationPercentage")] + public decimal? AvgUtilizationPercentage { get; private set; } + + /// + /// Gets this is the maximum hourly utilization in the usage time (day + /// or month). E.g. if usage record corresponds to 12/10/2017 and on + /// that for hour 4 and 5, utilization was 100%, this field will return + /// 100% for that day. + /// + [JsonProperty(PropertyName = "properties.maxUtilizationPercentage")] + public decimal? MaxUtilizationPercentage { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Amount.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ResourceAttributes.cs similarity index 54% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/Amount.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/ResourceAttributes.cs index 0fc4e60c00e9..d99d15fe3189 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Amount.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/ResourceAttributes.cs @@ -14,27 +14,27 @@ namespace Microsoft.Azure.Management.Consumption.Models using System.Linq; /// - /// Object to represent monetary quantities. + /// The Resource model definition. /// - public partial class Amount + public partial class ResourceAttributes { /// - /// Initializes a new instance of the Amount class. + /// Initializes a new instance of the ResourceAttributes class. /// - public Amount() + public ResourceAttributes() { CustomInit(); } /// - /// Initializes a new instance of the Amount class. + /// Initializes a new instance of the ResourceAttributes class. /// - /// The currency for the amount value. - /// Amount value. - public Amount(string currency = default(string), double? value = default(double?)) + /// Resource location + /// Resource sku + public ResourceAttributes(string location = default(string), string sku = default(string)) { - Currency = currency; - Value = value; + Location = location; + Sku = sku; CustomInit(); } @@ -44,16 +44,16 @@ public Amount() partial void CustomInit(); /// - /// Gets the currency for the amount value. + /// Gets resource location /// - [JsonProperty(PropertyName = "currency")] - public string Currency { get; private set; } + [JsonProperty(PropertyName = "location")] + public string Location { get; private set; } /// - /// Gets amount value. + /// Gets resource sku /// - [JsonProperty(PropertyName = "value")] - public double? Value { get; private set; } + [JsonProperty(PropertyName = "sku")] + public string Sku { get; private set; } } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Lots.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Tag.cs similarity index 60% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/Lots.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/Tag.cs index 67fbcc855a1d..ea212513c039 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/Lots.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/Tag.cs @@ -11,30 +11,28 @@ namespace Microsoft.Azure.Management.Consumption.Models { using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; using System.Linq; /// - /// Result of listing lot summary. + /// The tag resource. /// - public partial class Lots + public partial class Tag { /// - /// Initializes a new instance of the Lots class. + /// Initializes a new instance of the Tag class. /// - public Lots() + public Tag() { CustomInit(); } /// - /// Initializes a new instance of the Lots class. + /// Initializes a new instance of the Tag class. /// - /// The list of lot summary. - public Lots(IList value = default(IList)) + /// Tag key. + public Tag(string key = default(string)) { - Value = value; + Key = key; CustomInit(); } @@ -44,10 +42,10 @@ public Lots() partial void CustomInit(); /// - /// Gets the list of lot summary. + /// Gets or sets tag key. /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } + [JsonProperty(PropertyName = "key")] + public string Key { get; set; } } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/TagsResult.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/TagsResult.cs new file mode 100644 index 000000000000..85d682f02708 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/TagsResult.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A resource listing all tags. + /// + [Rest.Serialization.JsonTransformation] + public partial class TagsResult : ProxyResource + { + /// + /// Initializes a new instance of the TagsResult class. + /// + public TagsResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagsResult class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// eTag of the resource. To handle concurrent + /// update scenario, this field will be used to determine whether the + /// user is updating the latest version or not. + /// A list of Tag. + public TagsResult(string id = default(string), string name = default(string), string type = default(string), string eTag = default(string), IList tags = default(IList)) + : base(id, name, type, eTag) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a list of Tag. + /// + [JsonProperty(PropertyName = "properties.tags")] + public IList Tags { get; set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/TimeGrainType.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/TimeGrainType.cs new file mode 100644 index 000000000000..6e0a7feed11d --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/TimeGrainType.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + + /// + /// Defines values for TimeGrainType. + /// + public static class TimeGrainType + { + public const string Monthly = "Monthly"; + public const string Quarterly = "Quarterly"; + public const string Annually = "Annually"; + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/UsageDetail.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/UsageDetail.cs new file mode 100644 index 000000000000..8ff10325964c --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/UsageDetail.cs @@ -0,0 +1,449 @@ +// +// 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.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An usage detail resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class UsageDetail : Resource + { + /// + /// Initializes a new instance of the UsageDetail class. + /// + public UsageDetail() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UsageDetail class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + /// Billing Account identifier. + /// Billing Account Name. + /// The billing period start + /// date. + /// The billing period end + /// date. + /// Billing Profile identifier. + /// Billing Profile Name. + /// Account Owner Id. + /// Account Name. + /// Subscription guid. + /// Subscription name. + /// Date for the usage record. + /// Product name for the consumed service or + /// purchase. Not available for Marketplace. + /// Part Number of the service used. Can be + /// used to join with the price sheet. Not available for + /// marketplace. + /// The meter id (GUID). Not available for + /// marketplace. For reserved instance this represents the primary + /// meter for which the reservation was purchased. For the actual VM + /// Size for which the reservation is purchased see + /// productOrderName. + /// The details about the meter. By default + /// this is not populated, unless it's specified in $expand. + /// The usage quantity. + /// Effective Price that’s charged for the + /// usage. + /// The amount of cost before tax. + /// Unit Price is the price applicable to you. + /// (your EA or other contract price). + /// Billing Currency. + /// Resource Location. + /// Consumed service name. Name of the + /// azure resource provider that emits the usage or was purchased. This + /// value is not provided for marketplace usage. + /// Azure resource manager resource + /// identifier. + /// Resource Name. + /// Service Info 1. + /// Service Info 2. + /// Additional details of this usage item. + /// By default this is not populated, unless it's specified in $expand. + /// Use this field to get usage line item specific details such as the + /// actual VM Size (ServiceType) or the ratio in which the reservation + /// discount is applied. + /// Invoice Section Name. + /// The cost center of this department if it + /// is a department and a cost center is provided. + /// Resource Group Name. + /// ARM resource id of the reservation. + /// Only applies to records relevant to reservations. + /// User provided display name of the + /// reservation. Last known name for a particular day is populated in + /// the daily data. Only applies to records relevant to + /// reservations. + /// Product Order Id. For reservations + /// this is the Reservation Order ID. + /// Product Order Name. For reservations + /// this is the SKU that was purchased. + /// Offer Id. Ex: MS-AZR-0017P, + /// MS-AZR-0148P. + /// Is Azure Credit + /// Eligible. + /// Term (in months). 1 month for monthly recurring + /// purchase. 12 months for a 1 year reservation. 36 months for a 3 + /// year reservation. + /// Publisher Name. + /// Publisher Type. + /// Plan Name. + /// Indicates a charge represents credits, + /// usage, a Marketplace purchase, a reservation fee, or a + /// refund. + /// Indicates how frequently this charge will + /// occur. OneTime for purchases which only happen once, Monthly for + /// fees which recur every month, and UsageBased for charges based on + /// how much a service is used. + public UsageDetail(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string billingAccountId = default(string), string billingAccountName = default(string), System.DateTime? billingPeriodStartDate = default(System.DateTime?), System.DateTime? billingPeriodEndDate = default(System.DateTime?), string billingProfileId = default(string), string billingProfileName = default(string), string accountOwnerId = default(string), string accountName = default(string), string subscriptionId = default(string), string subscriptionName = default(string), System.DateTime? date = default(System.DateTime?), string product = default(string), string partNumber = default(string), System.Guid? meterId = default(System.Guid?), MeterDetailsResponse meterDetails = default(MeterDetailsResponse), decimal? quantity = default(decimal?), decimal? effectivePrice = default(decimal?), decimal? cost = default(decimal?), decimal? unitPrice = default(decimal?), string billingCurrency = default(string), string resourceLocation = default(string), string consumedService = default(string), string resourceId = default(string), string resourceName = default(string), string serviceInfo1 = default(string), string serviceInfo2 = default(string), string additionalInfo = default(string), string invoiceSection = default(string), string costCenter = default(string), string resourceGroup = default(string), string reservationId = default(string), string reservationName = default(string), string productOrderId = default(string), string productOrderName = default(string), string offerId = default(string), bool? isAzureCreditEligible = default(bool?), string term = default(string), string publisherName = default(string), string publisherType = default(string), string planName = default(string), string chargeType = default(string), string frequency = default(string)) + : base(id, name, type, tags) + { + BillingAccountId = billingAccountId; + BillingAccountName = billingAccountName; + BillingPeriodStartDate = billingPeriodStartDate; + BillingPeriodEndDate = billingPeriodEndDate; + BillingProfileId = billingProfileId; + BillingProfileName = billingProfileName; + AccountOwnerId = accountOwnerId; + AccountName = accountName; + SubscriptionId = subscriptionId; + SubscriptionName = subscriptionName; + Date = date; + Product = product; + PartNumber = partNumber; + MeterId = meterId; + MeterDetails = meterDetails; + Quantity = quantity; + EffectivePrice = effectivePrice; + Cost = cost; + UnitPrice = unitPrice; + BillingCurrency = billingCurrency; + ResourceLocation = resourceLocation; + ConsumedService = consumedService; + ResourceId = resourceId; + ResourceName = resourceName; + ServiceInfo1 = serviceInfo1; + ServiceInfo2 = serviceInfo2; + AdditionalInfo = additionalInfo; + InvoiceSection = invoiceSection; + CostCenter = costCenter; + ResourceGroup = resourceGroup; + ReservationId = reservationId; + ReservationName = reservationName; + ProductOrderId = productOrderId; + ProductOrderName = productOrderName; + OfferId = offerId; + IsAzureCreditEligible = isAzureCreditEligible; + Term = term; + PublisherName = publisherName; + PublisherType = publisherType; + PlanName = planName; + ChargeType = chargeType; + Frequency = frequency; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets billing Account identifier. + /// + [JsonProperty(PropertyName = "properties.billingAccountId")] + public string BillingAccountId { get; private set; } + + /// + /// Gets billing Account Name. + /// + [JsonProperty(PropertyName = "properties.billingAccountName")] + public string BillingAccountName { get; private set; } + + /// + /// Gets the billing period start date. + /// + [JsonProperty(PropertyName = "properties.billingPeriodStartDate")] + public System.DateTime? BillingPeriodStartDate { get; private set; } + + /// + /// Gets the billing period end date. + /// + [JsonProperty(PropertyName = "properties.billingPeriodEndDate")] + public System.DateTime? BillingPeriodEndDate { get; private set; } + + /// + /// Gets billing Profile identifier. + /// + [JsonProperty(PropertyName = "properties.billingProfileId")] + public string BillingProfileId { get; private set; } + + /// + /// Gets billing Profile Name. + /// + [JsonProperty(PropertyName = "properties.billingProfileName")] + public string BillingProfileName { get; private set; } + + /// + /// Gets account Owner Id. + /// + [JsonProperty(PropertyName = "properties.accountOwnerId")] + public string AccountOwnerId { get; private set; } + + /// + /// Gets account Name. + /// + [JsonProperty(PropertyName = "properties.accountName")] + public string AccountName { get; private set; } + + /// + /// Gets subscription guid. + /// + [JsonProperty(PropertyName = "properties.subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets subscription name. + /// + [JsonProperty(PropertyName = "properties.subscriptionName")] + public string SubscriptionName { get; private set; } + + /// + /// Gets date for the usage record. + /// + [JsonProperty(PropertyName = "properties.date")] + public System.DateTime? Date { get; private set; } + + /// + /// Gets product name for the consumed service or purchase. Not + /// available for Marketplace. + /// + [JsonProperty(PropertyName = "properties.product")] + public string Product { get; private set; } + + /// + /// Gets part Number of the service used. Can be used to join with the + /// price sheet. Not available for marketplace. + /// + [JsonProperty(PropertyName = "properties.partNumber")] + public string PartNumber { get; private set; } + + /// + /// Gets the meter id (GUID). Not available for marketplace. For + /// reserved instance this represents the primary meter for which the + /// reservation was purchased. For the actual VM Size for which the + /// reservation is purchased see productOrderName. + /// + [JsonProperty(PropertyName = "properties.meterId")] + public System.Guid? MeterId { get; private set; } + + /// + /// Gets the details about the meter. By default this is not populated, + /// unless it's specified in $expand. + /// + [JsonProperty(PropertyName = "properties.meterDetails")] + public MeterDetailsResponse MeterDetails { get; private set; } + + /// + /// Gets the usage quantity. + /// + [JsonProperty(PropertyName = "properties.quantity")] + public decimal? Quantity { get; private set; } + + /// + /// Gets effective Price that’s charged for the usage. + /// + [JsonProperty(PropertyName = "properties.effectivePrice")] + public decimal? EffectivePrice { get; private set; } + + /// + /// Gets the amount of cost before tax. + /// + [JsonProperty(PropertyName = "properties.cost")] + public decimal? Cost { get; private set; } + + /// + /// Gets unit Price is the price applicable to you. (your EA or other + /// contract price). + /// + [JsonProperty(PropertyName = "properties.unitPrice")] + public decimal? UnitPrice { get; private set; } + + /// + /// Gets billing Currency. + /// + [JsonProperty(PropertyName = "properties.billingCurrency")] + public string BillingCurrency { get; private set; } + + /// + /// Gets resource Location. + /// + [JsonProperty(PropertyName = "properties.resourceLocation")] + public string ResourceLocation { get; private set; } + + /// + /// Gets consumed service name. Name of the azure resource provider + /// that emits the usage or was purchased. This value is not provided + /// for marketplace usage. + /// + [JsonProperty(PropertyName = "properties.consumedService")] + public string ConsumedService { get; private set; } + + /// + /// Gets azure resource manager resource identifier. + /// + [JsonProperty(PropertyName = "properties.resourceId")] + public string ResourceId { get; private set; } + + /// + /// Gets resource Name. + /// + [JsonProperty(PropertyName = "properties.resourceName")] + public string ResourceName { get; private set; } + + /// + /// Gets service Info 1. + /// + [JsonProperty(PropertyName = "properties.serviceInfo1")] + public string ServiceInfo1 { get; private set; } + + /// + /// Gets service Info 2. + /// + [JsonProperty(PropertyName = "properties.serviceInfo2")] + public string ServiceInfo2 { get; private set; } + + /// + /// Gets additional details of this usage item. By default this is not + /// populated, unless it's specified in $expand. Use this field to get + /// usage line item specific details such as the actual VM Size + /// (ServiceType) or the ratio in which the reservation discount is + /// applied. + /// + [JsonProperty(PropertyName = "properties.additionalInfo")] + public string AdditionalInfo { get; private set; } + + /// + /// Gets invoice Section Name. + /// + [JsonProperty(PropertyName = "properties.invoiceSection")] + public string InvoiceSection { get; private set; } + + /// + /// Gets the cost center of this department if it is a department and a + /// cost center is provided. + /// + [JsonProperty(PropertyName = "properties.costCenter")] + public string CostCenter { get; private set; } + + /// + /// Gets resource Group Name. + /// + [JsonProperty(PropertyName = "properties.resourceGroup")] + public string ResourceGroup { get; private set; } + + /// + /// Gets ARM resource id of the reservation. Only applies to records + /// relevant to reservations. + /// + [JsonProperty(PropertyName = "properties.reservationId")] + public string ReservationId { get; private set; } + + /// + /// Gets user provided display name of the reservation. Last known name + /// for a particular day is populated in the daily data. Only applies + /// to records relevant to reservations. + /// + [JsonProperty(PropertyName = "properties.reservationName")] + public string ReservationName { get; private set; } + + /// + /// Gets product Order Id. For reservations this is the Reservation + /// Order ID. + /// + [JsonProperty(PropertyName = "properties.productOrderId")] + public string ProductOrderId { get; private set; } + + /// + /// Gets product Order Name. For reservations this is the SKU that was + /// purchased. + /// + [JsonProperty(PropertyName = "properties.productOrderName")] + public string ProductOrderName { get; private set; } + + /// + /// Gets offer Id. Ex: MS-AZR-0017P, MS-AZR-0148P. + /// + [JsonProperty(PropertyName = "properties.offerId")] + public string OfferId { get; private set; } + + /// + /// Gets is Azure Credit Eligible. + /// + [JsonProperty(PropertyName = "properties.isAzureCreditEligible")] + public bool? IsAzureCreditEligible { get; private set; } + + /// + /// Gets term (in months). 1 month for monthly recurring purchase. 12 + /// months for a 1 year reservation. 36 months for a 3 year + /// reservation. + /// + [JsonProperty(PropertyName = "properties.term")] + public string Term { get; private set; } + + /// + /// Gets publisher Name. + /// + [JsonProperty(PropertyName = "properties.publisherName")] + public string PublisherName { get; private set; } + + /// + /// Gets publisher Type. + /// + [JsonProperty(PropertyName = "properties.publisherType")] + public string PublisherType { get; private set; } + + /// + /// Gets plan Name. + /// + [JsonProperty(PropertyName = "properties.planName")] + public string PlanName { get; private set; } + + /// + /// Gets indicates a charge represents credits, usage, a Marketplace + /// purchase, a reservation fee, or a refund. + /// + [JsonProperty(PropertyName = "properties.chargeType")] + public string ChargeType { get; private set; } + + /// + /// Gets indicates how frequently this charge will occur. OneTime for + /// purchases which only happen once, Monthly for fees which recur + /// every month, and UsageBased for charges based on how much a service + /// is used. + /// + [JsonProperty(PropertyName = "properties.frequency")] + public string Frequency { get; private set; } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/InvoicePricesheetDownloadHeaders.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/UsageDetailsDownloadHeaders.cs similarity index 75% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/InvoicePricesheetDownloadHeaders.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/UsageDetailsDownloadHeaders.cs index 0dccb69fcf26..26cf1f9a2de3 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/InvoicePricesheetDownloadHeaders.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/UsageDetailsDownloadHeaders.cs @@ -16,19 +16,19 @@ namespace Microsoft.Azure.Management.Consumption.Models /// /// Defines headers for Download operation. /// - public partial class InvoicePricesheetDownloadHeaders + public partial class UsageDetailsDownloadHeaders { /// - /// Initializes a new instance of the InvoicePricesheetDownloadHeaders + /// Initializes a new instance of the UsageDetailsDownloadHeaders /// class. /// - public InvoicePricesheetDownloadHeaders() + public UsageDetailsDownloadHeaders() { CustomInit(); } /// - /// Initializes a new instance of the InvoicePricesheetDownloadHeaders + /// Initializes a new instance of the UsageDetailsDownloadHeaders /// class. /// /// GET this URL to retrieve the status of the @@ -39,13 +39,11 @@ public InvoicePricesheetDownloadHeaders() /// To get the progress of the /// operation, call GET operation on the URL in Azure-AsyncOperation /// header field. - /// The operation entity Id GUID. - public InvoicePricesheetDownloadHeaders(string location = default(string), string retryAfter = default(string), string azureAsyncOperation = default(string), string oDataEntityId = default(string)) + public UsageDetailsDownloadHeaders(string location = default(string), string retryAfter = default(string), string azureAsyncOperation = default(string)) { Location = location; RetryAfter = retryAfter; AzureAsyncOperation = azureAsyncOperation; - ODataEntityId = oDataEntityId; CustomInit(); } @@ -75,11 +73,5 @@ public InvoicePricesheetDownloadHeaders() [JsonProperty(PropertyName = "Azure-AsyncOperation")] public string AzureAsyncOperation { get; set; } - /// - /// Gets or sets the operation entity Id GUID. - /// - [JsonProperty(PropertyName = "OData-EntityId")] - public string ODataEntityId { get; set; } - } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/Models/PricesheetDownloadResponse.cs b/src/SDKs/Consumption/Management.Consumption/Generated/Models/UsageDetailsDownloadResponse.cs similarity index 63% rename from src/SDKs/Consumption/Management.Consumption/Generated/Models/PricesheetDownloadResponse.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/Models/UsageDetailsDownloadResponse.cs index 6f88e7a5138e..6eda8d43d49c 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/Models/PricesheetDownloadResponse.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/Models/UsageDetailsDownloadResponse.cs @@ -18,34 +18,36 @@ namespace Microsoft.Azure.Management.Consumption.Models using System.Linq; /// - /// Download response of Pricesheets. + /// Download response of Usage Details. /// [Rest.Serialization.JsonTransformation] - public partial class PricesheetDownloadResponse : Resource + public partial class UsageDetailsDownloadResponse : Resource { /// - /// Initializes a new instance of the PricesheetDownloadResponse class. + /// Initializes a new instance of the UsageDetailsDownloadResponse + /// class. /// - public PricesheetDownloadResponse() + public UsageDetailsDownloadResponse() { CustomInit(); } /// - /// Initializes a new instance of the PricesheetDownloadResponse class. + /// Initializes a new instance of the UsageDetailsDownloadResponse + /// class. /// /// Resource Id. /// Resource name. /// Resource type. /// Resource tags. - /// The URL to the PDF file. - /// The time in UTC at which this download URL + /// The URL to the csv file. + /// The time in UTC at which this download URL /// will expire. - public PricesheetDownloadResponse(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string downloadUrlProperty = default(string), string expiryTime = default(string)) + public UsageDetailsDownloadResponse(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string downloadUrlProperty = default(string), string validTill = default(string)) : base(id, name, type, tags) { DownloadUrlProperty = downloadUrlProperty; - ExpiryTime = expiryTime; + ValidTill = validTill; CustomInit(); } @@ -55,7 +57,7 @@ public PricesheetDownloadResponse() partial void CustomInit(); /// - /// Gets the URL to the PDF file. + /// Gets the URL to the csv file. /// [JsonProperty(PropertyName = "properties.downloadUrl")] public string DownloadUrlProperty { get; private set; } @@ -63,8 +65,8 @@ public PricesheetDownloadResponse() /// /// Gets the time in UTC at which this download URL will expire. /// - [JsonProperty(PropertyName = "properties.expiryTime")] - public string ExpiryTime { get; private set; } + [JsonProperty(PropertyName = "properties.validTill")] + public string ValidTill { get; private set; } } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/PriceSheetOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/PriceSheetOperations.cs new file mode 100644 index 000000000000..aed615d8df84 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/PriceSheetOperations.cs @@ -0,0 +1,485 @@ +// +// 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.Consumption +{ + 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; + + /// + /// PriceSheetOperations operations. + /// + internal partial class PriceSheetOperations : IServiceOperations, IPriceSheetOperations + { + /// + /// Initializes a new instance of the PriceSheetOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PriceSheetOperations(ConsumptionManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ConsumptionManagementClient + /// + public ConsumptionManagementClient Client { get; private set; } + + /// + /// Gets the price sheet for a scope by subscriptionId. Price sheet is + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// May be used to expand the properties/meterDetails within a price sheet. By + /// default, these fields are not included when returning price sheet. + /// + /// + /// 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 top N results. + /// + /// + /// 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 expand = default(string), string skiptoken = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("expand", expand); + tracingParameters.Add("skiptoken", skiptoken); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the price sheet for a scope by subscriptionId and billing period. Price + /// sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// + /// Billing Period Name. + /// + /// + /// May be used to expand the properties/meterDetails within a price sheet. By + /// default, these fields are not included when returning price sheet. + /// + /// + /// 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 top N results. + /// + /// + /// 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> GetByBillingPeriodWithHttpMessagesAsync(string billingPeriodName, string expand = default(string), string skiptoken = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + 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 (billingPeriodName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingPeriodName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("expand", expand); + tracingParameters.Add("skiptoken", skiptoken); + tracingParameters.Add("top", top); + tracingParameters.Add("billingPeriodName", billingPeriodName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetByBillingPeriod", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{billingPeriodName}", System.Uri.EscapeDataString(billingPeriodName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 (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/Consumption/Management.Consumption/Generated/PriceSheetOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/PriceSheetOperationsExtensions.cs new file mode 100644 index 000000000000..d4815b9f87a8 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/PriceSheetOperationsExtensions.cs @@ -0,0 +1,147 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PriceSheetOperations. + /// + public static partial class PriceSheetOperationsExtensions + { + /// + /// Gets the price sheet for a scope by subscriptionId. Price sheet is + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// May be used to expand the properties/meterDetails within a price sheet. By + /// default, these fields are not included when returning price sheet. + /// + /// + /// 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 top N results. + /// + public static PriceSheetResult Get(this IPriceSheetOperations operations, string expand = default(string), string skiptoken = default(string), int? top = default(int?)) + { + return operations.GetAsync(expand, skiptoken, top).GetAwaiter().GetResult(); + } + + /// + /// Gets the price sheet for a scope by subscriptionId. Price sheet is + /// available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// May be used to expand the properties/meterDetails within a price sheet. By + /// default, these fields are not included when returning price sheet. + /// + /// + /// 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 top N results. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPriceSheetOperations operations, string expand = default(string), string skiptoken = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(expand, skiptoken, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the price sheet for a scope by subscriptionId and billing period. Price + /// sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing Period Name. + /// + /// + /// May be used to expand the properties/meterDetails within a price sheet. By + /// default, these fields are not included when returning price sheet. + /// + /// + /// 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 top N results. + /// + public static PriceSheetResult GetByBillingPeriod(this IPriceSheetOperations operations, string billingPeriodName, string expand = default(string), string skiptoken = default(string), int? top = default(int?)) + { + return operations.GetByBillingPeriodAsync(billingPeriodName, expand, skiptoken, top).GetAwaiter().GetResult(); + } + + /// + /// Get the price sheet for a scope by subscriptionId and billing period. Price + /// sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing Period Name. + /// + /// + /// May be used to expand the properties/meterDetails within a price sheet. By + /// default, these fields are not included when returning price sheet. + /// + /// + /// 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 top N results. + /// + /// + /// The cancellation token. + /// + public static async Task GetByBillingPeriodAsync(this IPriceSheetOperations operations, string billingPeriodName, string expand = default(string), string skiptoken = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetByBillingPeriodWithHttpMessagesAsync(billingPeriodName, expand, skiptoken, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/InvoicePricesheetOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationRecommendationsOperations.cs similarity index 50% rename from src/SDKs/Consumption/Management.Consumption/Generated/InvoicePricesheetOperations.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/ReservationRecommendationsOperations.cs index 9d73fbf9a0ab..b0c3ab64809a 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/InvoicePricesheetOperations.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationRecommendationsOperations.cs @@ -23,12 +23,12 @@ namespace Microsoft.Azure.Management.Consumption using System.Threading.Tasks; /// - /// InvoicePricesheetOperations operations. + /// ReservationRecommendationsOperations operations. /// - internal partial class InvoicePricesheetOperations : IServiceOperations, IInvoicePricesheetOperations + internal partial class ReservationRecommendationsOperations : IServiceOperations, IReservationRecommendationsOperations { /// - /// Initializes a new instance of the InvoicePricesheetOperations class. + /// Initializes a new instance of the ReservationRecommendationsOperations class. /// /// /// Reference to the service client. @@ -36,7 +36,7 @@ internal partial class InvoicePricesheetOperations : IServiceOperations /// Thrown when a required parameter is null /// - internal InvoicePricesheetOperations(ConsumptionManagementClient client) + internal ReservationRecommendationsOperations(ConsumptionManagementClient client) { if (client == null) { @@ -51,35 +51,12 @@ internal InvoicePricesheetOperations(ConsumptionManagementClient client) public ConsumptionManagementClient Client { get; private set; } /// - /// Get pricesheet data for invoice id (invoiceName). + /// List of recommendations for purchasing reserved instances. + /// /// - /// - /// Azure Billing Account Id. - /// - /// - /// The name of an invoice resource. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> DownloadWithHttpMessagesAsync(string billingAccountId, string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDownloadWithHttpMessagesAsync(billingAccountId, invoiceName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get pricesheet data for invoice id (invoiceName). - /// - /// - /// Azure Billing Account Id. - /// - /// - /// The name of an invoice resource. + /// + /// May be used to filter reservationRecommendations by properties/scope and + /// properties/lookBackPeriod. /// /// /// Headers that will be added to request. @@ -102,19 +79,15 @@ internal InvoicePricesheetOperations(ConsumptionManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> BeginDownloadWithHttpMessagesAsync(string billingAccountId, string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListWithHttpMessagesAsync(string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (billingAccountId == null) + if (Client.SubscriptionId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); - } - if (invoiceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "invoiceName"); + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; @@ -123,17 +96,19 @@ internal InvoicePricesheetOperations(ConsumptionManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("billingAccountId", billingAccountId); - tracingParameters.Add("invoiceName", invoiceName); + tracingParameters.Add("filter", filter); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDownload", 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("/") ? "" : "/")), "providers/Microsoft.Consumption/billingAccounts/{billingAccountId}/invoices/{invoiceName}/pricesheet/default/download").ToString(); - _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); - _url = _url.Replace("{invoiceName}", System.Uri.EscapeDataString(invoiceName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reservationRecommendations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } if (Client.ApiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); @@ -145,7 +120,7 @@ internal InvoicePricesheetOperations(ConsumptionManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -196,7 +171,7 @@ internal InvoicePricesheetOperations(ConsumptionManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) + if ((int)_statusCode != 200) { var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -226,7 +201,7 @@ internal InvoicePricesheetOperations(ConsumptionManagementClient 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")) @@ -239,7 +214,7 @@ internal InvoicePricesheetOperations(ConsumptionManagementClient 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) { @@ -251,18 +226,174 @@ internal InvoicePricesheetOperations(ConsumptionManagementClient client) throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } - try + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List of recommendations for purchasing reserved instances. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } } - catch (JsonException ex) + + // 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 new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + 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) { diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/ReservationRecommendationsOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationRecommendationsOperationsExtensions.cs new file mode 100644 index 000000000000..5358163308b1 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationRecommendationsOperationsExtensions.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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ReservationRecommendationsOperations. + /// + public static partial class ReservationRecommendationsOperationsExtensions + { + /// + /// List of recommendations for purchasing reserved instances. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// May be used to filter reservationRecommendations by properties/scope and + /// properties/lookBackPeriod. + /// + public static IPage List(this IReservationRecommendationsOperations operations, string filter = default(string)) + { + return operations.ListAsync(filter).GetAwaiter().GetResult(); + } + + /// + /// List of recommendations for purchasing reserved instances. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// May be used to filter reservationRecommendations by properties/scope and + /// properties/lookBackPeriod. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IReservationRecommendationsOperations operations, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List of recommendations for purchasing reserved instances. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IReservationRecommendationsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List of recommendations for purchasing reserved instances. + /// + /// + /// + /// 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 IReservationRecommendationsOperations 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/Consumption/Management.Consumption/Generated/ReservationsDetailsOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationsDetailsOperations.cs new file mode 100644 index 000000000000..b94241f33af7 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationsDetailsOperations.cs @@ -0,0 +1,783 @@ +// +// 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.Consumption +{ + 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; + + /// + /// ReservationsDetailsOperations operations. + /// + internal partial class ReservationsDetailsOperations : IServiceOperations, IReservationsDetailsOperations + { + /// + /// Initializes a new instance of the ReservationsDetailsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ReservationsDetailsOperations(ConsumptionManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ConsumptionManagementClient + /// + public ConsumptionManagementClient Client { get; private set; } + + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// Order Id of the reservation + /// + /// + /// Filter reservation details by date range. The properties/UsageDate for + /// start date and end date. The filter supports 'le' and 'ge' + /// + /// + /// 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>> ListByReservationOrderWithHttpMessagesAsync(string reservationOrderId, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (reservationOrderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "reservationOrderId"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + 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("reservationOrderId", reservationOrderId); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByReservationOrder", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails").ToString(); + _url = _url.Replace("{reservationOrderId}", System.Uri.EscapeDataString(reservationOrderId)); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 reservations details for provided date range. + /// + /// + /// + /// Order Id of the reservation + /// + /// + /// Id of the reservation + /// + /// + /// Filter reservation details by date range. The properties/UsageDate for + /// start date and end date. The filter supports 'le' and 'ge' + /// + /// + /// 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>> ListByReservationOrderAndReservationWithHttpMessagesAsync(string reservationOrderId, string reservationId, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (reservationOrderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "reservationOrderId"); + } + if (reservationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "reservationId"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + 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("reservationOrderId", reservationOrderId); + tracingParameters.Add("reservationId", reservationId); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByReservationOrderAndReservation", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails").ToString(); + _url = _url.Replace("{reservationOrderId}", System.Uri.EscapeDataString(reservationOrderId)); + _url = _url.Replace("{reservationId}", System.Uri.EscapeDataString(reservationId)); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 reservations details for provided date range. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByReservationOrderNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByReservationOrderNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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 reservations details for provided date range. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByReservationOrderAndReservationNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByReservationOrderAndReservationNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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/Consumption/Management.Consumption/Generated/ReservationsDetailsOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationsDetailsOperationsExtensions.cs new file mode 100644 index 000000000000..0d08b82a9067 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationsDetailsOperationsExtensions.cs @@ -0,0 +1,191 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ReservationsDetailsOperations. + /// + public static partial class ReservationsDetailsOperationsExtensions + { + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Order Id of the reservation + /// + /// + /// Filter reservation details by date range. The properties/UsageDate for + /// start date and end date. The filter supports 'le' and 'ge' + /// + public static IPage ListByReservationOrder(this IReservationsDetailsOperations operations, string reservationOrderId, string filter) + { + return operations.ListByReservationOrderAsync(reservationOrderId, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Order Id of the reservation + /// + /// + /// Filter reservation details by date range. The properties/UsageDate for + /// start date and end date. The filter supports 'le' and 'ge' + /// + /// + /// The cancellation token. + /// + public static async Task> ListByReservationOrderAsync(this IReservationsDetailsOperations operations, string reservationOrderId, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByReservationOrderWithHttpMessagesAsync(reservationOrderId, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Order Id of the reservation + /// + /// + /// Id of the reservation + /// + /// + /// Filter reservation details by date range. The properties/UsageDate for + /// start date and end date. The filter supports 'le' and 'ge' + /// + public static IPage ListByReservationOrderAndReservation(this IReservationsDetailsOperations operations, string reservationOrderId, string reservationId, string filter) + { + return operations.ListByReservationOrderAndReservationAsync(reservationOrderId, reservationId, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Order Id of the reservation + /// + /// + /// Id of the reservation + /// + /// + /// Filter reservation details by date range. The properties/UsageDate for + /// start date and end date. The filter supports 'le' and 'ge' + /// + /// + /// The cancellation token. + /// + public static async Task> ListByReservationOrderAndReservationAsync(this IReservationsDetailsOperations operations, string reservationOrderId, string reservationId, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByReservationOrderAndReservationWithHttpMessagesAsync(reservationOrderId, reservationId, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByReservationOrderNext(this IReservationsDetailsOperations operations, string nextPageLink) + { + return operations.ListByReservationOrderNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByReservationOrderNextAsync(this IReservationsDetailsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByReservationOrderNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByReservationOrderAndReservationNext(this IReservationsDetailsOperations operations, string nextPageLink) + { + return operations.ListByReservationOrderAndReservationNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the reservations details for provided date range. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByReservationOrderAndReservationNextAsync(this IReservationsDetailsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByReservationOrderAndReservationNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/ReservationsSummariesOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationsSummariesOperations.cs new file mode 100644 index 000000000000..67051f50e750 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationsSummariesOperations.cs @@ -0,0 +1,801 @@ +// +// 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.Consumption +{ + 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; + + /// + /// ReservationsSummariesOperations operations. + /// + internal partial class ReservationsSummariesOperations : IServiceOperations, IReservationsSummariesOperations + { + /// + /// Initializes a new instance of the ReservationsSummariesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ReservationsSummariesOperations(ConsumptionManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ConsumptionManagementClient + /// + public ConsumptionManagementClient Client { get; private set; } + + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// Order Id of the reservation + /// + /// + /// Can be daily or monthly. Possible values include: 'DailyGrain', + /// 'MonthlyGrain' + /// + /// + /// Required only for daily grain. The properties/UsageDate for start date and + /// end date. The filter supports 'le' and 'ge' + /// + /// + /// 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>> ListByReservationOrderWithHttpMessagesAsync(string reservationOrderId, string grain, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (reservationOrderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "reservationOrderId"); + } + if (grain == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "grain"); + } + 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("reservationOrderId", reservationOrderId); + tracingParameters.Add("grain", grain); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByReservationOrder", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries").ToString(); + _url = _url.Replace("{reservationOrderId}", System.Uri.EscapeDataString(reservationOrderId)); + List _queryParameters = new List(); + if (grain != null) + { + _queryParameters.Add(string.Format("grain={0}", System.Uri.EscapeDataString(grain))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 reservations summaries for daily or monthly grain. + /// + /// + /// + /// Order Id of the reservation + /// + /// + /// Id of the reservation + /// + /// + /// Can be daily or monthly. Possible values include: 'DailyGrain', + /// 'MonthlyGrain' + /// + /// + /// Required only for daily grain. The properties/UsageDate for start date and + /// end date. The filter supports 'le' and 'ge' + /// + /// + /// 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>> ListByReservationOrderAndReservationWithHttpMessagesAsync(string reservationOrderId, string reservationId, string grain, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (reservationOrderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "reservationOrderId"); + } + if (reservationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "reservationId"); + } + if (grain == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "grain"); + } + 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("reservationOrderId", reservationOrderId); + tracingParameters.Add("reservationId", reservationId); + tracingParameters.Add("grain", grain); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByReservationOrderAndReservation", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries").ToString(); + _url = _url.Replace("{reservationOrderId}", System.Uri.EscapeDataString(reservationOrderId)); + _url = _url.Replace("{reservationId}", System.Uri.EscapeDataString(reservationId)); + List _queryParameters = new List(); + if (grain != null) + { + _queryParameters.Add(string.Format("grain={0}", System.Uri.EscapeDataString(grain))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 reservations summaries for daily or monthly grain. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByReservationOrderNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByReservationOrderNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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 reservations summaries for daily or monthly grain. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByReservationOrderAndReservationNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByReservationOrderAndReservationNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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/Consumption/Management.Consumption/Generated/ReservationsSummariesOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationsSummariesOperationsExtensions.cs new file mode 100644 index 000000000000..a2c21e8d0231 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/ReservationsSummariesOperationsExtensions.cs @@ -0,0 +1,207 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ReservationsSummariesOperations. + /// + public static partial class ReservationsSummariesOperationsExtensions + { + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Order Id of the reservation + /// + /// + /// Can be daily or monthly. Possible values include: 'DailyGrain', + /// 'MonthlyGrain' + /// + /// + /// Required only for daily grain. The properties/UsageDate for start date and + /// end date. The filter supports 'le' and 'ge' + /// + public static IPage ListByReservationOrder(this IReservationsSummariesOperations operations, string reservationOrderId, string grain, string filter = default(string)) + { + return operations.ListByReservationOrderAsync(reservationOrderId, grain, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Order Id of the reservation + /// + /// + /// Can be daily or monthly. Possible values include: 'DailyGrain', + /// 'MonthlyGrain' + /// + /// + /// Required only for daily grain. The properties/UsageDate for start date and + /// end date. The filter supports 'le' and 'ge' + /// + /// + /// The cancellation token. + /// + public static async Task> ListByReservationOrderAsync(this IReservationsSummariesOperations operations, string reservationOrderId, string grain, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByReservationOrderWithHttpMessagesAsync(reservationOrderId, grain, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Order Id of the reservation + /// + /// + /// Id of the reservation + /// + /// + /// Can be daily or monthly. Possible values include: 'DailyGrain', + /// 'MonthlyGrain' + /// + /// + /// Required only for daily grain. The properties/UsageDate for start date and + /// end date. The filter supports 'le' and 'ge' + /// + public static IPage ListByReservationOrderAndReservation(this IReservationsSummariesOperations operations, string reservationOrderId, string reservationId, string grain, string filter = default(string)) + { + return operations.ListByReservationOrderAndReservationAsync(reservationOrderId, reservationId, grain, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Order Id of the reservation + /// + /// + /// Id of the reservation + /// + /// + /// Can be daily or monthly. Possible values include: 'DailyGrain', + /// 'MonthlyGrain' + /// + /// + /// Required only for daily grain. The properties/UsageDate for start date and + /// end date. The filter supports 'le' and 'ge' + /// + /// + /// The cancellation token. + /// + public static async Task> ListByReservationOrderAndReservationAsync(this IReservationsSummariesOperations operations, string reservationOrderId, string reservationId, string grain, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByReservationOrderAndReservationWithHttpMessagesAsync(reservationOrderId, reservationId, grain, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByReservationOrderNext(this IReservationsSummariesOperations operations, string nextPageLink) + { + return operations.ListByReservationOrderNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByReservationOrderNextAsync(this IReservationsSummariesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByReservationOrderNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByReservationOrderAndReservationNext(this IReservationsSummariesOperations operations, string nextPageLink) + { + return operations.ListByReservationOrderAndReservationNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the reservations summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByReservationOrderAndReservationNextAsync(this IReservationsSummariesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByReservationOrderAndReservationNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/SdkInfo_ConsumptionManagementClient.cs b/src/SDKs/Consumption/Management.Consumption/Generated/SdkInfo_ConsumptionManagementClient.cs index a231b2e39e81..2329d9f3ba0c 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/SdkInfo_ConsumptionManagementClient.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/SdkInfo_ConsumptionManagementClient.cs @@ -19,15 +19,20 @@ public static IEnumerable> ApiInfo_ConsumptionMana { return new Tuple[] { - new Tuple("Billing", "ChargesByBillingAccount", "2018-11-01-preview"), - new Tuple("Billing", "ChargesByBillingProfile", "2018-11-01-preview"), - new Tuple("Billing", "ChargesByInvoiceSection", "2018-11-01-preview"), - new Tuple("Billing", "CreditSummaryByBillingProfile", "2018-11-01-preview"), - new Tuple("Billing", "EventsByBillingProfile", "2018-11-01-preview"), - new Tuple("Billing", "LotsByBillingProfile", "2018-11-01-preview"), - new Tuple("Consumption", "BillingProfilePricesheet", "2018-11-01-preview"), - new Tuple("Consumption", "InvoicePricesheet", "2018-11-01-preview"), - new Tuple("Consumption", "Operations", "2018-11-01-preview"), + new Tuple("Billing", "Balances", "2019-04-01-preview"), + new Tuple("Billing", "PriceSheet", "2019-04-01-preview"), + new Tuple("Capacity", "ReservationsDetails", "2019-04-01-preview"), + new Tuple("Capacity", "ReservationsSummaries", "2019-04-01-preview"), + new Tuple("Consumption", "Budgets", "2019-04-01-preview"), + new Tuple("Consumption", "Charges", "2019-04-01-preview"), + new Tuple("Consumption", "Forecasts", "2019-04-01-preview"), + new Tuple("Consumption", "Marketplaces", "2019-04-01-preview"), + new Tuple("Consumption", "Operations", "2019-04-01-preview"), + new Tuple("Consumption", "PriceSheet", "2019-04-01-preview"), + new Tuple("Consumption", "ReservationRecommendations", "2019-04-01-preview"), + new Tuple("Consumption", "Tags", "2019-04-01-preview"), + new Tuple("Consumption", "UsageDetails", "2019-04-01-preview"), + new Tuple("Management", "AggregatedCost", "2019-04-01-preview"), }.AsEnumerable(); } } diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/CreditSummaryByBillingProfileOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/TagsOperations.cs similarity index 81% rename from src/SDKs/Consumption/Management.Consumption/Generated/CreditSummaryByBillingProfileOperations.cs rename to src/SDKs/Consumption/Management.Consumption/Generated/TagsOperations.cs index 01957893bc11..f5e72efa6ffe 100644 --- a/src/SDKs/Consumption/Management.Consumption/Generated/CreditSummaryByBillingProfileOperations.cs +++ b/src/SDKs/Consumption/Management.Consumption/Generated/TagsOperations.cs @@ -23,12 +23,12 @@ namespace Microsoft.Azure.Management.Consumption using System.Threading.Tasks; /// - /// CreditSummaryByBillingProfileOperations operations. + /// TagsOperations operations. /// - internal partial class CreditSummaryByBillingProfileOperations : IServiceOperations, ICreditSummaryByBillingProfileOperations + internal partial class TagsOperations : IServiceOperations, ITagsOperations { /// - /// Initializes a new instance of the CreditSummaryByBillingProfileOperations class. + /// Initializes a new instance of the TagsOperations class. /// /// /// Reference to the service client. @@ -36,7 +36,7 @@ internal partial class CreditSummaryByBillingProfileOperations : IServiceOperati /// /// Thrown when a required parameter is null /// - internal CreditSummaryByBillingProfileOperations(ConsumptionManagementClient client) + internal TagsOperations(ConsumptionManagementClient client) { if (client == null) { @@ -51,15 +51,22 @@ internal CreditSummaryByBillingProfileOperations(ConsumptionManagementClient cli public ConsumptionManagementClient Client { get; private set; } /// - /// The credit summary by billingAccountId and billingProfileId for given start - /// and end date. + /// Get all available tag keys for the defined scope /// /// - /// - /// BillingAccount ID - /// - /// - /// Billing Profile Id. + /// + /// The scope associated with tags operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope.. /// /// /// Headers that will be added to request. @@ -82,15 +89,11 @@ internal CreditSummaryByBillingProfileOperations(ConsumptionManagementClient cli /// /// A response object containing the response body and response headers. /// - public async Task> GetWithHttpMessagesAsync(string billingAccountId, string billingProfileId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (billingAccountId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); - } - if (billingProfileId == null) + if (scope == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileId"); + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (Client.ApiVersion == null) { @@ -103,16 +106,14 @@ internal CreditSummaryByBillingProfileOperations(ConsumptionManagementClient cli { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("billingAccountId", billingAccountId); - tracingParameters.Add("billingProfileId", billingProfileId); + tracingParameters.Add("scope", scope); 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/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary").ToString(); - _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); - _url = _url.Replace("{billingProfileId}", System.Uri.EscapeDataString(billingProfileId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/tags").ToString(); + _url = _url.Replace("{scope}", scope); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -206,7 +207,7 @@ internal CreditSummaryByBillingProfileOperations(ConsumptionManagementClient cli 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")) @@ -219,7 +220,7 @@ internal CreditSummaryByBillingProfileOperations(ConsumptionManagementClient cli _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/Consumption/Management.Consumption/Generated/TagsOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/TagsOperationsExtensions.cs new file mode 100644 index 000000000000..269128cad4d3 --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/TagsOperationsExtensions.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TagsOperations. + /// + public static partial class TagsOperationsExtensions + { + /// + /// Get all available tag keys for the defined scope + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with tags operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope.. + /// + public static TagsResult Get(this ITagsOperations operations, string scope) + { + return operations.GetAsync(scope).GetAwaiter().GetResult(); + } + + /// + /// Get all available tag keys for the defined scope + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with tags operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope.. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ITagsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Consumption/Management.Consumption/Generated/UsageDetailsOperations.cs b/src/SDKs/Consumption/Management.Consumption/Generated/UsageDetailsOperations.cs new file mode 100644 index 000000000000..7bfa4cfdf7ae --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/UsageDetailsOperations.cs @@ -0,0 +1,736 @@ +// +// 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.Consumption +{ + 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; + + /// + /// UsageDetailsOperations operations. + /// + internal partial class UsageDetailsOperations : IServiceOperations, IUsageDetailsOperations + { + /// + /// Initializes a new instance of the UsageDetailsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal UsageDetailsOperations(ConsumptionManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ConsumptionManagementClient + /// + public ConsumptionManagementClient Client { get; private set; } + + /// + /// Lists the usage details for the defined scope. Usage details are available + /// via this API only for May 1, 2014 or later. + /// + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and management group, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// May be used to expand the properties/additionalInfo or + /// properties/meterDetails within a list of usage details. By default, these + /// fields are not included when listing usage details. + /// + /// + /// May be used to filter usageDetails by properties/resourceGroup, + /// properties/resourceName, properties/resourceId, properties/chargeType, + /// properties/reservationId or tags. 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 (:). + /// + /// + /// 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 + /// usageDetails. + /// + /// + /// Allows to select different type of cost/usage records. Possible values + /// include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + /// + /// 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 scope, string expand = default(string), string filter = default(string), string skiptoken = default(string), int? top = default(int?), string metric = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + 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("scope", scope); + tracingParameters.Add("expand", expand); + tracingParameters.Add("filter", filter); + tracingParameters.Add("skiptoken", skiptoken); + tracingParameters.Add("top", top); + tracingParameters.Add("metric", metric); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/usageDetails").ToString(); + _url = _url.Replace("{scope}", scope); + List _queryParameters = new List(); + 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 (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (metric != null) + { + _queryParameters.Add(string.Format("metric={0}", System.Uri.EscapeDataString(metric))); + } + 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; + } + + /// + /// Download usage details data. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and management group, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// Allows to select different type of cost/usage records. Possible values + /// include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DownloadWithHttpMessagesAsync(string scope, string metric = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDownloadWithHttpMessagesAsync(scope, metric, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Download usage details data. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and management group, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// Allows to select different type of cost/usage records. Possible values + /// include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + /// + /// 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> BeginDownloadWithHttpMessagesAsync(string scope, string metric = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + 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("scope", scope); + tracingParameters.Add("metric", metric); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDownload", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/usageDetails/download").ToString(); + _url = _url.Replace("{scope}", scope); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (metric != null) + { + _queryParameters.Add(string.Format("metric={0}", System.Uri.EscapeDataString(metric))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists the usage details for the defined scope. Usage details are available + /// via this API only for May 1, 2014 or later. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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/Consumption/Management.Consumption/Generated/UsageDetailsOperationsExtensions.cs b/src/SDKs/Consumption/Management.Consumption/Generated/UsageDetailsOperationsExtensions.cs new file mode 100644 index 000000000000..e40b96215e9f --- /dev/null +++ b/src/SDKs/Consumption/Management.Consumption/Generated/UsageDetailsOperationsExtensions.cs @@ -0,0 +1,341 @@ +// +// 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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for UsageDetailsOperations. + /// + public static partial class UsageDetailsOperationsExtensions + { + /// + /// Lists the usage details for the defined scope. Usage details are available + /// via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and management group, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// May be used to expand the properties/additionalInfo or + /// properties/meterDetails within a list of usage details. By default, these + /// fields are not included when listing usage details. + /// + /// + /// May be used to filter usageDetails by properties/resourceGroup, + /// properties/resourceName, properties/resourceId, properties/chargeType, + /// properties/reservationId or tags. 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 (:). + /// + /// + /// 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 + /// usageDetails. + /// + /// + /// Allows to select different type of cost/usage records. Possible values + /// include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + public static IPage List(this IUsageDetailsOperations operations, string scope, string expand = default(string), string filter = default(string), string skiptoken = default(string), int? top = default(int?), string metric = default(string)) + { + return operations.ListAsync(scope, expand, filter, skiptoken, top, metric).GetAwaiter().GetResult(); + } + + /// + /// Lists the usage details for the defined scope. Usage details are available + /// via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and management group, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// May be used to expand the properties/additionalInfo or + /// properties/meterDetails within a list of usage details. By default, these + /// fields are not included when listing usage details. + /// + /// + /// May be used to filter usageDetails by properties/resourceGroup, + /// properties/resourceName, properties/resourceId, properties/chargeType, + /// properties/reservationId or tags. 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 (:). + /// + /// + /// 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 + /// usageDetails. + /// + /// + /// Allows to select different type of cost/usage records. Possible values + /// include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IUsageDetailsOperations operations, string scope, string expand = default(string), string filter = default(string), string skiptoken = default(string), int? top = default(int?), string metric = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(scope, expand, filter, skiptoken, top, metric, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Download usage details data. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and management group, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// Allows to select different type of cost/usage records. Possible values + /// include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + public static UsageDetailsDownloadResponse Download(this IUsageDetailsOperations operations, string scope, string metric = default(string)) + { + return operations.DownloadAsync(scope, metric).GetAwaiter().GetResult(); + } + + /// + /// Download usage details data. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and management group, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// Allows to select different type of cost/usage records. Possible values + /// include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + /// + /// The cancellation token. + /// + public static async Task DownloadAsync(this IUsageDetailsOperations operations, string scope, string metric = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DownloadWithHttpMessagesAsync(scope, metric, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Download usage details data. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and management group, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// Allows to select different type of cost/usage records. Possible values + /// include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + public static UsageDetailsDownloadResponse BeginDownload(this IUsageDetailsOperations operations, string scope, string metric = default(string)) + { + return operations.BeginDownloadAsync(scope, metric).GetAwaiter().GetResult(); + } + + /// + /// Download usage details data. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with usage details operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope, + /// '/providers/Microsoft.Billing/departments/{departmentId}' for Department + /// scope, + /// '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for + /// EnrollmentAccount scope and + /// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope. For subscription, billing account, department, + /// enrollment account and management group, you can also add billing period to + /// the scope using + /// '/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'. For e.g. + /// to specify billing period at department scope use + /// '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' + /// + /// + /// Allows to select different type of cost/usage records. Possible values + /// include: 'ActualCostMetricType', 'AmortizedCostMetricType', + /// 'UsageMetricType' + /// + /// + /// The cancellation token. + /// + public static async Task BeginDownloadAsync(this IUsageDetailsOperations operations, string scope, string metric = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDownloadWithHttpMessagesAsync(scope, metric, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the usage details for the defined scope. Usage details are available + /// via this API only for May 1, 2014 or later. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IUsageDetailsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the usage details for the defined scope. Usage details are available + /// via this API only for May 1, 2014 or later. + /// + /// + /// + /// 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 IUsageDetailsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}