diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/AlertsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/AlertsOperations.cs new file mode 100644 index 0000000000000..36a67ca861047 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/AlertsOperations.cs @@ -0,0 +1,891 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// AlertsOperations operations. + /// + internal partial class AlertsOperations : IServiceOperations, IAlertsOperations + { + /// + /// Initializes a new instance of the AlertsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AlertsOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Lists the alerts for scope defined. + /// + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// 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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + // 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.CostManagement/alerts").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 alert for the scope by alert ID. + /// + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Alert ID + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string scope, string alertId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (alertId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("alertId", alertId); + 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.CostManagement/alerts/{alertId}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{alertId}", alertId); + 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; + } + + /// + /// Dismisses the specified alert + /// + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Alert ID + /// + /// + /// Parameters supplied to the Dismiss Alert 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> DismissWithHttpMessagesAsync(string scope, string alertId, DismissAlertPayload parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (alertId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertId"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("alertId", alertId); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Dismiss", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/alerts/{alertId}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{alertId}", alertId); + 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("PATCH"); + _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) + { + 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 Alerts for external cloud provider type defined. + /// + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// 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> ListExternalWithHttpMessagesAsync(string externalCloudProviderType, string externalCloudProviderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (externalCloudProviderType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "externalCloudProviderType"); + } + if (externalCloudProviderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "externalCloudProviderId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("externalCloudProviderType", externalCloudProviderType); + tracingParameters.Add("externalCloudProviderId", externalCloudProviderId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListExternal", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/alerts").ToString(); + _url = _url.Replace("{externalCloudProviderType}", System.Uri.EscapeDataString(externalCloudProviderType)); + _url = _url.Replace("{externalCloudProviderId}", System.Uri.EscapeDataString(externalCloudProviderId)); + 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/AlertsOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/AlertsOperationsExtensions.cs new file mode 100644 index 0000000000000..61e40fa0c3ab6 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/AlertsOperationsExtensions.cs @@ -0,0 +1,305 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AlertsOperations. + /// + public static partial class AlertsOperationsExtensions + { + /// + /// Lists the alerts for scope defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + public static AlertsResult List(this IAlertsOperations operations, string scope) + { + return operations.ListAsync(scope).GetAwaiter().GetResult(); + } + + /// + /// Lists the alerts for scope defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IAlertsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the alert for the scope by alert ID. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Alert ID + /// + public static Alert Get(this IAlertsOperations operations, string scope, string alertId) + { + return operations.GetAsync(scope, alertId).GetAwaiter().GetResult(); + } + + /// + /// Gets the alert for the scope by alert ID. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Alert ID + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAlertsOperations operations, string scope, string alertId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scope, alertId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Dismisses the specified alert + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Alert ID + /// + /// + /// Parameters supplied to the Dismiss Alert operation. + /// + public static Alert Dismiss(this IAlertsOperations operations, string scope, string alertId, DismissAlertPayload parameters) + { + return operations.DismissAsync(scope, alertId, parameters).GetAwaiter().GetResult(); + } + + /// + /// Dismisses the specified alert + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Alert ID + /// + /// + /// Parameters supplied to the Dismiss Alert operation. + /// + /// + /// The cancellation token. + /// + public static async Task DismissAsync(this IAlertsOperations operations, string scope, string alertId, DismissAlertPayload parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DismissWithHttpMessagesAsync(scope, alertId, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the Alerts for external cloud provider type defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + public static AlertsResult ListExternal(this IAlertsOperations operations, string externalCloudProviderType, string externalCloudProviderId) + { + return operations.ListExternalAsync(externalCloudProviderType, externalCloudProviderId).GetAwaiter().GetResult(); + } + + /// + /// Lists the Alerts for external cloud provider type defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// The cancellation token. + /// + public static async Task ListExternalAsync(this IAlertsOperations operations, string externalCloudProviderType, string externalCloudProviderId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListExternalWithHttpMessagesAsync(externalCloudProviderType, externalCloudProviderId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitRecommendationsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitRecommendationsOperations.cs new file mode 100644 index 0000000000000..efa1b1972f8b6 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitRecommendationsOperations.cs @@ -0,0 +1,450 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// BenefitRecommendationsOperations operations. + /// + internal partial class BenefitRecommendationsOperations : IServiceOperations, IBenefitRecommendationsOperations + { + /// + /// Initializes a new instance of the BenefitRecommendationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal BenefitRecommendationsOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// List of recommendations for purchasing benefit (reservation or savings + /// plan). + /// + /// + /// + /// The scope associated with benefit recommendation details operations. This + /// includes '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resource group scope, + /// /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// BillingAccount scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope + /// + /// + /// Can be used to filter benefitRecommendations by: properties/scope with + /// allowed values ['Single', 'Shared'] and default value 'Shared'; and + /// properties/lookBackPeriod with allowed values ['Last7Days', 'Last30Days', + /// 'Last60Days'] and default value 'Last60Days'; properties/term with allowed + /// values ['P1Y', 'P3Y'] and default value 'P3Y'; kind with default value + /// 'SavingsPlan'; properties/armSkuName with allowed values ['Compute', 'SQL'] + /// - if mentioned kind SavingsPlan is applied implicitly; + /// properties/subscriptionId; properties/resourceGroup + /// + /// + /// May be used to order the recommendations by: properties/armSkuName. This + /// implicitly filters the results by the corresponding benefit type. + /// + /// + /// May be used to expand the properties by: properties/usage, + /// properties/allRecommendationDetails + /// + /// + /// 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 billingScope, string filter = default(string), string orderby = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (billingScope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingScope"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + tracingParameters.Add("orderby", orderby); + tracingParameters.Add("expand", expand); + tracingParameters.Add("billingScope", billingScope); + 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("/") ? "" : "/")), "{billingScope}/providers/Microsoft.CostManagement/benefitRecommendations").ToString(); + _url = _url.Replace("{billingScope}", billingScope); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (orderby != null) + { + _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderby))); + } + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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; + } + + /// + /// List of recommendations for purchasing benefit (reservation or savings + /// plan). + /// + /// + /// + /// 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitRecommendationsOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitRecommendationsOperationsExtensions.cs new file mode 100644 index 0000000000000..8d657eee8c0d6 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitRecommendationsOperationsExtensions.cs @@ -0,0 +1,151 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for BenefitRecommendationsOperations. + /// + public static partial class BenefitRecommendationsOperationsExtensions + { + /// + /// List of recommendations for purchasing benefit (reservation or savings + /// plan). + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with benefit recommendation details operations. This + /// includes '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resource group scope, + /// /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// BillingAccount scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope + /// + /// + /// Can be used to filter benefitRecommendations by: properties/scope with + /// allowed values ['Single', 'Shared'] and default value 'Shared'; and + /// properties/lookBackPeriod with allowed values ['Last7Days', 'Last30Days', + /// 'Last60Days'] and default value 'Last60Days'; properties/term with allowed + /// values ['P1Y', 'P3Y'] and default value 'P3Y'; kind with default value + /// 'SavingsPlan'; properties/armSkuName with allowed values ['Compute', 'SQL'] + /// - if mentioned kind SavingsPlan is applied implicitly; + /// properties/subscriptionId; properties/resourceGroup + /// + /// + /// May be used to order the recommendations by: properties/armSkuName. This + /// implicitly filters the results by the corresponding benefit type. + /// + /// + /// May be used to expand the properties by: properties/usage, + /// properties/allRecommendationDetails + /// + public static IPage List(this IBenefitRecommendationsOperations operations, string billingScope, string filter = default(string), string orderby = default(string), string expand = default(string)) + { + return operations.ListAsync(billingScope, filter, orderby, expand).GetAwaiter().GetResult(); + } + + /// + /// List of recommendations for purchasing benefit (reservation or savings + /// plan). + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with benefit recommendation details operations. This + /// includes '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resource group scope, + /// /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// BillingAccount scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope + /// + /// + /// Can be used to filter benefitRecommendations by: properties/scope with + /// allowed values ['Single', 'Shared'] and default value 'Shared'; and + /// properties/lookBackPeriod with allowed values ['Last7Days', 'Last30Days', + /// 'Last60Days'] and default value 'Last60Days'; properties/term with allowed + /// values ['P1Y', 'P3Y'] and default value 'P3Y'; kind with default value + /// 'SavingsPlan'; properties/armSkuName with allowed values ['Compute', 'SQL'] + /// - if mentioned kind SavingsPlan is applied implicitly; + /// properties/subscriptionId; properties/resourceGroup + /// + /// + /// May be used to order the recommendations by: properties/armSkuName. This + /// implicitly filters the results by the corresponding benefit type. + /// + /// + /// May be used to expand the properties by: properties/usage, + /// properties/allRecommendationDetails + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IBenefitRecommendationsOperations operations, string billingScope, string filter = default(string), string orderby = default(string), string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(billingScope, filter, orderby, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List of recommendations for purchasing benefit (reservation or savings + /// plan). + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IBenefitRecommendationsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List of recommendations for purchasing benefit (reservation or savings + /// plan). + /// + /// + /// + /// 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 IBenefitRecommendationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitUtilizationSummariesOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitUtilizationSummariesOperations.cs new file mode 100644 index 0000000000000..4fd3df334979e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitUtilizationSummariesOperations.cs @@ -0,0 +1,1562 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// BenefitUtilizationSummariesOperations operations. + /// + internal partial class BenefitUtilizationSummariesOperations : IServiceOperations, IBenefitUtilizationSummariesOperations + { + /// + /// Initializes a new instance of the BenefitUtilizationSummariesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal BenefitUtilizationSummariesOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Lists benefit utilization summaries for the provided billingAccount. This + /// API provides benefit utilization summaries only for enrollment accounts. + /// + /// + /// + /// Billing account ID + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// Supports filtering by properties/benefitType, properties/benefitId, + /// properties/benefitOrderId and properties/usageDate. properties/benefitType + /// is defaulted to savingsPlan. + /// + /// + /// 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>> ListByBillingAccountIdWithHttpMessagesAsync(string billingAccountId, string grainParameter = default(string), string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (billingAccountId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountId", billingAccountId); + tracingParameters.Add("grainParameter", grainParameter); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByBillingAccountId", 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.CostManagement/benefitUtilizationSummaries").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 (grainParameter != null) + { + _queryParameters.Add(string.Format("grainParameter={0}", System.Uri.EscapeDataString(grainParameter))); + } + 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; + } + + /// + /// Lists benefit utilization summaries for billingProfile. + /// + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// Supports filtering by properties/benefitType, properties/benefitId, + /// properties/benefitOrderId and properties/usageDate. properties/benefitType + /// is defaulted to savingsPlan. + /// + /// + /// 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>> ListByBillingProfileIdWithHttpMessagesAsync(string billingAccountId, string billingProfileId, string grainParameter = default(string), string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + 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("grainParameter", grainParameter); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByBillingProfileId", 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.CostManagement/benefitUtilizationSummaries").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 (grainParameter != null) + { + _queryParameters.Add(string.Format("grainParameter={0}", System.Uri.EscapeDataString(grainParameter))); + } + 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; + } + + /// + /// Lists the savings plan utilization summaries for daily or monthly grain. + /// + /// + /// + /// Savings plan order ID. + /// + /// + /// Supports filtering by properties/usageDate. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// 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>> ListBySavingsPlanOrderWithHttpMessagesAsync(string savingsPlanOrderId, string filter = default(string), string grainParameter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (savingsPlanOrderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "savingsPlanOrderId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + tracingParameters.Add("grainParameter", grainParameter); + tracingParameters.Add("savingsPlanOrderId", savingsPlanOrderId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySavingsPlanOrder", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries").ToString(); + _url = _url.Replace("{savingsPlanOrderId}", System.Uri.EscapeDataString(savingsPlanOrderId)); + 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 (grainParameter != null) + { + _queryParameters.Add(string.Format("grainParameter={0}", System.Uri.EscapeDataString(grainParameter))); + } + 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 savings plan utilization summaries for daily or monthly grain. + /// + /// + /// + /// Savings plan order ID. + /// + /// + /// Savings plan ID. + /// + /// + /// Supports filtering by properties/usageDate. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// 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>> ListBySavingsPlanIdWithHttpMessagesAsync(string savingsPlanOrderId, string savingsPlanId, string filter = default(string), string grainParameter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (savingsPlanOrderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "savingsPlanOrderId"); + } + if (savingsPlanId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "savingsPlanId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + tracingParameters.Add("grainParameter", grainParameter); + tracingParameters.Add("savingsPlanOrderId", savingsPlanOrderId); + tracingParameters.Add("savingsPlanId", savingsPlanId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySavingsPlanId", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries").ToString(); + _url = _url.Replace("{savingsPlanOrderId}", System.Uri.EscapeDataString(savingsPlanOrderId)); + _url = _url.Replace("{savingsPlanId}", System.Uri.EscapeDataString(savingsPlanId)); + 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 (grainParameter != null) + { + _queryParameters.Add(string.Format("grainParameter={0}", System.Uri.EscapeDataString(grainParameter))); + } + 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 benefit utilization summaries for the provided billingAccount. This + /// API provides benefit utilization summaries only for enrollment accounts. + /// + /// + /// + /// 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>> ListByBillingAccountIdNextWithHttpMessagesAsync(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, "ListByBillingAccountIdNext", 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 benefit utilization summaries for billingProfile. + /// + /// + /// + /// 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>> ListByBillingProfileIdNextWithHttpMessagesAsync(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, "ListByBillingProfileIdNext", 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 savings plan utilization 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>> ListBySavingsPlanOrderNextWithHttpMessagesAsync(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, "ListBySavingsPlanOrderNext", 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 savings plan utilization 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>> ListBySavingsPlanIdNextWithHttpMessagesAsync(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, "ListBySavingsPlanIdNext", 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitUtilizationSummariesOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitUtilizationSummariesOperationsExtensions.cs new file mode 100644 index 0000000000000..270b864348ae3 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/BenefitUtilizationSummariesOperationsExtensions.cs @@ -0,0 +1,393 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for BenefitUtilizationSummariesOperations. + /// + public static partial class BenefitUtilizationSummariesOperationsExtensions + { + /// + /// Lists benefit utilization summaries for the provided billingAccount. This + /// API provides benefit utilization summaries only for enrollment accounts. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing account ID + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// Supports filtering by properties/benefitType, properties/benefitId, + /// properties/benefitOrderId and properties/usageDate. properties/benefitType + /// is defaulted to savingsPlan. + /// + public static IPage ListByBillingAccountId(this IBenefitUtilizationSummariesOperations operations, string billingAccountId, string grainParameter = default(string), string filter = default(string)) + { + return operations.ListByBillingAccountIdAsync(billingAccountId, grainParameter, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists benefit utilization summaries for the provided billingAccount. This + /// API provides benefit utilization summaries only for enrollment accounts. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing account ID + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// Supports filtering by properties/benefitType, properties/benefitId, + /// properties/benefitOrderId and properties/usageDate. properties/benefitType + /// is defaulted to savingsPlan. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByBillingAccountIdAsync(this IBenefitUtilizationSummariesOperations operations, string billingAccountId, string grainParameter = default(string), string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByBillingAccountIdWithHttpMessagesAsync(billingAccountId, grainParameter, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists benefit utilization summaries for billingProfile. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// Supports filtering by properties/benefitType, properties/benefitId, + /// properties/benefitOrderId and properties/usageDate. properties/benefitType + /// is defaulted to savingsPlan. + /// + public static IPage ListByBillingProfileId(this IBenefitUtilizationSummariesOperations operations, string billingAccountId, string billingProfileId, string grainParameter = default(string), string filter = default(string)) + { + return operations.ListByBillingProfileIdAsync(billingAccountId, billingProfileId, grainParameter, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists benefit utilization summaries for billingProfile. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// Supports filtering by properties/benefitType, properties/benefitId, + /// properties/benefitOrderId and properties/usageDate. properties/benefitType + /// is defaulted to savingsPlan. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByBillingProfileIdAsync(this IBenefitUtilizationSummariesOperations operations, string billingAccountId, string billingProfileId, string grainParameter = default(string), string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByBillingProfileIdWithHttpMessagesAsync(billingAccountId, billingProfileId, grainParameter, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the savings plan utilization summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Savings plan order ID. + /// + /// + /// Supports filtering by properties/usageDate. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + public static IPage ListBySavingsPlanOrder(this IBenefitUtilizationSummariesOperations operations, string savingsPlanOrderId, string filter = default(string), string grainParameter = default(string)) + { + return operations.ListBySavingsPlanOrderAsync(savingsPlanOrderId, filter, grainParameter).GetAwaiter().GetResult(); + } + + /// + /// Lists the savings plan utilization summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Savings plan order ID. + /// + /// + /// Supports filtering by properties/usageDate. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySavingsPlanOrderAsync(this IBenefitUtilizationSummariesOperations operations, string savingsPlanOrderId, string filter = default(string), string grainParameter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySavingsPlanOrderWithHttpMessagesAsync(savingsPlanOrderId, filter, grainParameter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the savings plan utilization summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Savings plan order ID. + /// + /// + /// Savings plan ID. + /// + /// + /// Supports filtering by properties/usageDate. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + public static IPage ListBySavingsPlanId(this IBenefitUtilizationSummariesOperations operations, string savingsPlanOrderId, string savingsPlanId, string filter = default(string), string grainParameter = default(string)) + { + return operations.ListBySavingsPlanIdAsync(savingsPlanOrderId, savingsPlanId, filter, grainParameter).GetAwaiter().GetResult(); + } + + /// + /// Lists the savings plan utilization summaries for daily or monthly grain. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Savings plan order ID. + /// + /// + /// Savings plan ID. + /// + /// + /// Supports filtering by properties/usageDate. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySavingsPlanIdAsync(this IBenefitUtilizationSummariesOperations operations, string savingsPlanOrderId, string savingsPlanId, string filter = default(string), string grainParameter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySavingsPlanIdWithHttpMessagesAsync(savingsPlanOrderId, savingsPlanId, filter, grainParameter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists benefit utilization summaries for the provided billingAccount. This + /// API provides benefit utilization summaries only for enrollment accounts. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByBillingAccountIdNext(this IBenefitUtilizationSummariesOperations operations, string nextPageLink) + { + return operations.ListByBillingAccountIdNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists benefit utilization summaries for the provided billingAccount. This + /// API provides benefit utilization summaries only for enrollment accounts. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByBillingAccountIdNextAsync(this IBenefitUtilizationSummariesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByBillingAccountIdNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists benefit utilization summaries for billingProfile. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByBillingProfileIdNext(this IBenefitUtilizationSummariesOperations operations, string nextPageLink) + { + return operations.ListByBillingProfileIdNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists benefit utilization summaries for billingProfile. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByBillingProfileIdNextAsync(this IBenefitUtilizationSummariesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByBillingProfileIdNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the savings plan utilization 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 ListBySavingsPlanOrderNext(this IBenefitUtilizationSummariesOperations operations, string nextPageLink) + { + return operations.ListBySavingsPlanOrderNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the savings plan utilization 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> ListBySavingsPlanOrderNextAsync(this IBenefitUtilizationSummariesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySavingsPlanOrderNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the savings plan utilization 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 ListBySavingsPlanIdNext(this IBenefitUtilizationSummariesOperations operations, string nextPageLink) + { + return operations.ListBySavingsPlanIdNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the savings plan utilization 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> ListBySavingsPlanIdNextAsync(this IBenefitUtilizationSummariesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySavingsPlanIdNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/CostManagementClient.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/CostManagementClient.cs new file mode 100644 index 0000000000000..301705c78001f --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/CostManagementClient.cs @@ -0,0 +1,455 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + + /// + /// CostManagement management client provides access to CostManagement + /// resources for Azure Enterprise Subscriptions. + /// + public partial class CostManagementClient : ServiceClient, ICostManagementClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// The API version to use for this operation. + /// + public string ApiVersion { get; private set; } + + /// + /// Azure Subscription ID. + /// + public string SubscriptionId { get; set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When set to + /// true a unique x-ms-client-request-id value is generated and included in + /// each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IViewsOperations. + /// + public virtual IViewsOperations Views { get; private set; } + + /// + /// Gets the IAlertsOperations. + /// + public virtual IAlertsOperations Alerts { get; private set; } + + /// + /// Gets the IForecastOperations. + /// + public virtual IForecastOperations Forecast { get; private set; } + + /// + /// Gets the IDimensionsOperations. + /// + public virtual IDimensionsOperations Dimensions { get; private set; } + + /// + /// Gets the IQueryOperations. + /// + public virtual IQueryOperations Query { get; private set; } + + /// + /// Gets the IGenerateReservationDetailsReportOperations. + /// + public virtual IGenerateReservationDetailsReportOperations GenerateReservationDetailsReport { get; private set; } + + /// + /// Gets the IExportsOperations. + /// + public virtual IExportsOperations Exports { get; private set; } + + /// + /// Gets the IGenerateCostDetailsReportOperations. + /// + public virtual IGenerateCostDetailsReportOperations GenerateCostDetailsReport { get; private set; } + + /// + /// Gets the IGenerateDetailedCostReportOperations. + /// + public virtual IGenerateDetailedCostReportOperations GenerateDetailedCostReport { get; private set; } + + /// + /// Gets the IGenerateDetailedCostReportOperationResultsOperations. + /// + public virtual IGenerateDetailedCostReportOperationResultsOperations GenerateDetailedCostReportOperationResults { get; private set; } + + /// + /// Gets the IGenerateDetailedCostReportOperationStatusOperations. + /// + public virtual IGenerateDetailedCostReportOperationStatusOperations GenerateDetailedCostReportOperationStatus { get; private set; } + + /// + /// Gets the IPriceSheetOperations. + /// + public virtual IPriceSheetOperations PriceSheet { get; private set; } + + /// + /// Gets the IScheduledActionsOperations. + /// + public virtual IScheduledActionsOperations ScheduledActions { get; private set; } + + /// + /// Gets the IBenefitRecommendationsOperations. + /// + public virtual IBenefitRecommendationsOperations BenefitRecommendations { get; private set; } + + /// + /// Gets the IBenefitUtilizationSummariesOperations. + /// + public virtual IBenefitUtilizationSummariesOperations BenefitUtilizationSummaries { get; private set; } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling CostManagementClient.Dispose(). False: will not dispose provided httpClient + protected CostManagementClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected CostManagementClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected CostManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected CostManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected CostManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CostManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling CostManagementClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public CostManagementClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CostManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CostManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CostManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CostManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + Operations = new Operations(this); + Views = new ViewsOperations(this); + Alerts = new AlertsOperations(this); + Forecast = new ForecastOperations(this); + Dimensions = new DimensionsOperations(this); + Query = new QueryOperations(this); + GenerateReservationDetailsReport = new GenerateReservationDetailsReportOperations(this); + Exports = new ExportsOperations(this); + GenerateCostDetailsReport = new GenerateCostDetailsReportOperations(this); + GenerateDetailedCostReport = new GenerateDetailedCostReportOperations(this); + GenerateDetailedCostReportOperationResults = new GenerateDetailedCostReportOperationResultsOperations(this); + GenerateDetailedCostReportOperationStatus = new GenerateDetailedCostReportOperationStatusOperations(this); + PriceSheet = new PriceSheetOperations(this); + ScheduledActions = new ScheduledActionsOperations(this); + BenefitRecommendations = new BenefitRecommendationsOperations(this); + BenefitUtilizationSummaries = new BenefitUtilizationSummariesOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2022-10-01"; + AcceptLanguage = "en-US"; + LongRunningOperationRetryTimeout = 30; + GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("scope")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("scope")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("kind")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("kind")); + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/DimensionsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/DimensionsOperations.cs new file mode 100644 index 0000000000000..b65640f3c76af --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/DimensionsOperations.cs @@ -0,0 +1,502 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// DimensionsOperations operations. + /// + internal partial class DimensionsOperations : IServiceOperations, IDimensionsOperations + { + /// + /// Initializes a new instance of the DimensionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DimensionsOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Lists the dimensions by the defined scope. + /// + /// + /// + /// The scope associated with dimension 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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// 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"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("scope", scope); + tracingParameters.Add("skiptoken", skiptoken); + 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.CostManagement/dimensions").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 (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (skiptoken != null) + { + _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // 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 dimensions by the external cloud provider type. + /// + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// 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>> ByExternalCloudProviderTypeWithHttpMessagesAsync(string externalCloudProviderType, string externalCloudProviderId, ODataQuery odataQuery = default(ODataQuery), string skiptoken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (externalCloudProviderType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "externalCloudProviderType"); + } + if (externalCloudProviderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "externalCloudProviderId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("externalCloudProviderType", externalCloudProviderType); + tracingParameters.Add("externalCloudProviderId", externalCloudProviderId); + tracingParameters.Add("skiptoken", skiptoken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ByExternalCloudProviderType", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/dimensions").ToString(); + _url = _url.Replace("{externalCloudProviderType}", System.Uri.EscapeDataString(externalCloudProviderType)); + _url = _url.Replace("{externalCloudProviderId}", System.Uri.EscapeDataString(externalCloudProviderId)); + 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))); + } + if (skiptoken != null) + { + _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken))); + } + 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/DimensionsOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/DimensionsOperationsExtensions.cs new file mode 100644 index 0000000000000..ca25d96621ed6 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/DimensionsOperationsExtensions.cs @@ -0,0 +1,186 @@ +// +// 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.CostManagement +{ + 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 DimensionsOperations. + /// + public static partial class DimensionsOperationsExtensions + { + /// + /// Lists the dimensions by the defined scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with dimension 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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// 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 IEnumerable List(this IDimensionsOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery), string skiptoken = default(string)) + { + return operations.ListAsync(scope, odataQuery, skiptoken).GetAwaiter().GetResult(); + } + + /// + /// Lists the dimensions by the defined scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with dimension 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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// 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 IDimensionsOperations 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 dimensions by the external cloud provider type. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// 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 IEnumerable ByExternalCloudProviderType(this IDimensionsOperations operations, string externalCloudProviderType, string externalCloudProviderId, ODataQuery odataQuery = default(ODataQuery), string skiptoken = default(string)) + { + return operations.ByExternalCloudProviderTypeAsync(externalCloudProviderType, externalCloudProviderId, odataQuery, skiptoken).GetAwaiter().GetResult(); + } + + /// + /// Lists the dimensions by the external cloud provider type. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// 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> ByExternalCloudProviderTypeAsync(this IDimensionsOperations operations, string externalCloudProviderType, string externalCloudProviderId, ODataQuery odataQuery = default(ODataQuery), string skiptoken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ByExternalCloudProviderTypeWithHttpMessagesAsync(externalCloudProviderType, externalCloudProviderId, odataQuery, skiptoken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ExportsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ExportsOperations.cs new file mode 100644 index 0000000000000..c27cce7899561 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ExportsOperations.cs @@ -0,0 +1,1328 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// ExportsOperations operations. + /// + internal partial class ExportsOperations : IServiceOperations, IExportsOperations + { + /// + /// Initializes a new instance of the ExportsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ExportsOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// The operation to list all exports at the given scope. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// May be used to expand the properties within an export. Currently only + /// 'runHistory' is supported and will return information for the last run of + /// each export. + /// + /// + /// 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), 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // 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("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.CostManagement/exports").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 (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to get the export for the defined scope by export name. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// May be used to expand the properties within an export. Currently only + /// 'runHistory' is supported and will return information for the last 10 runs + /// of the export. + /// + /// + /// 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 exportName, string expand = 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"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (exportName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "exportName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("exportName", exportName); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/exports/{exportName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{exportName}", System.Uri.EscapeDataString(exportName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to create or update a export. Update operation requires + /// latest eTag to be set in the request. You may obtain the latest eTag by + /// performing a get operation. Create operation does not require eTag. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// Parameters supplied to the CreateOrUpdate Export 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 exportName, Export 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (exportName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "exportName"); + } + 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("exportName", exportName); + 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.CostManagement/exports/{exportName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{exportName}", System.Uri.EscapeDataString(exportName)); + 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 export. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export 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 exportName, 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (exportName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "exportName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("exportName", exportName); + 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.CostManagement/exports/{exportName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{exportName}", System.Uri.EscapeDataString(exportName)); + 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; + } + + /// + /// The operation to run an export. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export 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 ExecuteWithHttpMessagesAsync(string scope, string exportName, 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (exportName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "exportName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("exportName", exportName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Execute", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/exports/{exportName}/run").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{exportName}", System.Uri.EscapeDataString(exportName)); + 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) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to get the run history of an export for the defined scope and + /// export name. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export 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> GetExecutionHistoryWithHttpMessagesAsync(string scope, string exportName, 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (exportName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "exportName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("exportName", exportName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetExecutionHistory", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/exports/{exportName}/runHistory").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{exportName}", System.Uri.EscapeDataString(exportName)); + 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ExportsOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ExportsOperationsExtensions.cs new file mode 100644 index 0000000000000..c25d408444ab5 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ExportsOperationsExtensions.cs @@ -0,0 +1,501 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ExportsOperations. + /// + public static partial class ExportsOperationsExtensions + { + /// + /// The operation to list all exports at the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// May be used to expand the properties within an export. Currently only + /// 'runHistory' is supported and will return information for the last run of + /// each export. + /// + public static ExportListResult List(this IExportsOperations operations, string scope, string expand = default(string)) + { + return operations.ListAsync(scope, expand).GetAwaiter().GetResult(); + } + + /// + /// The operation to list all exports at the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// May be used to expand the properties within an export. Currently only + /// 'runHistory' is supported and will return information for the last run of + /// each export. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IExportsOperations operations, string scope, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(scope, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to get the export for the defined scope by export name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// May be used to expand the properties within an export. Currently only + /// 'runHistory' is supported and will return information for the last 10 runs + /// of the export. + /// + public static Export Get(this IExportsOperations operations, string scope, string exportName, string expand = default(string)) + { + return operations.GetAsync(scope, exportName, expand).GetAwaiter().GetResult(); + } + + /// + /// The operation to get the export for the defined scope by export name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// May be used to expand the properties within an export. Currently only + /// 'runHistory' is supported and will return information for the last 10 runs + /// of the export. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IExportsOperations operations, string scope, string exportName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scope, exportName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to create or update a export. Update operation requires + /// latest eTag to be set in the request. 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 export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// Parameters supplied to the CreateOrUpdate Export operation. + /// + public static Export CreateOrUpdate(this IExportsOperations operations, string scope, string exportName, Export parameters) + { + return operations.CreateOrUpdateAsync(scope, exportName, parameters).GetAwaiter().GetResult(); + } + + /// + /// The operation to create or update a export. Update operation requires + /// latest eTag to be set in the request. 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 export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// Parameters supplied to the CreateOrUpdate Export operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IExportsOperations operations, string scope, string exportName, Export parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(scope, exportName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to delete a export. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + public static void Delete(this IExportsOperations operations, string scope, string exportName) + { + operations.DeleteAsync(scope, exportName).GetAwaiter().GetResult(); + } + + /// + /// The operation to delete a export. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IExportsOperations operations, string scope, string exportName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(scope, exportName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// The operation to run an export. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + public static void Execute(this IExportsOperations operations, string scope, string exportName) + { + operations.ExecuteAsync(scope, exportName).GetAwaiter().GetResult(); + } + + /// + /// The operation to run an export. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// The cancellation token. + /// + public static async Task ExecuteAsync(this IExportsOperations operations, string scope, string exportName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.ExecuteWithHttpMessagesAsync(scope, exportName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// The operation to get the run history of an export for the defined scope and + /// export name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + public static ExportExecutionListResult GetExecutionHistory(this IExportsOperations operations, string scope, string exportName) + { + return operations.GetExecutionHistoryAsync(scope, exportName).GetAwaiter().GetResult(); + } + + /// + /// The operation to get the run history of an export for the defined scope and + /// export name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// The cancellation token. + /// + public static async Task GetExecutionHistoryAsync(this IExportsOperations operations, string scope, string exportName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetExecutionHistoryWithHttpMessagesAsync(scope, exportName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ForecastOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ForecastOperations.cs new file mode 100644 index 0000000000000..8e5c98e77705f --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ForecastOperations.cs @@ -0,0 +1,513 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// ForecastOperations operations. + /// + internal partial class ForecastOperations : IServiceOperations, IForecastOperations + { + /// + /// Initializes a new instance of the ForecastOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ForecastOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Lists the forecast charges for scope defined. + /// + /// + /// + /// The scope associated with forecast operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), + /// properties/chargeType or properties/grain. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. + /// + /// + /// 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> UsageWithHttpMessagesAsync(string scope, ForecastDefinition parameters, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + 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("filter", filter); + tracingParameters.Add("scope", scope); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Usage", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/forecast").ToString(); + _url = _url.Replace("{scope}", scope); + 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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // 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 forecast charges for external cloud provider type defined. + /// + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), + /// properties/chargeType or properties/grain. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. + /// + /// + /// 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> ExternalCloudProviderUsageWithHttpMessagesAsync(string externalCloudProviderType, string externalCloudProviderId, ForecastDefinition parameters, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (externalCloudProviderType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "externalCloudProviderType"); + } + if (externalCloudProviderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "externalCloudProviderId"); + } + 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("filter", filter); + tracingParameters.Add("externalCloudProviderType", externalCloudProviderType); + tracingParameters.Add("externalCloudProviderId", externalCloudProviderId); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ExternalCloudProviderUsage", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/forecast").ToString(); + _url = _url.Replace("{externalCloudProviderType}", System.Uri.EscapeDataString(externalCloudProviderType)); + _url = _url.Replace("{externalCloudProviderId}", System.Uri.EscapeDataString(externalCloudProviderId)); + 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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ForecastOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ForecastOperationsExtensions.cs new file mode 100644 index 0000000000000..ad64e918073ec --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ForecastOperationsExtensions.cs @@ -0,0 +1,183 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ForecastOperations. + /// + public static partial class ForecastOperationsExtensions + { + /// + /// Lists the forecast charges for scope defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with forecast operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), + /// properties/chargeType or properties/grain. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. + /// + public static ForecastResult Usage(this IForecastOperations operations, string scope, ForecastDefinition parameters, string filter = default(string)) + { + return operations.UsageAsync(scope, parameters, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists the forecast charges for scope defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with forecast operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), + /// properties/chargeType or properties/grain. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. + /// + /// + /// The cancellation token. + /// + public static async Task UsageAsync(this IForecastOperations operations, string scope, ForecastDefinition parameters, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UsageWithHttpMessagesAsync(scope, parameters, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the forecast charges for external cloud provider type defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), + /// properties/chargeType or properties/grain. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. + /// + public static ForecastResult ExternalCloudProviderUsage(this IForecastOperations operations, string externalCloudProviderType, string externalCloudProviderId, ForecastDefinition parameters, string filter = default(string)) + { + return operations.ExternalCloudProviderUsageAsync(externalCloudProviderType, externalCloudProviderId, parameters, filter).GetAwaiter().GetResult(); + } + + /// + /// Lists the forecast charges for external cloud provider type defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), + /// properties/chargeType or properties/grain. The filter supports 'eq', 'lt', + /// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + /// 'not'. + /// + /// + /// The cancellation token. + /// + public static async Task ExternalCloudProviderUsageAsync(this IForecastOperations operations, string externalCloudProviderType, string externalCloudProviderId, ForecastDefinition parameters, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExternalCloudProviderUsageWithHttpMessagesAsync(externalCloudProviderType, externalCloudProviderId, parameters, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateCostDetailsReportOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateCostDetailsReportOperations.cs new file mode 100644 index 0000000000000..94fe400be578b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateCostDetailsReportOperations.cs @@ -0,0 +1,515 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// GenerateCostDetailsReportOperations operations. + /// + internal partial class GenerateCostDetailsReportOperations : IServiceOperations, IGenerateCostDetailsReportOperations + { + /// + /// Initializes a new instance of the GenerateCostDetailsReportOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal GenerateCostDetailsReportOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// This API is the replacement for all previously release Usage Details APIs. + /// Request to generate a cost details report for the provided date range, + /// billing period (Only enterprise customers) or Invoice Id asynchronously at + /// a certain scope. The initial call to request a report will return a 202 + /// with a 'Location' and 'Retry-After' header. The 'Location' header will + /// provide the endpoint to poll to get the result of the report generation. + /// The 'Retry-After' provides the duration to wait before polling for the + /// generated report. A call to poll the report operation will provide a 202 + /// response with a 'Location' header if the operation is still in progress. + /// Once the report generation operation completes, the polling endpoint will + /// provide a 200 response along with details on the report blob(s) that are + /// available for download. The details on the file(s) available for download + /// will be available in the polling response body. + /// + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create cost details operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOperationWithHttpMessagesAsync(string scope, GenerateCostDetailsReportRequestDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginCreateOperationWithHttpMessagesAsync(scope, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + + /// + /// This API is the replacement for all previously release Usage Details APIs. + /// Request to generate a cost details report for the provided date range, + /// billing period (Only enterprise customers) or Invoice Id asynchronously at + /// a certain scope. The initial call to request a report will return a 202 + /// with a 'Location' and 'Retry-After' header. The 'Location' header will + /// provide the endpoint to poll to get the result of the report generation. + /// The 'Retry-After' provides the duration to wait before polling for the + /// generated report. A call to poll the report operation will provide a 202 + /// response with a 'Location' header if the operation is still in progress. + /// Once the report generation operation completes, the polling endpoint will + /// provide a 200 response along with details on the report blob(s) that are + /// available for download. The details on the file(s) available for download + /// will be available in the polling response body. + /// + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create cost details 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> BeginCreateOperationWithHttpMessagesAsync(string scope, GenerateCostDetailsReportRequestDefinition 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + 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("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOperation", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/generateCostDetailsReport").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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new GenerateCostDetailsReportErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + GenerateCostDetailsReportErrorResponse _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; + } + + /// + /// Get the result of the specified operation. This link is provided in the + /// CostDetails creation request response Location header. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// The target operation 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> BeginGetOperationResultsWithHttpMessagesAsync(string scope, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginGetOperationResults", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/costDetailsOperationResults/{operationId}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateCostDetailsReportOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateCostDetailsReportOperationsExtensions.cs new file mode 100644 index 0000000000000..89787e6e9afc1 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateCostDetailsReportOperationsExtensions.cs @@ -0,0 +1,249 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GenerateCostDetailsReportOperations. + /// + public static partial class GenerateCostDetailsReportOperationsExtensions + { + /// + /// This API is the replacement for all previously release Usage Details APIs. + /// Request to generate a cost details report for the provided date range, + /// billing period (Only enterprise customers) or Invoice Id asynchronously at + /// a certain scope. The initial call to request a report will return a 202 + /// with a 'Location' and 'Retry-After' header. The 'Location' header will + /// provide the endpoint to poll to get the result of the report generation. + /// The 'Retry-After' provides the duration to wait before polling for the + /// generated report. A call to poll the report operation will provide a 202 + /// response with a 'Location' header if the operation is still in progress. + /// Once the report generation operation completes, the polling endpoint will + /// provide a 200 response along with details on the report blob(s) that are + /// available for download. The details on the file(s) available for download + /// will be available in the polling response body. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create cost details operation. + /// + public static CostDetailsOperationResults CreateOperation(this IGenerateCostDetailsReportOperations operations, string scope, GenerateCostDetailsReportRequestDefinition parameters) + { + return operations.CreateOperationAsync(scope, parameters).GetAwaiter().GetResult(); + } + + /// + /// This API is the replacement for all previously release Usage Details APIs. + /// Request to generate a cost details report for the provided date range, + /// billing period (Only enterprise customers) or Invoice Id asynchronously at + /// a certain scope. The initial call to request a report will return a 202 + /// with a 'Location' and 'Retry-After' header. The 'Location' header will + /// provide the endpoint to poll to get the result of the report generation. + /// The 'Retry-After' provides the duration to wait before polling for the + /// generated report. A call to poll the report operation will provide a 202 + /// response with a 'Location' header if the operation is still in progress. + /// Once the report generation operation completes, the polling endpoint will + /// provide a 200 response along with details on the report blob(s) that are + /// available for download. The details on the file(s) available for download + /// will be available in the polling response body. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create cost details operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOperationAsync(this IGenerateCostDetailsReportOperations operations, string scope, GenerateCostDetailsReportRequestDefinition parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOperationWithHttpMessagesAsync(scope, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the result of the specified operation. This link is provided in the + /// CostDetails creation request response Location header. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// The target operation Id. + /// + public static CostDetailsOperationResults GetOperationResults(this IGenerateCostDetailsReportOperations operations, string scope, string operationId) + { + return operations.GetOperationResultsAsync(scope, operationId).GetAwaiter().GetResult(); + } + + /// + /// Get the result of the specified operation. This link is provided in the + /// CostDetails creation request response Location header. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// The target operation Id. + /// + /// + /// The cancellation token. + /// + public static async Task GetOperationResultsAsync(this IGenerateCostDetailsReportOperations operations, string scope, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetOperationResultsWithHttpMessagesAsync(scope, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// This API is the replacement for all previously release Usage Details APIs. + /// Request to generate a cost details report for the provided date range, + /// billing period (Only enterprise customers) or Invoice Id asynchronously at + /// a certain scope. The initial call to request a report will return a 202 + /// with a 'Location' and 'Retry-After' header. The 'Location' header will + /// provide the endpoint to poll to get the result of the report generation. + /// The 'Retry-After' provides the duration to wait before polling for the + /// generated report. A call to poll the report operation will provide a 202 + /// response with a 'Location' header if the operation is still in progress. + /// Once the report generation operation completes, the polling endpoint will + /// provide a 200 response along with details on the report blob(s) that are + /// available for download. The details on the file(s) available for download + /// will be available in the polling response body. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create cost details operation. + /// + public static CostDetailsOperationResults BeginCreateOperation(this IGenerateCostDetailsReportOperations operations, string scope, GenerateCostDetailsReportRequestDefinition parameters) + { + return operations.BeginCreateOperationAsync(scope, parameters).GetAwaiter().GetResult(); + } + + /// + /// This API is the replacement for all previously release Usage Details APIs. + /// Request to generate a cost details report for the provided date range, + /// billing period (Only enterprise customers) or Invoice Id asynchronously at + /// a certain scope. The initial call to request a report will return a 202 + /// with a 'Location' and 'Retry-After' header. The 'Location' header will + /// provide the endpoint to poll to get the result of the report generation. + /// The 'Retry-After' provides the duration to wait before polling for the + /// generated report. A call to poll the report operation will provide a 202 + /// response with a 'Location' header if the operation is still in progress. + /// Once the report generation operation completes, the polling endpoint will + /// provide a 200 response along with details on the report blob(s) that are + /// available for download. The details on the file(s) available for download + /// will be available in the polling response body. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create cost details operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOperationAsync(this IGenerateCostDetailsReportOperations operations, string scope, GenerateCostDetailsReportRequestDefinition parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOperationWithHttpMessagesAsync(scope, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the result of the specified operation. This link is provided in the + /// CostDetails creation request response Location header. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// The target operation Id. + /// + public static CostDetailsOperationResults BeginGetOperationResults(this IGenerateCostDetailsReportOperations operations, string scope, string operationId) + { + return operations.BeginGetOperationResultsAsync(scope, operationId).GetAwaiter().GetResult(); + } + + /// + /// Get the result of the specified operation. This link is provided in the + /// CostDetails creation request response Location header. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// The target operation Id. + /// + /// + /// The cancellation token. + /// + public static async Task BeginGetOperationResultsAsync(this IGenerateCostDetailsReportOperations operations, string scope, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginGetOperationResultsWithHttpMessagesAsync(scope, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationResultsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationResultsOperations.cs new file mode 100644 index 0000000000000..cb825180d15ae --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationResultsOperations.cs @@ -0,0 +1,250 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// GenerateDetailedCostReportOperationResultsOperations operations. + /// + internal partial class GenerateDetailedCostReportOperationResultsOperations : IServiceOperations, IGenerateDetailedCostReportOperationResultsOperations + { + /// + /// Initializes a new instance of the GenerateDetailedCostReportOperationResultsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal GenerateDetailedCostReportOperationResultsOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + + /// + /// Gets the result of the specified operation. The link with this operationId + /// is provided as a response header of the initial request. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// 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> BeginGetWithHttpMessagesAsync(string operationId, string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("scope", scope); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginGet", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/operationResults/{operationId}").ToString(); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + _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 && (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); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationResultsOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationResultsOperationsExtensions.cs new file mode 100644 index 0000000000000..a64ae30cd6e44 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationResultsOperationsExtensions.cs @@ -0,0 +1,113 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GenerateDetailedCostReportOperationResultsOperations. + /// + public static partial class GenerateDetailedCostReportOperationResultsOperationsExtensions + { + /// + /// Gets the result of the specified operation. The link with this operationId + /// is provided as a response header of the initial request. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + public static GenerateDetailedCostReportOperationResult Get(this IGenerateDetailedCostReportOperationResultsOperations operations, string operationId, string scope) + { + return operations.GetAsync(operationId, scope).GetAwaiter().GetResult(); + } + + /// + /// Gets the result of the specified operation. The link with this operationId + /// is provided as a response header of the initial request. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IGenerateDetailedCostReportOperationResultsOperations operations, string operationId, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(operationId, scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the result of the specified operation. The link with this operationId + /// is provided as a response header of the initial request. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + public static GenerateDetailedCostReportOperationResult BeginGet(this IGenerateDetailedCostReportOperationResultsOperations operations, string operationId, string scope) + { + return operations.BeginGetAsync(operationId, scope).GetAwaiter().GetResult(); + } + + /// + /// Gets the result of the specified operation. The link with this operationId + /// is provided as a response header of the initial request. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// The cancellation token. + /// + public static async Task BeginGetAsync(this IGenerateDetailedCostReportOperationResultsOperations operations, string operationId, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginGetWithHttpMessagesAsync(operationId, scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationStatusOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationStatusOperations.cs new file mode 100644 index 0000000000000..77d6ee0404f08 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationStatusOperations.cs @@ -0,0 +1,249 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// GenerateDetailedCostReportOperationStatusOperations operations. + /// + internal partial class GenerateDetailedCostReportOperationStatusOperations : IServiceOperations, IGenerateDetailedCostReportOperationStatusOperations + { + /// + /// Initializes a new instance of the GenerateDetailedCostReportOperationStatusOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal GenerateDetailedCostReportOperationStatusOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Get the status of the specified operation. This link is provided in the + /// GenerateDetailedCostReport creation request response header. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// 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 operationId, string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("operationId", operationId); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/operationStatus/{operationId}").ToString(); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + _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; + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationStatusOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationStatusOperationsExtensions.cs new file mode 100644 index 0000000000000..4be4b520d9a44 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationStatusOperationsExtensions.cs @@ -0,0 +1,69 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GenerateDetailedCostReportOperationStatusOperations. + /// + public static partial class GenerateDetailedCostReportOperationStatusOperationsExtensions + { + /// + /// Get the status of the specified operation. This link is provided in the + /// GenerateDetailedCostReport creation request response header. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + public static GenerateDetailedCostReportOperationStatuses Get(this IGenerateDetailedCostReportOperationStatusOperations operations, string operationId, string scope) + { + return operations.GetAsync(operationId, scope).GetAwaiter().GetResult(); + } + + /// + /// Get the status of the specified operation. This link is provided in the + /// GenerateDetailedCostReport creation request response header. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IGenerateDetailedCostReportOperationStatusOperations operations, string operationId, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(operationId, scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperations.cs new file mode 100644 index 0000000000000..5adcfb11f7b1e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperations.cs @@ -0,0 +1,305 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// GenerateDetailedCostReportOperations operations. + /// + internal partial class GenerateDetailedCostReportOperations : IServiceOperations, IGenerateDetailedCostReportOperations + { + /// + /// Initializes a new instance of the GenerateDetailedCostReportOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal GenerateDetailedCostReportOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Generates the detailed cost report for provided date range, billing + /// period(only enterprise customers) or Invoice ID asynchronously at a certain + /// scope. Call returns a 202 with header Azure-Consumption-AsyncOperation + /// providing a link to the operation created. A call on the operation will + /// provide the status and if the operation is completed the blob file where + /// generated detailed cost report is being stored. + /// + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create detailed cost report operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOperationWithHttpMessagesAsync(string scope, GenerateDetailedCostReportDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginCreateOperationWithHttpMessagesAsync(scope, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Generates the detailed cost report for provided date range, billing + /// period(only enterprise customers) or Invoice ID asynchronously at a certain + /// scope. Call returns a 202 with header Azure-Consumption-AsyncOperation + /// providing a link to the operation created. A call on the operation will + /// provide the status and if the operation is completed the blob file where + /// generated detailed cost report is being stored. + /// + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create detailed cost report 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> BeginCreateOperationWithHttpMessagesAsync(string scope, GenerateDetailedCostReportDefinition 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + 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("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOperation", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/generateDetailedCostReport").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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new GenerateDetailedCostReportErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + GenerateDetailedCostReportErrorResponse _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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationsExtensions.cs new file mode 100644 index 0000000000000..fa8d84cd45a54 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateDetailedCostReportOperationsExtensions.cs @@ -0,0 +1,133 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GenerateDetailedCostReportOperations. + /// + public static partial class GenerateDetailedCostReportOperationsExtensions + { + /// + /// Generates the detailed cost report for provided date range, billing + /// period(only enterprise customers) or Invoice ID asynchronously at a certain + /// scope. Call returns a 202 with header Azure-Consumption-AsyncOperation + /// providing a link to the operation created. A call on the operation will + /// provide the status and if the operation is completed the blob file where + /// generated detailed cost report is being stored. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create detailed cost report operation. + /// + public static GenerateDetailedCostReportOperationResult CreateOperation(this IGenerateDetailedCostReportOperations operations, string scope, GenerateDetailedCostReportDefinition parameters) + { + return operations.CreateOperationAsync(scope, parameters).GetAwaiter().GetResult(); + } + + /// + /// Generates the detailed cost report for provided date range, billing + /// period(only enterprise customers) or Invoice ID asynchronously at a certain + /// scope. Call returns a 202 with header Azure-Consumption-AsyncOperation + /// providing a link to the operation created. A call on the operation will + /// provide the status and if the operation is completed the blob file where + /// generated detailed cost report is being stored. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create detailed cost report operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOperationAsync(this IGenerateDetailedCostReportOperations operations, string scope, GenerateDetailedCostReportDefinition parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOperationWithHttpMessagesAsync(scope, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Generates the detailed cost report for provided date range, billing + /// period(only enterprise customers) or Invoice ID asynchronously at a certain + /// scope. Call returns a 202 with header Azure-Consumption-AsyncOperation + /// providing a link to the operation created. A call on the operation will + /// provide the status and if the operation is completed the blob file where + /// generated detailed cost report is being stored. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create detailed cost report operation. + /// + public static GenerateDetailedCostReportOperationResult BeginCreateOperation(this IGenerateDetailedCostReportOperations operations, string scope, GenerateDetailedCostReportDefinition parameters) + { + return operations.BeginCreateOperationAsync(scope, parameters).GetAwaiter().GetResult(); + } + + /// + /// Generates the detailed cost report for provided date range, billing + /// period(only enterprise customers) or Invoice ID asynchronously at a certain + /// scope. Call returns a 202 with header Azure-Consumption-AsyncOperation + /// providing a link to the operation created. A call on the operation will + /// provide the status and if the operation is completed the blob file where + /// generated detailed cost report is being stored. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing account, or + /// other billing scopes. For details, see https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create detailed cost report operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOperationAsync(this IGenerateDetailedCostReportOperations operations, string scope, GenerateDetailedCostReportDefinition parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOperationWithHttpMessagesAsync(scope, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateReservationDetailsReportOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateReservationDetailsReportOperations.cs new file mode 100644 index 0000000000000..2a207d738b514 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateReservationDetailsReportOperations.cs @@ -0,0 +1,576 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// GenerateReservationDetailsReportOperations operations. + /// + internal partial class GenerateReservationDetailsReportOperations : IServiceOperations, IGenerateReservationDetailsReportOperations + { + /// + /// Initializes a new instance of the GenerateReservationDetailsReportOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal GenerateReservationDetailsReportOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously based on enrollment id. The Reservation usage details can be + /// viewed only by certain enterprise roles. For more details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role + /// + /// + /// + /// Enrollment ID (Legacy BillingAccount ID) + /// + /// + /// Start Date + /// + /// + /// End Date + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> ByBillingAccountIdWithHttpMessagesAsync(string billingAccountId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginByBillingAccountIdWithHttpMessagesAsync(billingAccountId, startDate, endDate, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously by billing profile. The Reservation usage details can be + /// viewed by only certain enterprise roles by default. For more details on the + /// roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access + /// + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Start Date + /// + /// + /// End Date + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> ByBillingProfileIdWithHttpMessagesAsync(string billingAccountId, string billingProfileId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginByBillingProfileIdWithHttpMessagesAsync(billingAccountId, billingProfileId, startDate, endDate, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously based on enrollment id. The Reservation usage details can be + /// viewed only by certain enterprise roles. For more details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role + /// + /// + /// + /// Enrollment ID (Legacy BillingAccount ID) + /// + /// + /// Start Date + /// + /// + /// End Date + /// + /// + /// 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> BeginByBillingAccountIdWithHttpMessagesAsync(string billingAccountId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (billingAccountId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountId"); + } + if (startDate == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "startDate"); + } + if (endDate == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endDate"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // 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("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginByBillingAccountId", 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.CostManagement/generateReservationDetailsReport").ToString(); + _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); + List _queryParameters = new List(); + 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 (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; + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously by billing profile. The Reservation usage details can be + /// viewed by only certain enterprise roles by default. For more details on the + /// roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access + /// + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Start Date + /// + /// + /// End Date + /// + /// + /// 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> BeginByBillingProfileIdWithHttpMessagesAsync(string billingAccountId, string billingProfileId, string startDate, string endDate, 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 (startDate == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "startDate"); + } + if (endDate == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endDate"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // 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("startDate", startDate); + tracingParameters.Add("endDate", endDate); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginByBillingProfileId", 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.CostManagement/generateReservationDetailsReport").ToString(); + _url = _url.Replace("{billingAccountId}", System.Uri.EscapeDataString(billingAccountId)); + _url = _url.Replace("{billingProfileId}", System.Uri.EscapeDataString(billingProfileId)); + List _queryParameters = new List(); + 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 (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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateReservationDetailsReportOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateReservationDetailsReportOperationsExtensions.cs new file mode 100644 index 0000000000000..2ecb01325bdbd --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/GenerateReservationDetailsReportOperationsExtensions.cs @@ -0,0 +1,257 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GenerateReservationDetailsReportOperations. + /// + public static partial class GenerateReservationDetailsReportOperationsExtensions + { + /// + /// Generates the reservations details report for provided date range + /// asynchronously based on enrollment id. The Reservation usage details can be + /// viewed only by certain enterprise roles. For more details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Enrollment ID (Legacy BillingAccount ID) + /// + /// + /// Start Date + /// + /// + /// End Date + /// + public static OperationStatus ByBillingAccountId(this IGenerateReservationDetailsReportOperations operations, string billingAccountId, string startDate, string endDate) + { + return operations.ByBillingAccountIdAsync(billingAccountId, startDate, endDate).GetAwaiter().GetResult(); + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously based on enrollment id. The Reservation usage details can be + /// viewed only by certain enterprise roles. For more details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Enrollment ID (Legacy BillingAccount ID) + /// + /// + /// Start Date + /// + /// + /// End Date + /// + /// + /// The cancellation token. + /// + public static async Task ByBillingAccountIdAsync(this IGenerateReservationDetailsReportOperations operations, string billingAccountId, string startDate, string endDate, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ByBillingAccountIdWithHttpMessagesAsync(billingAccountId, startDate, endDate, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously by billing profile. The Reservation usage details can be + /// viewed by only certain enterprise roles by default. For more details on the + /// roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Start Date + /// + /// + /// End Date + /// + public static OperationStatus ByBillingProfileId(this IGenerateReservationDetailsReportOperations operations, string billingAccountId, string billingProfileId, string startDate, string endDate) + { + return operations.ByBillingProfileIdAsync(billingAccountId, billingProfileId, startDate, endDate).GetAwaiter().GetResult(); + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously by billing profile. The Reservation usage details can be + /// viewed by only certain enterprise roles by default. For more details on the + /// roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Start Date + /// + /// + /// End Date + /// + /// + /// The cancellation token. + /// + public static async Task ByBillingProfileIdAsync(this IGenerateReservationDetailsReportOperations operations, string billingAccountId, string billingProfileId, string startDate, string endDate, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ByBillingProfileIdWithHttpMessagesAsync(billingAccountId, billingProfileId, startDate, endDate, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously based on enrollment id. The Reservation usage details can be + /// viewed only by certain enterprise roles. For more details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Enrollment ID (Legacy BillingAccount ID) + /// + /// + /// Start Date + /// + /// + /// End Date + /// + public static OperationStatus BeginByBillingAccountId(this IGenerateReservationDetailsReportOperations operations, string billingAccountId, string startDate, string endDate) + { + return operations.BeginByBillingAccountIdAsync(billingAccountId, startDate, endDate).GetAwaiter().GetResult(); + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously based on enrollment id. The Reservation usage details can be + /// viewed only by certain enterprise roles. For more details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Enrollment ID (Legacy BillingAccount ID) + /// + /// + /// Start Date + /// + /// + /// End Date + /// + /// + /// The cancellation token. + /// + public static async Task BeginByBillingAccountIdAsync(this IGenerateReservationDetailsReportOperations operations, string billingAccountId, string startDate, string endDate, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginByBillingAccountIdWithHttpMessagesAsync(billingAccountId, startDate, endDate, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously by billing profile. The Reservation usage details can be + /// viewed by only certain enterprise roles by default. For more details on the + /// roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Start Date + /// + /// + /// End Date + /// + public static OperationStatus BeginByBillingProfileId(this IGenerateReservationDetailsReportOperations operations, string billingAccountId, string billingProfileId, string startDate, string endDate) + { + return operations.BeginByBillingProfileIdAsync(billingAccountId, billingProfileId, startDate, endDate).GetAwaiter().GetResult(); + } + + /// + /// Generates the reservations details report for provided date range + /// asynchronously by billing profile. The Reservation usage details can be + /// viewed by only certain enterprise roles by default. For more details on the + /// roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Start Date + /// + /// + /// End Date + /// + /// + /// The cancellation token. + /// + public static async Task BeginByBillingProfileIdAsync(this IGenerateReservationDetailsReportOperations operations, string billingAccountId, string billingProfileId, string startDate, string endDate, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginByBillingProfileIdWithHttpMessagesAsync(billingAccountId, billingProfileId, startDate, endDate, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IAlertsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IAlertsOperations.cs new file mode 100644 index 0000000000000..f8fd60bbc4613 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IAlertsOperations.cs @@ -0,0 +1,188 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AlertsOperations operations. + /// + public partial interface IAlertsOperations + { + /// + /// Lists the alerts for scope defined. + /// + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// 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 alert for the scope by alert ID. + /// + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Alert 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 scope, string alertId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Dismisses the specified alert + /// + /// + /// + /// The scope associated with alerts operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Alert ID + /// + /// + /// Parameters supplied to the Dismiss Alert 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> DismissWithHttpMessagesAsync(string scope, string alertId, DismissAlertPayload parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the Alerts for external cloud provider type defined. + /// + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked + /// account and 'externalBillingAccounts' for consolidated account. + /// Possible values include: 'externalSubscriptions', + /// 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// 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> ListExternalWithHttpMessagesAsync(string externalCloudProviderType, string externalCloudProviderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IBenefitRecommendationsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IBenefitRecommendationsOperations.cs new file mode 100644 index 0000000000000..0aad40f26774c --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IBenefitRecommendationsOperations.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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// BenefitRecommendationsOperations operations. + /// + public partial interface IBenefitRecommendationsOperations + { + /// + /// List of recommendations for purchasing benefit (reservation or + /// savings plan). + /// + /// + /// + /// The scope associated with benefit recommendation details + /// operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resource group scope, + /// /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for BillingAccount scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope + /// + /// + /// Can be used to filter benefitRecommendations by: properties/scope + /// with allowed values ['Single', 'Shared'] and default value + /// 'Shared'; and properties/lookBackPeriod with allowed values + /// ['Last7Days', 'Last30Days', 'Last60Days'] and default value + /// 'Last60Days'; properties/term with allowed values ['P1Y', 'P3Y'] + /// and default value 'P3Y'; kind with default value 'SavingsPlan'; + /// properties/armSkuName with allowed values ['Compute', 'SQL'] - if + /// mentioned kind SavingsPlan is applied implicitly; + /// properties/subscriptionId; properties/resourceGroup + /// + /// + /// May be used to order the recommendations by: properties/armSkuName. + /// This implicitly filters the results by the corresponding benefit + /// type. + /// + /// + /// May be used to expand the properties by: properties/usage, + /// properties/allRecommendationDetails + /// + /// + /// 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 billingScope, string filter = default(string), string orderby = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List of recommendations for purchasing benefit (reservation or + /// savings plan). + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IBenefitUtilizationSummariesOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IBenefitUtilizationSummariesOperations.cs new file mode 100644 index 0000000000000..7d11479f90d9b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IBenefitUtilizationSummariesOperations.cs @@ -0,0 +1,257 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// BenefitUtilizationSummariesOperations operations. + /// + public partial interface IBenefitUtilizationSummariesOperations + { + /// + /// Lists benefit utilization summaries for the provided + /// billingAccount. This API provides benefit utilization summaries + /// only for enrollment accounts. + /// + /// + /// + /// Billing account ID + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// Supports filtering by properties/benefitType, properties/benefitId, + /// properties/benefitOrderId and properties/usageDate. + /// properties/benefitType is defaulted to savingsPlan. + /// + /// + /// 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>> ListByBillingAccountIdWithHttpMessagesAsync(string billingAccountId, string grainParameter = default(string), string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists benefit utilization summaries for billingProfile. + /// + /// + /// + /// Billing account ID + /// + /// + /// Billing profile ID. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// Supports filtering by properties/benefitType, properties/benefitId, + /// properties/benefitOrderId and properties/usageDate. + /// properties/benefitType is defaulted to savingsPlan. + /// + /// + /// 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>> ListByBillingProfileIdWithHttpMessagesAsync(string billingAccountId, string billingProfileId, string grainParameter = default(string), string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the savings plan utilization summaries for daily or monthly + /// grain. + /// + /// + /// + /// Savings plan order ID. + /// + /// + /// Supports filtering by properties/usageDate. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// 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>> ListBySavingsPlanOrderWithHttpMessagesAsync(string savingsPlanOrderId, string filter = default(string), string grainParameter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the savings plan utilization summaries for daily or monthly + /// grain. + /// + /// + /// + /// Savings plan order ID. + /// + /// + /// Savings plan ID. + /// + /// + /// Supports filtering by properties/usageDate. + /// + /// + /// Daily or monthly grain. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + /// + /// 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>> ListBySavingsPlanIdWithHttpMessagesAsync(string savingsPlanOrderId, string savingsPlanId, string filter = default(string), string grainParameter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists benefit utilization summaries for the provided + /// billingAccount. This API provides benefit utilization summaries + /// only for enrollment accounts. + /// + /// + /// + /// 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>> ListByBillingAccountIdNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists benefit utilization summaries for billingProfile. + /// + /// + /// + /// 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>> ListByBillingProfileIdNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the savings plan utilization 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>> ListBySavingsPlanOrderNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the savings plan utilization 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>> ListBySavingsPlanIdNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ICostManagementClient.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ICostManagementClient.cs new file mode 100644 index 0000000000000..e0757ff23251d --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ICostManagementClient.cs @@ -0,0 +1,154 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// CostManagement management client provides access to CostManagement + /// resources for Azure Enterprise Subscriptions. + /// + public partial interface ICostManagementClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// The API version to use for this operation. + /// + string ApiVersion { get; } + + /// + /// Azure Subscription ID. + /// + string SubscriptionId { get; set; } + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IViewsOperations. + /// + IViewsOperations Views { get; } + + /// + /// Gets the IAlertsOperations. + /// + IAlertsOperations Alerts { get; } + + /// + /// Gets the IForecastOperations. + /// + IForecastOperations Forecast { get; } + + /// + /// Gets the IDimensionsOperations. + /// + IDimensionsOperations Dimensions { get; } + + /// + /// Gets the IQueryOperations. + /// + IQueryOperations Query { get; } + + /// + /// Gets the IGenerateReservationDetailsReportOperations. + /// + IGenerateReservationDetailsReportOperations GenerateReservationDetailsReport { get; } + + /// + /// Gets the IExportsOperations. + /// + IExportsOperations Exports { get; } + + /// + /// Gets the IGenerateCostDetailsReportOperations. + /// + IGenerateCostDetailsReportOperations GenerateCostDetailsReport { get; } + + /// + /// Gets the IGenerateDetailedCostReportOperations. + /// + IGenerateDetailedCostReportOperations GenerateDetailedCostReport { get; } + + /// + /// Gets the IGenerateDetailedCostReportOperationResultsOperations. + /// + IGenerateDetailedCostReportOperationResultsOperations GenerateDetailedCostReportOperationResults { get; } + + /// + /// Gets the IGenerateDetailedCostReportOperationStatusOperations. + /// + IGenerateDetailedCostReportOperationStatusOperations GenerateDetailedCostReportOperationStatus { get; } + + /// + /// Gets the IPriceSheetOperations. + /// + IPriceSheetOperations PriceSheet { get; } + + /// + /// Gets the IScheduledActionsOperations. + /// + IScheduledActionsOperations ScheduledActions { get; } + + /// + /// Gets the IBenefitRecommendationsOperations. + /// + IBenefitRecommendationsOperations BenefitRecommendations { get; } + + /// + /// Gets the IBenefitUtilizationSummariesOperations. + /// + IBenefitUtilizationSummariesOperations BenefitUtilizationSummaries { get; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IDimensionsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IDimensionsOperations.cs new file mode 100644 index 0000000000000..c866dd96e2f74 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IDimensionsOperations.cs @@ -0,0 +1,118 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// DimensionsOperations operations. + /// + public partial interface IDimensionsOperations + { + /// + /// Lists the dimensions by the defined scope. + /// + /// + /// + /// The scope associated with dimension 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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// 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 dimensions by the external cloud provider type. + /// + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked + /// account and 'externalBillingAccounts' for consolidated account. + /// Possible values include: 'externalSubscriptions', + /// 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// 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>> ByExternalCloudProviderTypeWithHttpMessagesAsync(string externalCloudProviderType, string externalCloudProviderId, ODataQuery odataQuery = default(ODataQuery), string skiptoken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IExportsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IExportsOperations.cs new file mode 100644 index 0000000000000..ab2296e4e4942 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IExportsOperations.cs @@ -0,0 +1,294 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ExportsOperations operations. + /// + public partial interface IExportsOperations + { + /// + /// The operation to list all exports at the given scope. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// May be used to expand the properties within an export. Currently + /// only 'runHistory' is supported and will return information for the + /// last run of each export. + /// + /// + /// 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), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to get the export for the defined scope by export + /// name. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// May be used to expand the properties within an export. Currently + /// only 'runHistory' is supported and will return information for the + /// last 10 runs of the export. + /// + /// + /// 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 exportName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to create or update a export. Update operation + /// requires latest eTag to be set in the request. You may obtain the + /// latest eTag by performing a get operation. Create operation does + /// not require eTag. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export Name. + /// + /// + /// Parameters supplied to the CreateOrUpdate Export 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 exportName, Export parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to delete a export. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export 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 exportName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to run an export. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export 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 ExecuteWithHttpMessagesAsync(string scope, string exportName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to get the run history of an export for the defined + /// scope and export name. + /// + /// + /// + /// The scope associated with export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Export 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> GetExecutionHistoryWithHttpMessagesAsync(string scope, string exportName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IForecastOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IForecastOperations.cs new file mode 100644 index 0000000000000..333588a382f31 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IForecastOperations.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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ForecastOperations operations. + /// + public partial interface IForecastOperations + { + /// + /// Lists the forecast charges for scope defined. + /// + /// + /// + /// The scope associated with forecast operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Parameters supplied to the CreateOrUpdate Forecast Config + /// operation. + /// + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), + /// properties/chargeType or properties/grain. The filter supports + /// 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently + /// support 'ne', 'or', or 'not'. + /// + /// + /// 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> UsageWithHttpMessagesAsync(string scope, ForecastDefinition parameters, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the forecast charges for external cloud provider type + /// defined. + /// + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked + /// account and 'externalBillingAccounts' for consolidated account. + /// Possible values include: 'externalSubscriptions', + /// 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// Parameters supplied to the CreateOrUpdate Forecast Config + /// operation. + /// + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), + /// properties/chargeType or properties/grain. The filter supports + /// 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently + /// support 'ne', 'or', or 'not'. + /// + /// + /// 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> ExternalCloudProviderUsageWithHttpMessagesAsync(string externalCloudProviderType, string externalCloudProviderId, ForecastDefinition parameters, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateCostDetailsReportOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateCostDetailsReportOperations.cs new file mode 100644 index 0000000000000..dffcc3caa2bc7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateCostDetailsReportOperations.cs @@ -0,0 +1,167 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GenerateCostDetailsReportOperations operations. + /// + public partial interface IGenerateCostDetailsReportOperations + { + /// + /// This API is the replacement for all previously release Usage + /// Details APIs. Request to generate a cost details report for the + /// provided date range, billing period (Only enterprise customers) or + /// Invoice Id asynchronously at a certain scope. The initial call to + /// request a report will return a 202 with a 'Location' and + /// 'Retry-After' header. The 'Location' header will provide the + /// endpoint to poll to get the result of the report generation. The + /// 'Retry-After' provides the duration to wait before polling for the + /// generated report. A call to poll the report operation will provide + /// a 202 response with a 'Location' header if the operation is still + /// in progress. Once the report generation operation completes, the + /// polling endpoint will provide a 200 response along with details on + /// the report blob(s) that are available for download. The details on + /// the file(s) available for download will be available in the polling + /// response body. + /// + /// + /// + /// The ARM Resource ID for subscription, resource group, billing + /// account, or other billing scopes. For details, see + /// https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create cost details 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> CreateOperationWithHttpMessagesAsync(string scope, GenerateCostDetailsReportRequestDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the result of the specified operation. This link is provided in + /// the CostDetails creation request response Location header. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing + /// account, or other billing scopes. For details, see + /// https://aka.ms/costmgmt/scopes. + /// + /// + /// The target operation 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> GetOperationResultsWithHttpMessagesAsync(string scope, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// This API is the replacement for all previously release Usage + /// Details APIs. Request to generate a cost details report for the + /// provided date range, billing period (Only enterprise customers) or + /// Invoice Id asynchronously at a certain scope. The initial call to + /// request a report will return a 202 with a 'Location' and + /// 'Retry-After' header. The 'Location' header will provide the + /// endpoint to poll to get the result of the report generation. The + /// 'Retry-After' provides the duration to wait before polling for the + /// generated report. A call to poll the report operation will provide + /// a 202 response with a 'Location' header if the operation is still + /// in progress. Once the report generation operation completes, the + /// polling endpoint will provide a 200 response along with details on + /// the report blob(s) that are available for download. The details on + /// the file(s) available for download will be available in the polling + /// response body. + /// + /// + /// + /// The ARM Resource ID for subscription, resource group, billing + /// account, or other billing scopes. For details, see + /// https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create cost details 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> BeginCreateOperationWithHttpMessagesAsync(string scope, GenerateCostDetailsReportRequestDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the result of the specified operation. This link is provided in + /// the CostDetails creation request response Location header. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing + /// account, or other billing scopes. For details, see + /// https://aka.ms/costmgmt/scopes. + /// + /// + /// The target operation 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> BeginGetOperationResultsWithHttpMessagesAsync(string scope, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateDetailedCostReportOperationResultsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateDetailedCostReportOperationResultsOperations.cs new file mode 100644 index 0000000000000..7c7a4b60f418d --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateDetailedCostReportOperationResultsOperations.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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GenerateDetailedCostReportOperationResultsOperations operations. + /// + public partial interface IGenerateDetailedCostReportOperationResultsOperations + { + /// + /// Gets the result of the specified operation. The link with this + /// operationId is provided as a response header of the initial + /// request. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing + /// account, or other billing scopes. For details, see + /// https://aka.ms/costmgmt/scopes. + /// + /// + /// 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 operationId, string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the result of the specified operation. The link with this + /// operationId is provided as a response header of the initial + /// request. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing + /// account, or other billing scopes. For details, see + /// https://aka.ms/costmgmt/scopes. + /// + /// + /// 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> BeginGetWithHttpMessagesAsync(string operationId, string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateDetailedCostReportOperationStatusOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateDetailedCostReportOperationStatusOperations.cs new file mode 100644 index 0000000000000..cec301c418a79 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateDetailedCostReportOperationStatusOperations.cs @@ -0,0 +1,55 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GenerateDetailedCostReportOperationStatusOperations operations. + /// + public partial interface IGenerateDetailedCostReportOperationStatusOperations + { + /// + /// Get the status of the specified operation. This link is provided in + /// the GenerateDetailedCostReport creation request response header. + /// + /// + /// The target operation Id. + /// + /// + /// The ARM Resource ID for subscription, resource group, billing + /// account, or other billing scopes. For details, see + /// https://aka.ms/costmgmt/scopes. + /// + /// + /// 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 operationId, string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateDetailedCostReportOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateDetailedCostReportOperations.cs new file mode 100644 index 0000000000000..62f1706f1047b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateDetailedCostReportOperations.cs @@ -0,0 +1,95 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GenerateDetailedCostReportOperations operations. + /// + public partial interface IGenerateDetailedCostReportOperations + { + /// + /// Generates the detailed cost report for provided date range, billing + /// period(only enterprise customers) or Invoice ID asynchronously at a + /// certain scope. Call returns a 202 with header + /// Azure-Consumption-AsyncOperation providing a link to the operation + /// created. A call on the operation will provide the status and if the + /// operation is completed the blob file where generated detailed cost + /// report is being stored. + /// + /// + /// + /// The ARM Resource ID for subscription, resource group, billing + /// account, or other billing scopes. For details, see + /// https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create detailed cost report 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> CreateOperationWithHttpMessagesAsync(string scope, GenerateDetailedCostReportDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Generates the detailed cost report for provided date range, billing + /// period(only enterprise customers) or Invoice ID asynchronously at a + /// certain scope. Call returns a 202 with header + /// Azure-Consumption-AsyncOperation providing a link to the operation + /// created. A call on the operation will provide the status and if the + /// operation is completed the blob file where generated detailed cost + /// report is being stored. + /// + /// + /// + /// The ARM Resource ID for subscription, resource group, billing + /// account, or other billing scopes. For details, see + /// https://aka.ms/costmgmt/scopes. + /// + /// + /// Parameters supplied to the Create detailed cost report 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> BeginCreateOperationWithHttpMessagesAsync(string scope, GenerateDetailedCostReportDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateReservationDetailsReportOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateReservationDetailsReportOperations.cs new file mode 100644 index 0000000000000..dfdf02aa41f33 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IGenerateReservationDetailsReportOperations.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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GenerateReservationDetailsReportOperations operations. + /// + public partial interface IGenerateReservationDetailsReportOperations + { + /// + /// Generates the reservations details report for provided date range + /// asynchronously based on enrollment id. The Reservation usage + /// details can be viewed only by certain enterprise roles. For more + /// details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role + /// + /// + /// + /// Enrollment ID (Legacy BillingAccount 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> ByBillingAccountIdWithHttpMessagesAsync(string billingAccountId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Generates the reservations details report for provided date range + /// asynchronously by billing profile. The Reservation usage details + /// can be viewed by only certain enterprise roles by default. For more + /// details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access + /// + /// + /// + /// Billing account 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> ByBillingProfileIdWithHttpMessagesAsync(string billingAccountId, string billingProfileId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Generates the reservations details report for provided date range + /// asynchronously based on enrollment id. The Reservation usage + /// details can be viewed only by certain enterprise roles. For more + /// details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role + /// + /// + /// + /// Enrollment ID (Legacy BillingAccount 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> BeginByBillingAccountIdWithHttpMessagesAsync(string billingAccountId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Generates the reservations details report for provided date range + /// asynchronously by billing profile. The Reservation usage details + /// can be viewed by only certain enterprise roles by default. For more + /// details on the roles see, + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access + /// + /// + /// + /// Billing account 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> BeginByBillingProfileIdWithHttpMessagesAsync(string billingAccountId, string billingProfileId, string startDate, string endDate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IOperations.cs new file mode 100644 index 0000000000000..2c27cf7db3d7f --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IOperations.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + public partial interface IOperations + { + /// + /// Lists all of the available cost management REST API operations. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all of the available cost management REST API operations. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IPriceSheetOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IPriceSheetOperations.cs new file mode 100644 index 0000000000000..6e8eb9e09bcdb --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IPriceSheetOperations.cs @@ -0,0 +1,149 @@ +// +// 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.CostManagement +{ + 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 a URL to download the pricesheet for an invoice. The operation + /// is supported for billing accounts with agreement type Microsoft + /// Partner Agreement or Microsoft Customer Agreement. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The ID that uniquely identifies an invoice. + /// + /// + /// 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 billingAccountName, string billingProfileName, string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a URL to download the current month's pricesheet for a billing + /// profile. The operation is supported for billing accounts with + /// agreement type Microsoft Partner Agreement or Microsoft Customer + /// Agreement.Due to Azure product growth, the Azure price sheet + /// download experience in this preview version will be updated from a + /// single csv file to a Zip file containing multiple csv files, each + /// with max 200k records. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// 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> DownloadByBillingProfileWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a URL to download the pricesheet for an invoice. The operation + /// is supported for billing accounts with agreement type Microsoft + /// Partner Agreement or Microsoft Customer Agreement. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The ID that uniquely identifies an invoice. + /// + /// + /// 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 billingAccountName, string billingProfileName, string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a URL to download the current month's pricesheet for a billing + /// profile. The operation is supported for billing accounts with + /// agreement type Microsoft Partner Agreement or Microsoft Customer + /// Agreement.Due to Azure product growth, the Azure price sheet + /// download experience in this preview version will be updated from a + /// single csv file to a Zip file containing multiple csv files, each + /// with max 200k records. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// 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> BeginDownloadByBillingProfileWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IQueryOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IQueryOperations.cs new file mode 100644 index 0000000000000..e7783c2b82e6c --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IQueryOperations.cs @@ -0,0 +1,105 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// QueryOperations operations. + /// + public partial interface IQueryOperations + { + /// + /// Query the usage data for scope defined. + /// + /// + /// + /// The scope associated with query and export operations. This + /// includes '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Parameters supplied to the CreateOrUpdate Query Config 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> UsageWithHttpMessagesAsync(string scope, QueryDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Query the usage data for external cloud provider type defined. + /// + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked + /// account and 'externalBillingAccounts' for consolidated account. + /// Possible values include: 'externalSubscriptions', + /// 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// Parameters supplied to the CreateOrUpdate Query Config 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> UsageByExternalCloudProviderTypeWithHttpMessagesAsync(string externalCloudProviderType, string externalCloudProviderId, QueryDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IScheduledActionsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IScheduledActionsOperations.cs new file mode 100644 index 0000000000000..a47e5b956df71 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IScheduledActionsOperations.cs @@ -0,0 +1,467 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ScheduledActionsOperations operations. + /// + public partial interface IScheduledActionsOperations + { + /// + /// List all private scheduled actions. + /// + /// + /// + /// May be used to filter scheduled actions by properties/viewId. + /// Supported operator is 'eq'. + /// + /// + /// 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 filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all shared scheduled actions within the given scope. + /// + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only + /// available on subscription scope. + /// + /// + /// May be used to filter scheduled actions by properties/viewId. + /// Supported operator is 'eq'. + /// + /// + /// 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)); + /// + /// Create or update a private scheduled action. + /// + /// + /// Scheduled action name. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// 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 name, ScheduledAction scheduledAction, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the private scheduled action by name. + /// + /// + /// + /// Scheduled action 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 name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a private scheduled action. + /// + /// + /// + /// Scheduled action 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 name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a shared scheduled action within the given scope. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only + /// available on subscription scope. + /// + /// + /// Scheduled action name. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// 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> CreateOrUpdateByScopeWithHttpMessagesAsync(string scope, string name, ScheduledAction scheduledAction, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the shared scheduled action from the given scope by name. + /// + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only + /// available on subscription scope. + /// + /// + /// Scheduled action 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> GetByScopeWithHttpMessagesAsync(string scope, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a scheduled action within the given scope. + /// + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only + /// available on subscription scope. + /// + /// + /// Scheduled action 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 DeleteByScopeWithHttpMessagesAsync(string scope, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Processes a private scheduled action. + /// + /// + /// Scheduled action 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 RunWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Runs a shared scheduled action within the given scope. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only + /// available on subscription scope. + /// + /// + /// Scheduled action 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 RunByScopeWithHttpMessagesAsync(string scope, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks availability and correctness of the name for a scheduled + /// action. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// 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> CheckNameAvailabilityWithHttpMessagesAsync(CheckNameAvailabilityRequest checkNameAvailabilityRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks availability and correctness of the name for a scheduled + /// action within the given scope. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only + /// available on subscription scope. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// 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> CheckNameAvailabilityByScopeWithHttpMessagesAsync(string scope, CheckNameAvailabilityRequest checkNameAvailabilityRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all private scheduled actions. + /// + /// + /// + /// 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)); + /// + /// List all shared scheduled actions within the given 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>> ListByScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IViewsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IViewsOperations.cs new file mode 100644 index 0000000000000..113b114257aa9 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IViewsOperations.cs @@ -0,0 +1,345 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ViewsOperations operations. + /// + public partial interface IViewsOperations + { + /// + /// Lists all views by tenant and object. + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all views at the given scope. + /// + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription 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>> ListByScopeWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the view by view name. + /// + /// + /// + /// View 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 viewName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to create or update a view. Update operation requires + /// latest eTag to be set in the request. You may obtain the latest + /// eTag by performing a get operation. Create operation does not + /// require eTag. + /// + /// + /// + /// View name + /// + /// + /// Parameters supplied to the CreateOrUpdate View 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 viewName, View parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to delete a view. + /// + /// + /// + /// View 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 viewName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the view for the defined scope by view name. + /// + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View 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> GetByScopeWithHttpMessagesAsync(string scope, string viewName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to create or update a view. Update operation requires + /// latest eTag to be set in the request. You may obtain the latest + /// eTag by performing a get operation. Create operation does not + /// require eTag. + /// + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View name + /// + /// + /// Parameters supplied to the CreateOrUpdate View 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> CreateOrUpdateByScopeWithHttpMessagesAsync(string scope, string viewName, View parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to delete a view. + /// + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View 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 DeleteByScopeWithHttpMessagesAsync(string scope, string viewName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all views by tenant and object. + /// + /// + /// + /// 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)); + /// + /// Lists all views at the given 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>> ListByScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AccumulatedType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AccumulatedType.cs new file mode 100644 index 0000000000000..a2e19985def02 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AccumulatedType.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.CostManagement.Models +{ + + /// + /// Defines values for AccumulatedType. + /// + public static class AccumulatedType + { + public const string True = "true"; + public const string False = "false"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ActionType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ActionType.cs new file mode 100644 index 0000000000000..8db884aaff372 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ActionType.cs @@ -0,0 +1,21 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for ActionType. + /// + public static class ActionType + { + public const string Internal = "Internal"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Alert.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Alert.cs new file mode 100644 index 0000000000000..d4c39bc691c5e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Alert.cs @@ -0,0 +1,149 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// An individual alert. + /// + [Rest.Serialization.JsonTransformation] + public partial class Alert : CostManagementProxyResource + { + /// + /// Initializes a new instance of the Alert class. + /// + public Alert() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Alert 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. + /// defines the type of alert + /// Alert description + /// Source of alert. Possible values include: + /// 'Preset', 'User' + /// Alert details + /// related budget + /// alert status. Possible values include: 'None', + /// 'Active', 'Overridden', 'Resolved', 'Dismissed' + /// dateTime in which alert was + /// created + /// dateTime in which alert was closed + /// dateTime in which alert was last + /// modified + /// User who last modified the + /// alert + /// dateTime in which the alert + /// status was last modified + public Alert(string id = default(string), string name = default(string), string type = default(string), string eTag = default(string), AlertPropertiesDefinition definition = default(AlertPropertiesDefinition), string description = default(string), string source = default(string), AlertPropertiesDetails details = default(AlertPropertiesDetails), string costEntityId = default(string), string status = default(string), string creationTime = default(string), string closeTime = default(string), string modificationTime = default(string), string statusModificationUserName = default(string), string statusModificationTime = default(string)) + : base(id, name, type, eTag) + { + Definition = definition; + Description = description; + Source = source; + Details = details; + CostEntityId = costEntityId; + Status = status; + CreationTime = creationTime; + CloseTime = closeTime; + ModificationTime = modificationTime; + StatusModificationUserName = statusModificationUserName; + StatusModificationTime = statusModificationTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets defines the type of alert + /// + [JsonProperty(PropertyName = "properties.definition")] + public AlertPropertiesDefinition Definition { get; set; } + + /// + /// Gets or sets alert description + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets source of alert. Possible values include: 'Preset', + /// 'User' + /// + [JsonProperty(PropertyName = "properties.source")] + public string Source { get; set; } + + /// + /// Gets or sets alert details + /// + [JsonProperty(PropertyName = "properties.details")] + public AlertPropertiesDetails Details { get; set; } + + /// + /// Gets or sets related budget + /// + [JsonProperty(PropertyName = "properties.costEntityId")] + public string CostEntityId { get; set; } + + /// + /// Gets or sets alert status. Possible values include: 'None', + /// 'Active', 'Overridden', 'Resolved', 'Dismissed' + /// + [JsonProperty(PropertyName = "properties.status")] + public string Status { get; set; } + + /// + /// Gets or sets dateTime in which alert was created + /// + [JsonProperty(PropertyName = "properties.creationTime")] + public string CreationTime { get; set; } + + /// + /// Gets or sets dateTime in which alert was closed + /// + [JsonProperty(PropertyName = "properties.closeTime")] + public string CloseTime { get; set; } + + /// + /// Gets or sets dateTime in which alert was last modified + /// + [JsonProperty(PropertyName = "properties.modificationTime")] + public string ModificationTime { get; set; } + + /// + /// Gets or sets user who last modified the alert + /// + [JsonProperty(PropertyName = "properties.statusModificationUserName")] + public string StatusModificationUserName { get; set; } + + /// + /// Gets or sets dateTime in which the alert status was last modified + /// + [JsonProperty(PropertyName = "properties.statusModificationTime")] + public string StatusModificationTime { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertCategory.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertCategory.cs new file mode 100644 index 0000000000000..ed6f45f22a16b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertCategory.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + + /// + /// Defines values for AlertCategory. + /// + public static class AlertCategory + { + public const string Cost = "Cost"; + public const string Usage = "Usage"; + public const string Billing = "Billing"; + public const string System = "System"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertCriteria.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertCriteria.cs new file mode 100644 index 0000000000000..330062018e85c --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertCriteria.cs @@ -0,0 +1,34 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for AlertCriteria. + /// + public static class AlertCriteria + { + public const string CostThresholdExceeded = "CostThresholdExceeded"; + public const string UsageThresholdExceeded = "UsageThresholdExceeded"; + public const string CreditThresholdApproaching = "CreditThresholdApproaching"; + public const string CreditThresholdReached = "CreditThresholdReached"; + public const string QuotaThresholdApproaching = "QuotaThresholdApproaching"; + public const string QuotaThresholdReached = "QuotaThresholdReached"; + public const string MultiCurrency = "MultiCurrency"; + public const string ForecastCostThresholdExceeded = "ForecastCostThresholdExceeded"; + public const string ForecastUsageThresholdExceeded = "ForecastUsageThresholdExceeded"; + public const string InvoiceDueDateApproaching = "InvoiceDueDateApproaching"; + public const string InvoiceDueDateReached = "InvoiceDueDateReached"; + public const string CrossCloudNewDataAvailable = "CrossCloudNewDataAvailable"; + public const string CrossCloudCollectionError = "CrossCloudCollectionError"; + public const string GeneralThresholdError = "GeneralThresholdError"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertOperator.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertOperator.cs new file mode 100644 index 0000000000000..fd7a1372f452b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertOperator.cs @@ -0,0 +1,26 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for AlertOperator. + /// + public static class AlertOperator + { + public const string None = "None"; + public const string EqualTo = "EqualTo"; + public const string GreaterThan = "GreaterThan"; + public const string GreaterThanOrEqualTo = "GreaterThanOrEqualTo"; + public const string LessThan = "LessThan"; + public const string LessThanOrEqualTo = "LessThanOrEqualTo"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertPropertiesDefinition.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertPropertiesDefinition.cs new file mode 100644 index 0000000000000..904e562d055c2 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertPropertiesDefinition.cs @@ -0,0 +1,86 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// defines the type of alert + /// + public partial class AlertPropertiesDefinition + { + /// + /// Initializes a new instance of the AlertPropertiesDefinition class. + /// + public AlertPropertiesDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertPropertiesDefinition class. + /// + /// type of alert. Possible values include: + /// 'Budget', 'Invoice', 'Credit', 'Quota', 'General', 'xCloud', + /// 'BudgetForecast' + /// Alert category. Possible values include: + /// 'Cost', 'Usage', 'Billing', 'System' + /// Criteria that triggered alert. Possible + /// values include: 'CostThresholdExceeded', 'UsageThresholdExceeded', + /// 'CreditThresholdApproaching', 'CreditThresholdReached', + /// 'QuotaThresholdApproaching', 'QuotaThresholdReached', + /// 'MultiCurrency', 'ForecastCostThresholdExceeded', + /// 'ForecastUsageThresholdExceeded', 'InvoiceDueDateApproaching', + /// 'InvoiceDueDateReached', 'CrossCloudNewDataAvailable', + /// 'CrossCloudCollectionError', 'GeneralThresholdError' + public AlertPropertiesDefinition(string type = default(string), string category = default(string), string criteria = default(string)) + { + Type = type; + Category = category; + Criteria = criteria; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets type of alert. Possible values include: 'Budget', + /// 'Invoice', 'Credit', 'Quota', 'General', 'xCloud', 'BudgetForecast' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets alert category. Possible values include: 'Cost', + /// 'Usage', 'Billing', 'System' + /// + [JsonProperty(PropertyName = "category")] + public string Category { get; set; } + + /// + /// Gets or sets criteria that triggered alert. Possible values + /// include: 'CostThresholdExceeded', 'UsageThresholdExceeded', + /// 'CreditThresholdApproaching', 'CreditThresholdReached', + /// 'QuotaThresholdApproaching', 'QuotaThresholdReached', + /// 'MultiCurrency', 'ForecastCostThresholdExceeded', + /// 'ForecastUsageThresholdExceeded', 'InvoiceDueDateApproaching', + /// 'InvoiceDueDateReached', 'CrossCloudNewDataAvailable', + /// 'CrossCloudCollectionError', 'GeneralThresholdError' + /// + [JsonProperty(PropertyName = "criteria")] + public string Criteria { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertPropertiesDetails.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertPropertiesDetails.cs new file mode 100644 index 0000000000000..142a4b147f125 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertPropertiesDetails.cs @@ -0,0 +1,238 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Alert details + /// + public partial class AlertPropertiesDetails + { + /// + /// Initializes a new instance of the AlertPropertiesDetails class. + /// + public AlertPropertiesDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertPropertiesDetails class. + /// + /// Type of timegrain cadence. Possible + /// values include: 'None', 'Monthly', 'Quarterly', 'Annually', + /// 'BillingMonth', 'BillingQuarter', 'BillingAnnual' + /// datetime of periodStartDate + /// notificationId that triggered this + /// alert + /// array of resourceGroups to filter + /// by + /// array of resources to filter + /// by + /// array of meters to filter by + /// tags to filter by + /// notification threshold percentage as a + /// decimal which activated this alert + /// operator used to compare + /// currentSpend with amount. Possible values include: 'None', + /// 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo', 'LessThan', + /// 'LessThanOrEqualTo' + /// budget threshold amount + /// unit of currency being used + /// current spend + /// list of emails to contact + /// list of action groups to broadcast + /// to + /// list of contact roles + /// overriding alert + /// department name + /// company name + /// enrollment number + /// datetime of + /// enrollmentStartDate + /// datetime of + /// enrollmentEndDate + /// invoicing threshold + public AlertPropertiesDetails(string timeGrainType = default(string), string periodStartDate = default(string), string triggeredBy = default(string), IList resourceGroupFilter = default(IList), IList resourceFilter = default(IList), IList meterFilter = default(IList), object tagFilter = default(object), decimal? threshold = default(decimal?), string operatorProperty = default(string), decimal? amount = default(decimal?), string unit = default(string), decimal? currentSpend = default(decimal?), IList contactEmails = default(IList), IList contactGroups = default(IList), IList contactRoles = default(IList), string overridingAlert = default(string), string departmentName = default(string), string companyName = default(string), string enrollmentNumber = default(string), string enrollmentStartDate = default(string), string enrollmentEndDate = default(string), decimal? invoicingThreshold = default(decimal?)) + { + TimeGrainType = timeGrainType; + PeriodStartDate = periodStartDate; + TriggeredBy = triggeredBy; + ResourceGroupFilter = resourceGroupFilter; + ResourceFilter = resourceFilter; + MeterFilter = meterFilter; + TagFilter = tagFilter; + Threshold = threshold; + OperatorProperty = operatorProperty; + Amount = amount; + Unit = unit; + CurrentSpend = currentSpend; + ContactEmails = contactEmails; + ContactGroups = contactGroups; + ContactRoles = contactRoles; + OverridingAlert = overridingAlert; + DepartmentName = departmentName; + CompanyName = companyName; + EnrollmentNumber = enrollmentNumber; + EnrollmentStartDate = enrollmentStartDate; + EnrollmentEndDate = enrollmentEndDate; + InvoicingThreshold = invoicingThreshold; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets type of timegrain cadence. Possible values include: + /// 'None', 'Monthly', 'Quarterly', 'Annually', 'BillingMonth', + /// 'BillingQuarter', 'BillingAnnual' + /// + [JsonProperty(PropertyName = "timeGrainType")] + public string TimeGrainType { get; set; } + + /// + /// Gets or sets datetime of periodStartDate + /// + [JsonProperty(PropertyName = "periodStartDate")] + public string PeriodStartDate { get; set; } + + /// + /// Gets or sets notificationId that triggered this alert + /// + [JsonProperty(PropertyName = "triggeredBy")] + public string TriggeredBy { get; set; } + + /// + /// Gets or sets array of resourceGroups to filter by + /// + [JsonProperty(PropertyName = "resourceGroupFilter")] + public IList ResourceGroupFilter { get; set; } + + /// + /// Gets or sets array of resources to filter by + /// + [JsonProperty(PropertyName = "resourceFilter")] + public IList ResourceFilter { get; set; } + + /// + /// Gets or sets array of meters to filter by + /// + [JsonProperty(PropertyName = "meterFilter")] + public IList MeterFilter { get; set; } + + /// + /// Gets or sets tags to filter by + /// + [JsonProperty(PropertyName = "tagFilter")] + public object TagFilter { get; set; } + + /// + /// Gets or sets notification threshold percentage as a decimal which + /// activated this alert + /// + [JsonProperty(PropertyName = "threshold")] + public decimal? Threshold { get; set; } + + /// + /// Gets or sets operator used to compare currentSpend with amount. + /// Possible values include: 'None', 'EqualTo', 'GreaterThan', + /// 'GreaterThanOrEqualTo', 'LessThan', 'LessThanOrEqualTo' + /// + [JsonProperty(PropertyName = "operator")] + public string OperatorProperty { get; set; } + + /// + /// Gets or sets budget threshold amount + /// + [JsonProperty(PropertyName = "amount")] + public decimal? Amount { get; set; } + + /// + /// Gets or sets unit of currency being used + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// Gets or sets current spend + /// + [JsonProperty(PropertyName = "currentSpend")] + public decimal? CurrentSpend { get; set; } + + /// + /// Gets or sets list of emails to contact + /// + [JsonProperty(PropertyName = "contactEmails")] + public IList ContactEmails { get; set; } + + /// + /// Gets or sets list of action groups to broadcast to + /// + [JsonProperty(PropertyName = "contactGroups")] + public IList ContactGroups { get; set; } + + /// + /// Gets or sets list of contact roles + /// + [JsonProperty(PropertyName = "contactRoles")] + public IList ContactRoles { get; set; } + + /// + /// Gets or sets overriding alert + /// + [JsonProperty(PropertyName = "overridingAlert")] + public string OverridingAlert { get; set; } + + /// + /// Gets or sets department name + /// + [JsonProperty(PropertyName = "departmentName")] + public string DepartmentName { get; set; } + + /// + /// Gets or sets company name + /// + [JsonProperty(PropertyName = "companyName")] + public string CompanyName { get; set; } + + /// + /// Gets or sets enrollment number + /// + [JsonProperty(PropertyName = "enrollmentNumber")] + public string EnrollmentNumber { get; set; } + + /// + /// Gets or sets datetime of enrollmentStartDate + /// + [JsonProperty(PropertyName = "enrollmentStartDate")] + public string EnrollmentStartDate { get; set; } + + /// + /// Gets or sets datetime of enrollmentEndDate + /// + [JsonProperty(PropertyName = "enrollmentEndDate")] + public string EnrollmentEndDate { get; set; } + + /// + /// Gets or sets invoicing threshold + /// + [JsonProperty(PropertyName = "invoicingThreshold")] + public decimal? InvoicingThreshold { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertSource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertSource.cs new file mode 100644 index 0000000000000..1116dbb21b09b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertSource.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.CostManagement.Models +{ + + /// + /// Defines values for AlertSource. + /// + public static class AlertSource + { + public const string Preset = "Preset"; + public const string User = "User"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertStatus.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertStatus.cs new file mode 100644 index 0000000000000..2c495f7af4756 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertStatus.cs @@ -0,0 +1,25 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for AlertStatus. + /// + public static class AlertStatus + { + public const string None = "None"; + public const string Active = "Active"; + public const string Overridden = "Overridden"; + public const string Resolved = "Resolved"; + public const string Dismissed = "Dismissed"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertTimeGrainType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertTimeGrainType.cs new file mode 100644 index 0000000000000..88593acce77f7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertTimeGrainType.cs @@ -0,0 +1,27 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for AlertTimeGrainType. + /// + public static class AlertTimeGrainType + { + public const string None = "None"; + public const string Monthly = "Monthly"; + public const string Quarterly = "Quarterly"; + public const string Annually = "Annually"; + public const string BillingMonth = "BillingMonth"; + public const string BillingQuarter = "BillingQuarter"; + public const string BillingAnnual = "BillingAnnual"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertType.cs new file mode 100644 index 0000000000000..bbf1cb020be3a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertType.cs @@ -0,0 +1,27 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for AlertType. + /// + public static class AlertType + { + public const string Budget = "Budget"; + public const string Invoice = "Invoice"; + public const string Credit = "Credit"; + public const string Quota = "Quota"; + public const string General = "General"; + public const string XCloud = "xCloud"; + public const string BudgetForecast = "BudgetForecast"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertsResult.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertsResult.cs new file mode 100644 index 0000000000000..1f74bfe6615ad --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertsResult.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of alerts. + /// + public partial class AlertsResult + { + /// + /// Initializes a new instance of the AlertsResult class. + /// + public AlertsResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertsResult class. + /// + /// List of alerts. + /// URL to get the next set of alerts results if + /// there are any. + public AlertsResult(IList value = default(IList), string nextLink = default(string)) + { + Value = value; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of alerts. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + /// + /// Gets URL to get the next set of alerts results if there are any. + /// + [JsonProperty(PropertyName = "nextLink")] + public string NextLink { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AllSavingsBenefitDetails.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AllSavingsBenefitDetails.cs new file mode 100644 index 0000000000000..96397dac73a72 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AllSavingsBenefitDetails.cs @@ -0,0 +1,126 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of the benefit plan recommendation details for a saving. + /// + public partial class AllSavingsBenefitDetails + { + /// + /// Initializes a new instance of the AllSavingsBenefitDetails class. + /// + public AllSavingsBenefitDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AllSavingsBenefitDetails class. + /// + /// The difference between total cost and + /// benefit cost. + /// The exact cost of the estimated usage + /// using plan. It's equal to (commitmentAmount * totalHours) + /// The cost of the suggested + /// commitment. + /// The amount saved by purchasing the + /// recommended quantity of benefit. + /// The savings in percentage by + /// purchasing the recommended quantity of benefit. + /// Expected coverage at this + /// commitment. + /// The commitment amount for the + /// benefit. + /// Estimated average + /// utilization percentage at this commitment. + /// Wastage cost at this commitment. + public AllSavingsBenefitDetails(decimal? overageCost = default(decimal?), decimal? benefitCost = default(decimal?), decimal? totalCost = default(decimal?), decimal? savingsAmount = default(decimal?), decimal? savingsPercentage = default(decimal?), decimal? coveragePercentage = default(decimal?), decimal? commitmentAmount = default(decimal?), decimal? averageUtilizationPercentage = default(decimal?), decimal? wastageCost = default(decimal?)) + { + OverageCost = overageCost; + BenefitCost = benefitCost; + TotalCost = totalCost; + SavingsAmount = savingsAmount; + SavingsPercentage = savingsPercentage; + CoveragePercentage = coveragePercentage; + CommitmentAmount = commitmentAmount; + AverageUtilizationPercentage = averageUtilizationPercentage; + WastageCost = wastageCost; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the difference between total cost and benefit cost. + /// + [JsonProperty(PropertyName = "overageCost")] + public decimal? OverageCost { get; private set; } + + /// + /// Gets the exact cost of the estimated usage using plan. It's equal + /// to (commitmentAmount * totalHours) + /// + [JsonProperty(PropertyName = "benefitCost")] + public decimal? BenefitCost { get; private set; } + + /// + /// Gets the cost of the suggested commitment. + /// + [JsonProperty(PropertyName = "totalCost")] + public decimal? TotalCost { get; private set; } + + /// + /// Gets the amount saved by purchasing the recommended quantity of + /// benefit. + /// + [JsonProperty(PropertyName = "savingsAmount")] + public decimal? SavingsAmount { get; private set; } + + /// + /// Gets the savings in percentage by purchasing the recommended + /// quantity of benefit. + /// + [JsonProperty(PropertyName = "savingsPercentage")] + public decimal? SavingsPercentage { get; private set; } + + /// + /// Gets expected coverage at this commitment. + /// + [JsonProperty(PropertyName = "coveragePercentage")] + public decimal? CoveragePercentage { get; private set; } + + /// + /// Gets the commitment amount for the benefit. + /// + [JsonProperty(PropertyName = "commitmentAmount")] + public decimal? CommitmentAmount { get; private set; } + + /// + /// Gets estimated average utilization percentage at this commitment. + /// + [JsonProperty(PropertyName = "averageUtilizationPercentage")] + public decimal? AverageUtilizationPercentage { get; private set; } + + /// + /// Gets wastage cost at this commitment. + /// + [JsonProperty(PropertyName = "wastageCost")] + public decimal? WastageCost { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AllSavingsList.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AllSavingsList.cs new file mode 100644 index 0000000000000..919b8020caf13 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AllSavingsList.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of listing benefit recommendations. + /// + public partial class AllSavingsList + { + /// + /// Initializes a new instance of the AllSavingsList class. + /// + public AllSavingsList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AllSavingsList class. + /// + /// The list of benefit recommendations. + /// The link (URL) to the next page of + /// results. + public AllSavingsList(IList value = default(IList), string nextLink = default(string)) + { + Value = value; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of benefit recommendations. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + /// + /// Gets the link (URL) to the next page of results. + /// + [JsonProperty(PropertyName = "nextLink")] + public string NextLink { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AzureEntityResource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AzureEntityResource.cs new file mode 100644 index 0000000000000..c6212fa03a02a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AzureEntityResource.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Entity Resource + /// + /// + /// The resource model definition for an Azure Resource Manager resource + /// with an etag. + /// + public partial class AzureEntityResource : Resource + { + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + public AzureEntityResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Resource Etag. + public AzureEntityResource(string id = default(string), string name = default(string), string type = default(string), string etag = default(string)) + : base(id, name, type) + { + Etag = etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Etag. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitKind.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitKind.cs new file mode 100644 index 0000000000000..b227305890bc8 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitKind.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.CostManagement.Models +{ + + /// + /// Defines values for BenefitKind. + /// + public static class BenefitKind + { + /// + /// Benefit is IncludedQuantity. + /// + public const string IncludedQuantity = "IncludedQuantity"; + /// + /// Benefit is Reservation. + /// + public const string Reservation = "Reservation"; + /// + /// Benefit is SavingsPlan. + /// + public const string SavingsPlan = "SavingsPlan"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitRecommendationModel.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitRecommendationModel.cs new file mode 100644 index 0000000000000..671d4aebd3246 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitRecommendationModel.cs @@ -0,0 +1,52 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// benefit plan recommendation details. + /// + public partial class BenefitRecommendationModel : BenefitResource + { + /// + /// Initializes a new instance of the BenefitRecommendationModel class. + /// + public BenefitRecommendationModel() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BenefitRecommendationModel class. + /// + /// Reservation or SavingsPlan. Possible values + /// include: 'IncludedQuantity', 'Reservation', 'SavingsPlan' + public BenefitRecommendationModel(string kind = default(string), BenefitRecommendationProperties properties = default(BenefitRecommendationProperties)) + : base(kind) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties")] + public BenefitRecommendationProperties Properties { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitRecommendationProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitRecommendationProperties.cs new file mode 100644 index 0000000000000..df9906ac239d8 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitRecommendationProperties.cs @@ -0,0 +1,170 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of the benefit plan recommendation. + /// + [Newtonsoft.Json.JsonObject("benefitRecommendationProperties")] + public partial class BenefitRecommendationProperties + { + /// + /// Initializes a new instance of the BenefitRecommendationProperties + /// class. + /// + public BenefitRecommendationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BenefitRecommendationProperties + /// class. + /// + /// The first usage date used for + /// looking back for computing the recommendation. + /// The last usage date used for + /// looking back for computing the recommendation. + /// The number of days of usage used to + /// look back for computing the recommendation. Possible values + /// include: 'Last7Days', 'Last30Days', 'Last60Days' + /// The total hours for which the cost is + /// covered. Its equal to number of records in a property + /// 'properties/usage/charges'. + /// The additional details about the usage which + /// are considered while computing benefit recommendations. + /// ARM SKU name. For example, Standard_D1_V2 + /// for Reservations and Compute_Savings_Plan for SavingsPlan. + /// Term period of the benefit. For example, P1Y or + /// P3Y. Possible values include: 'P1Y', 'P3Y' + /// Grain of the proposed + /// commitment amount. For example, hourly, monthly etc. Possible + /// values include: 'Hourly', 'Daily', 'Monthly' + /// An ISO 4217 currency code identifier for + /// the costs and savings amounts. + /// The current cost without benefit + /// corresponds to 'totalHours' property in a given look-back + /// period. + /// The details of the proposed + /// recommendation. + /// The list of all benefit + /// recommendations. + public BenefitRecommendationProperties(System.DateTime? firstConsumptionDate = default(System.DateTime?), System.DateTime? lastConsumptionDate = default(System.DateTime?), string lookBackPeriod = default(string), int? totalHours = default(int?), RecommendationUsageDetails usage = default(RecommendationUsageDetails), string armSkuName = default(string), string term = default(string), string commitmentGranularity = default(string), string currencyCode = default(string), decimal? costWithoutBenefit = default(decimal?), AllSavingsBenefitDetails recommendationDetails = default(AllSavingsBenefitDetails), AllSavingsList allRecommendationDetails = default(AllSavingsList)) + { + FirstConsumptionDate = firstConsumptionDate; + LastConsumptionDate = lastConsumptionDate; + LookBackPeriod = lookBackPeriod; + TotalHours = totalHours; + Usage = usage; + ArmSkuName = armSkuName; + Term = term; + CommitmentGranularity = commitmentGranularity; + CurrencyCode = currencyCode; + CostWithoutBenefit = costWithoutBenefit; + RecommendationDetails = recommendationDetails; + AllRecommendationDetails = allRecommendationDetails; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the first usage date used for looking back for computing the + /// recommendation. + /// + [JsonProperty(PropertyName = "firstConsumptionDate")] + public System.DateTime? FirstConsumptionDate { get; private set; } + + /// + /// Gets the last usage date used for looking back for computing the + /// recommendation. + /// + [JsonProperty(PropertyName = "lastConsumptionDate")] + public System.DateTime? LastConsumptionDate { get; private set; } + + /// + /// Gets or sets the number of days of usage used to look back for + /// computing the recommendation. Possible values include: 'Last7Days', + /// 'Last30Days', 'Last60Days' + /// + [JsonProperty(PropertyName = "lookBackPeriod")] + public string LookBackPeriod { get; set; } + + /// + /// Gets the total hours for which the cost is covered. Its equal to + /// number of records in a property 'properties/usage/charges'. + /// + [JsonProperty(PropertyName = "totalHours")] + public int? TotalHours { get; private set; } + + /// + /// Gets or sets the additional details about the usage which are + /// considered while computing benefit recommendations. + /// + [JsonProperty(PropertyName = "usage")] + public RecommendationUsageDetails Usage { get; set; } + + /// + /// Gets ARM SKU name. For example, Standard_D1_V2 for Reservations and + /// Compute_Savings_Plan for SavingsPlan. + /// + [JsonProperty(PropertyName = "armSkuName")] + public string ArmSkuName { get; private set; } + + /// + /// Gets or sets term period of the benefit. For example, P1Y or P3Y. + /// Possible values include: 'P1Y', 'P3Y' + /// + [JsonProperty(PropertyName = "term")] + public string Term { get; set; } + + /// + /// Gets or sets grain of the proposed commitment amount. For example, + /// hourly, monthly etc. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// + [JsonProperty(PropertyName = "commitmentGranularity")] + public string CommitmentGranularity { get; set; } + + /// + /// Gets an ISO 4217 currency code identifier for the costs and savings + /// amounts. + /// + [JsonProperty(PropertyName = "currencyCode")] + public string CurrencyCode { get; private set; } + + /// + /// Gets the current cost without benefit corresponds to 'totalHours' + /// property in a given look-back period. + /// + [JsonProperty(PropertyName = "costWithoutBenefit")] + public decimal? CostWithoutBenefit { get; private set; } + + /// + /// Gets or sets the details of the proposed recommendation. + /// + [JsonProperty(PropertyName = "recommendationDetails")] + public AllSavingsBenefitDetails RecommendationDetails { get; set; } + + /// + /// Gets the list of all benefit recommendations. + /// + [JsonProperty(PropertyName = "allRecommendationDetails")] + public AllSavingsList AllRecommendationDetails { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitResource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitResource.cs new file mode 100644 index 0000000000000..91fdbaf1abf21 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitResource.cs @@ -0,0 +1,55 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The benefit resource model definition. + /// + public partial class BenefitResource : IResource + { + /// + /// Initializes a new instance of the BenefitResource class. + /// + public BenefitResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BenefitResource class. + /// + /// Reservation or SavingsPlan. Possible values + /// include: 'IncludedQuantity', 'Reservation', 'SavingsPlan' + public BenefitResource(string kind = default(string)) + { + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets reservation or SavingsPlan. Possible values include: + /// 'IncludedQuantity', 'Reservation', 'SavingsPlan' + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitUtilizationSummary.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitUtilizationSummary.cs new file mode 100644 index 0000000000000..ad7fc6fedba3e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitUtilizationSummary.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using System.Linq; + + /// + /// Benefit utilization summary resource. + /// + public partial class BenefitUtilizationSummary : Resource + { + /// + /// Initializes a new instance of the BenefitUtilizationSummary class. + /// + public BenefitUtilizationSummary() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BenefitUtilizationSummary class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public BenefitUtilizationSummary(string id = default(string), string name = default(string), string type = default(string)) + : base(id, name, type) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitUtilizationSummaryProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitUtilizationSummaryProperties.cs new file mode 100644 index 0000000000000..9cbf2a3b0ab7d --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BenefitUtilizationSummaryProperties.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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of a benefit utilization summary. + /// + public partial class BenefitUtilizationSummaryProperties + { + /// + /// Initializes a new instance of the + /// BenefitUtilizationSummaryProperties class. + /// + public BenefitUtilizationSummaryProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// BenefitUtilizationSummaryProperties class. + /// + /// ARM SKU name. For example, Standard_D1_V2 + /// for reservations and ComputeSavingsPlan for savings plan. + /// The benefit ID is the identifier of a + /// benefit within a benefit order. + /// The benefit order ID is the identifier + /// for a benefit purchase. Each benefit order ID represents a single + /// purchase transaction. For example: A reservation order contains + /// reservations. The reservation order specifies the VM size and + /// region for the reservations. + /// The benefit type. For example, + /// reservation or savings plan. Possible values include: + /// 'IncludedQuantity', 'Reservation', 'SavingsPlan' + /// Date corresponding to the utilization + /// record. If the grain of data is monthly, it will be first day of + /// month. + public BenefitUtilizationSummaryProperties(string armSkuName = default(string), string benefitId = default(string), string benefitOrderId = default(string), string benefitType = default(string), System.DateTime? usageDate = default(System.DateTime?)) + { + ArmSkuName = armSkuName; + BenefitId = benefitId; + BenefitOrderId = benefitOrderId; + BenefitType = benefitType; + UsageDate = usageDate; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets ARM SKU name. For example, Standard_D1_V2 for reservations and + /// ComputeSavingsPlan for savings plan. + /// + [JsonProperty(PropertyName = "armSkuName")] + public string ArmSkuName { get; private set; } + + /// + /// Gets the benefit ID is the identifier of a benefit within a benefit + /// order. + /// + [JsonProperty(PropertyName = "benefitId")] + public string BenefitId { get; private set; } + + /// + /// Gets the benefit order ID is the identifier for a benefit purchase. + /// Each benefit order ID represents a single purchase transaction. For + /// example: A reservation order contains reservations. The reservation + /// order specifies the VM size and region for the reservations. + /// + [JsonProperty(PropertyName = "benefitOrderId")] + public string BenefitOrderId { get; private set; } + + /// + /// Gets or sets the benefit type. For example, reservation or savings + /// plan. Possible values include: 'IncludedQuantity', 'Reservation', + /// 'SavingsPlan' + /// + [JsonProperty(PropertyName = "benefitType")] + public string BenefitType { get; set; } + + /// + /// Gets date corresponding to the utilization record. If the grain of + /// data is monthly, it will be first day of month. + /// + [JsonProperty(PropertyName = "usageDate")] + public System.DateTime? UsageDate { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BlobInfo.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BlobInfo.cs new file mode 100644 index 0000000000000..5deb94b890d89 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/BlobInfo.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The blob information generated by this operation. + /// + public partial class BlobInfo + { + /// + /// Initializes a new instance of the BlobInfo class. + /// + public BlobInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobInfo class. + /// + /// Link to the blob to download file. + /// Bytes in the blob. + public BlobInfo(string blobLink = default(string), long? byteCount = default(long?)) + { + BlobLink = blobLink; + ByteCount = byteCount; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets link to the blob to download file. + /// + [JsonProperty(PropertyName = "blobLink")] + public string BlobLink { get; set; } + + /// + /// Gets or sets bytes in the blob. + /// + [JsonProperty(PropertyName = "byteCount")] + public long? ByteCount { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ChartType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ChartType.cs new file mode 100644 index 0000000000000..0e72be35a68fc --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ChartType.cs @@ -0,0 +1,25 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for ChartType. + /// + public static class ChartType + { + public const string Area = "Area"; + public const string Line = "Line"; + public const string StackedColumn = "StackedColumn"; + public const string GroupedColumn = "GroupedColumn"; + public const string Table = "Table"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CheckNameAvailabilityReason.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CheckNameAvailabilityReason.cs new file mode 100644 index 0000000000000..94d21b98b8000 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CheckNameAvailabilityReason.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.CostManagement.Models +{ + + /// + /// Defines values for CheckNameAvailabilityReason. + /// + public static class CheckNameAvailabilityReason + { + public const string Invalid = "Invalid"; + public const string AlreadyExists = "AlreadyExists"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CheckNameAvailabilityRequest.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CheckNameAvailabilityRequest.cs new file mode 100644 index 0000000000000..1b0ed8ade2dd2 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CheckNameAvailabilityRequest.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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The check availability request body. + /// + public partial class CheckNameAvailabilityRequest + { + /// + /// Initializes a new instance of the CheckNameAvailabilityRequest + /// class. + /// + public CheckNameAvailabilityRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckNameAvailabilityRequest + /// class. + /// + /// The name of the resource for which availability + /// needs to be checked. + /// The resource type. + public CheckNameAvailabilityRequest(string name = default(string), string type = default(string)) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the resource for which availability needs + /// to be checked. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CheckNameAvailabilityResponse.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CheckNameAvailabilityResponse.cs new file mode 100644 index 0000000000000..067416d85bf0a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CheckNameAvailabilityResponse.cs @@ -0,0 +1,74 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The check availability result. + /// + public partial class CheckNameAvailabilityResponse + { + /// + /// Initializes a new instance of the CheckNameAvailabilityResponse + /// class. + /// + public CheckNameAvailabilityResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckNameAvailabilityResponse + /// class. + /// + /// Indicates if the resource name is + /// available. + /// The reason why the given name is not + /// available. Possible values include: 'Invalid', + /// 'AlreadyExists' + /// Detailed reason why the given name is + /// available. + public CheckNameAvailabilityResponse(bool? nameAvailable = default(bool?), string reason = default(string), string message = default(string)) + { + NameAvailable = nameAvailable; + Reason = reason; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates if the resource name is available. + /// + [JsonProperty(PropertyName = "nameAvailable")] + public bool? NameAvailable { get; set; } + + /// + /// Gets or sets the reason why the given name is not available. + /// Possible values include: 'Invalid', 'AlreadyExists' + /// + [JsonProperty(PropertyName = "reason")] + public string Reason { get; set; } + + /// + /// Gets or sets detailed reason why the given name is available. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CommonExportProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CommonExportProperties.cs new file mode 100644 index 0000000000000..f7735ec8b3046 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CommonExportProperties.cs @@ -0,0 +1,131 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The common properties of the export. + /// + public partial class CommonExportProperties + { + /// + /// Initializes a new instance of the CommonExportProperties class. + /// + public CommonExportProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CommonExportProperties class. + /// + /// Has delivery information for the + /// export. + /// Has the definition for the export. + /// The format of the export being delivered. + /// Currently only 'Csv' is supported. Possible values include: + /// 'Csv' + /// If requested, has the most recent run + /// history for the export. + /// If set to true, exported data will be + /// partitioned by size and placed in a blob directory together with a + /// manifest file. Note: this option is currently available only for + /// Microsoft Customer Agreement commerce scopes. + /// If the export has an active + /// schedule, provides an estimate of the next run time. + public CommonExportProperties(ExportDeliveryInfo deliveryInfo, ExportDefinition definition, string format = default(string), ExportExecutionListResult runHistory = default(ExportExecutionListResult), bool? partitionData = default(bool?), System.DateTime? nextRunTimeEstimate = default(System.DateTime?)) + { + Format = format; + DeliveryInfo = deliveryInfo; + Definition = definition; + RunHistory = runHistory; + PartitionData = partitionData; + NextRunTimeEstimate = nextRunTimeEstimate; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the format of the export being delivered. Currently + /// only 'Csv' is supported. Possible values include: 'Csv' + /// + [JsonProperty(PropertyName = "format")] + public string Format { get; set; } + + /// + /// Gets or sets has delivery information for the export. + /// + [JsonProperty(PropertyName = "deliveryInfo")] + public ExportDeliveryInfo DeliveryInfo { get; set; } + + /// + /// Gets or sets has the definition for the export. + /// + [JsonProperty(PropertyName = "definition")] + public ExportDefinition Definition { get; set; } + + /// + /// Gets or sets if requested, has the most recent run history for the + /// export. + /// + [JsonProperty(PropertyName = "runHistory")] + public ExportExecutionListResult RunHistory { get; set; } + + /// + /// Gets or sets if set to true, exported data will be partitioned by + /// size and placed in a blob directory together with a manifest file. + /// Note: this option is currently available only for Microsoft + /// Customer Agreement commerce scopes. + /// + [JsonProperty(PropertyName = "partitionData")] + public bool? PartitionData { get; set; } + + /// + /// Gets if the export has an active schedule, provides an estimate of + /// the next run time. + /// + [JsonProperty(PropertyName = "nextRunTimeEstimate")] + public System.DateTime? NextRunTimeEstimate { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (DeliveryInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DeliveryInfo"); + } + if (Definition == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Definition"); + } + if (DeliveryInfo != null) + { + DeliveryInfo.Validate(); + } + if (Definition != null) + { + Definition.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsDataFormat.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsDataFormat.cs new file mode 100644 index 0000000000000..08c1b294ce2be --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsDataFormat.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + + /// + /// Defines values for CostDetailsDataFormat. + /// + public static class CostDetailsDataFormat + { + /// + /// Csv data format. + /// + public const string CsvCostDetailsDataFormat = "Csv"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsMetricType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsMetricType.cs new file mode 100644 index 0000000000000..6ebc91f7bb638 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsMetricType.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.CostManagement.Models +{ + + /// + /// Defines values for CostDetailsMetricType. + /// + public static class CostDetailsMetricType + { + /// + /// Actual cost data. + /// + public const string ActualCostCostDetailsMetricType = "ActualCost"; + /// + /// Amortized cost data. + /// + public const string AmortizedCostCostDetailsMetricType = "AmortizedCost"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsOperationResults.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsOperationResults.cs new file mode 100644 index 0000000000000..df4f64fefa953 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsOperationResults.cs @@ -0,0 +1,189 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The result of the long running operation for cost details Api. + /// + [Rest.Serialization.JsonTransformation] + public partial class CostDetailsOperationResults + { + /// + /// Initializes a new instance of the CostDetailsOperationResults + /// class. + /// + public CostDetailsOperationResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CostDetailsOperationResults + /// class. + /// + /// The id of the long running operation. + /// The name of the long running operation. + /// The type of the long running operation. + /// The status of the cost details operation. + /// Possible values include: 'CompletedCostDetailsStatusType', + /// 'NoDataFoundCostDetailsStatusType', + /// 'FailedCostDetailsStatusType' + /// The Manifest version. + /// The data format of the report. Possible + /// values include: 'CsvCostDetailsDataFormat' + /// The total number of bytes in all + /// blobs. + /// The total number of blobs. + /// Is the data in compressed + /// format. + /// The request scope of the + /// request. + /// The request payload body provided in Cost + /// Details call + /// List of blob information generated by this + /// operation. + /// The time at which report URL becomes + /// invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// The details of the error. + public CostDetailsOperationResults(string id = default(string), string name = default(string), string type = default(string), string status = default(string), string manifestVersion = default(string), string dataFormat = default(string), long? byteCount = default(long?), int? blobCount = default(int?), bool? compressData = default(bool?), string requestScope = default(string), GenerateCostDetailsReportRequestDefinition requestBody = default(GenerateCostDetailsReportRequestDefinition), IList blobs = default(IList), System.DateTime? validTill = default(System.DateTime?), ErrorDetails error = default(ErrorDetails)) + { + Id = id; + Name = name; + Type = type; + Status = status; + ManifestVersion = manifestVersion; + DataFormat = dataFormat; + ByteCount = byteCount; + BlobCount = blobCount; + CompressData = compressData; + RequestScope = requestScope; + RequestBody = requestBody; + Blobs = blobs; + ValidTill = validTill; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the id of the long running operation. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the name of the long running operation. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the type of the long running operation. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the status of the cost details operation. Possible + /// values include: 'CompletedCostDetailsStatusType', + /// 'NoDataFoundCostDetailsStatusType', 'FailedCostDetailsStatusType' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the Manifest version. + /// + [JsonProperty(PropertyName = "manifest.manifestVersion")] + public string ManifestVersion { get; set; } + + /// + /// Gets or sets the data format of the report. Possible values + /// include: 'CsvCostDetailsDataFormat' + /// + [JsonProperty(PropertyName = "manifest.dataFormat")] + public string DataFormat { get; set; } + + /// + /// Gets or sets the total number of bytes in all blobs. + /// + [JsonProperty(PropertyName = "manifest.byteCount")] + public long? ByteCount { get; set; } + + /// + /// Gets or sets the total number of blobs. + /// + [JsonProperty(PropertyName = "manifest.blobCount")] + public int? BlobCount { get; set; } + + /// + /// Gets or sets is the data in compressed format. + /// + [JsonProperty(PropertyName = "manifest.compressData")] + public bool? CompressData { get; set; } + + /// + /// Gets or sets the request scope of the request. + /// + [JsonProperty(PropertyName = "manifest.requestContext.requestScope")] + public string RequestScope { get; set; } + + /// + /// Gets or sets the request payload body provided in Cost Details call + /// + [JsonProperty(PropertyName = "manifest.requestContext.requestBody")] + public GenerateCostDetailsReportRequestDefinition RequestBody { get; set; } + + /// + /// Gets or sets list of blob information generated by this operation. + /// + [JsonProperty(PropertyName = "manifest.blobs")] + public IList Blobs { get; set; } + + /// + /// Gets or sets the time at which report URL becomes invalid/expires + /// in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// + [JsonProperty(PropertyName = "validTill")] + public System.DateTime? ValidTill { get; set; } + + /// + /// Gets or sets the details of the error. + /// + [JsonProperty(PropertyName = "error")] + public ErrorDetails Error { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RequestBody != null) + { + RequestBody.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsStatusType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsStatusType.cs new file mode 100644 index 0000000000000..2dc6b12eff62a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsStatusType.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.CostManagement.Models +{ + + /// + /// Defines values for CostDetailsStatusType. + /// + public static class CostDetailsStatusType + { + /// + /// Operation is Completed. + /// + public const string CompletedCostDetailsStatusType = "Completed"; + /// + /// Operation is Completed and no cost data found. + /// + public const string NoDataFoundCostDetailsStatusType = "NoDataFound"; + /// + /// Operation Failed. + /// + public const string FailedCostDetailsStatusType = "Failed"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsTimePeriod.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsTimePeriod.cs new file mode 100644 index 0000000000000..aec2af480e9f6 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostDetailsTimePeriod.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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The start and end date for pulling data for the cost detailed report. + /// API only allows data to be pulled for 1 month or less and no older than + /// 13 months. + /// + public partial class CostDetailsTimePeriod + { + /// + /// Initializes a new instance of the CostDetailsTimePeriod class. + /// + public CostDetailsTimePeriod() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CostDetailsTimePeriod class. + /// + /// The start date to pull data from. example + /// format 2020-03-15 + /// The end date to pull data to. example format + /// 2020-03-15 + public CostDetailsTimePeriod(string start, string end) + { + Start = start; + End = end; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start date to pull data from. example format + /// 2020-03-15 + /// + [JsonProperty(PropertyName = "start")] + public string Start { get; set; } + + /// + /// Gets or sets the end date to pull data to. example format + /// 2020-03-15 + /// + [JsonProperty(PropertyName = "end")] + public string End { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Start == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Start"); + } + if (End == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "End"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostManagementOperation.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostManagementOperation.cs new file mode 100644 index 0000000000000..51e0fd2242b10 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostManagementOperation.cs @@ -0,0 +1,69 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A Cost management REST API operation. + /// + public partial class CostManagementOperation : Operation + { + /// + /// Initializes a new instance of the CostManagementOperation class. + /// + public CostManagementOperation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CostManagementOperation class. + /// + /// The name of the operation, as per Resource-Based + /// Access Control (RBAC). Examples: + /// "Microsoft.Compute/virtualMachines/write", + /// "Microsoft.Compute/virtualMachines/capture/action" + /// Whether the operation applies to + /// data-plane. This is "true" for data-plane operations and "false" + /// for ARM/control-plane operations. + /// Localized display information for this + /// particular operation. + /// The intended executor of the operation; as in + /// Resource Based Access Control (RBAC) and audit logs UX. Default + /// value is "user,system". Possible values include: 'user', 'system', + /// 'user,system' + /// Enum. Indicates the action type. + /// "Internal" refers to actions that are for internal only APIs. + /// Possible values include: 'Internal' + /// Operation id: + /// {provider}/{resource}/{operation}. + public CostManagementOperation(string name = default(string), bool? isDataAction = default(bool?), OperationDisplay display = default(OperationDisplay), string origin = default(string), string actionType = default(string), string id = default(string)) + : base(name, isDataAction, display, origin, actionType) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets operation id: {provider}/{resource}/{operation}. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostManagementProxyResource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostManagementProxyResource.cs new file mode 100644 index 0000000000000..c1a8952942341 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostManagementProxyResource.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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The Resource model definition. + /// + public partial class CostManagementProxyResource : IResource + { + /// + /// Initializes a new instance of the CostManagementProxyResource + /// class. + /// + public CostManagementProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CostManagementProxyResource + /// 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. + public CostManagementProxyResource(string id = default(string), string name = default(string), string type = default(string), string eTag = default(string)) + { + Id = id; + Name = name; + Type = type; + ETag = eTag; + 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 or sets 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. + /// + [JsonProperty(PropertyName = "eTag")] + public string ETag { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostManagementResource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostManagementResource.cs new file mode 100644 index 0000000000000..35fa34e5e4b5e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CostManagementResource.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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The Resource model definition. + /// + public partial class CostManagementResource : IResource + { + /// + /// Initializes a new instance of the CostManagementResource class. + /// + public CostManagementResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CostManagementResource class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Location of the resource. + /// SKU of the resource. + /// ETag of the resource. + /// Resource tags. + public CostManagementResource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), string sku = default(string), string eTag = default(string), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Location = location; + Sku = sku; + ETag = eTag; + Tags = tags; + 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 location of the resource. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; private set; } + + /// + /// Gets SKU of the resource. + /// + [JsonProperty(PropertyName = "sku")] + public string Sku { get; private set; } + + /// + /// Gets eTag of the resource. + /// + [JsonProperty(PropertyName = "eTag")] + public string ETag { get; private set; } + + /// + /// Gets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CreatedByType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CreatedByType.cs new file mode 100644 index 0000000000000..b822acdc17997 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CreatedByType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + + /// + /// Defines values for CreatedByType. + /// + public static class CreatedByType + { + public const string User = "User"; + public const string Application = "Application"; + public const string ManagedIdentity = "ManagedIdentity"; + public const string Key = "Key"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DaysOfWeek.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DaysOfWeek.cs new file mode 100644 index 0000000000000..2cdc4ef02d314 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DaysOfWeek.cs @@ -0,0 +1,27 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for DaysOfWeek. + /// + public static class DaysOfWeek + { + public const string Monday = "Monday"; + public const string Tuesday = "Tuesday"; + public const string Wednesday = "Wednesday"; + public const string Thursday = "Thursday"; + public const string Friday = "Friday"; + public const string Saturday = "Saturday"; + public const string Sunday = "Sunday"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Dimension.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Dimension.cs new file mode 100644 index 0000000000000..b3af3f06a232b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Dimension.cs @@ -0,0 +1,129 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of Dimension. + /// + [Rest.Serialization.JsonTransformation] + public partial class Dimension : CostManagementResource + { + /// + /// Initializes a new instance of the Dimension class. + /// + public Dimension() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Dimension class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Location of the resource. + /// SKU of the resource. + /// ETag of the resource. + /// Resource tags. + /// Dimension description. + /// Filter enabled. + /// Grouping enabled. + /// Dimension data. + /// Total number of data for the dimension. + /// Dimension category. + /// Usage start. + /// Usage end. + /// The link (url) to the next page of + /// results. + public Dimension(string id = default(string), string name = default(string), string type = default(string), string location = default(string), string sku = default(string), string eTag = default(string), IDictionary tags = default(IDictionary), string description = default(string), bool? filterEnabled = default(bool?), bool? groupingEnabled = default(bool?), IList data = default(IList), int? total = default(int?), string category = default(string), System.DateTime? usageStart = default(System.DateTime?), System.DateTime? usageEnd = default(System.DateTime?), string nextLink = default(string)) + : base(id, name, type, location, sku, eTag, tags) + { + Description = description; + FilterEnabled = filterEnabled; + GroupingEnabled = groupingEnabled; + Data = data; + Total = total; + Category = category; + UsageStart = usageStart; + UsageEnd = usageEnd; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets dimension description. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; private set; } + + /// + /// Gets filter enabled. + /// + [JsonProperty(PropertyName = "properties.filterEnabled")] + public bool? FilterEnabled { get; private set; } + + /// + /// Gets grouping enabled. + /// + [JsonProperty(PropertyName = "properties.groupingEnabled")] + public bool? GroupingEnabled { get; private set; } + + /// + /// Gets or sets dimension data. + /// + [JsonProperty(PropertyName = "properties.data")] + public IList Data { get; set; } + + /// + /// Gets total number of data for the dimension. + /// + [JsonProperty(PropertyName = "properties.total")] + public int? Total { get; private set; } + + /// + /// Gets dimension category. + /// + [JsonProperty(PropertyName = "properties.category")] + public string Category { get; private set; } + + /// + /// Gets usage start. + /// + [JsonProperty(PropertyName = "properties.usageStart")] + public System.DateTime? UsageStart { get; private set; } + + /// + /// Gets usage end. + /// + [JsonProperty(PropertyName = "properties.usageEnd")] + public System.DateTime? UsageEnd { get; private set; } + + /// + /// Gets the link (url) to the next page of results. + /// + [JsonProperty(PropertyName = "properties.nextLink")] + public string NextLink { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DismissAlertPayload.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DismissAlertPayload.cs new file mode 100644 index 0000000000000..e801d88f68871 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DismissAlertPayload.cs @@ -0,0 +1,142 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The request payload to update an alert + /// + [Rest.Serialization.JsonTransformation] + public partial class DismissAlertPayload + { + /// + /// Initializes a new instance of the DismissAlertPayload class. + /// + public DismissAlertPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DismissAlertPayload class. + /// + /// defines the type of alert + /// Alert description + /// Source of alert. Possible values include: + /// 'Preset', 'User' + /// Alert details + /// related budget + /// alert status. Possible values include: 'None', + /// 'Active', 'Overridden', 'Resolved', 'Dismissed' + /// dateTime in which alert was + /// created + /// dateTime in which alert was closed + /// dateTime in which alert was last + /// modified + /// User who last modified the + /// alert + /// dateTime in which the alert + /// status was last modified + public DismissAlertPayload(AlertPropertiesDefinition definition = default(AlertPropertiesDefinition), string description = default(string), string source = default(string), AlertPropertiesDetails details = default(AlertPropertiesDetails), string costEntityId = default(string), string status = default(string), string creationTime = default(string), string closeTime = default(string), string modificationTime = default(string), string statusModificationUserName = default(string), string statusModificationTime = default(string)) + { + Definition = definition; + Description = description; + Source = source; + Details = details; + CostEntityId = costEntityId; + Status = status; + CreationTime = creationTime; + CloseTime = closeTime; + ModificationTime = modificationTime; + StatusModificationUserName = statusModificationUserName; + StatusModificationTime = statusModificationTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets defines the type of alert + /// + [JsonProperty(PropertyName = "properties.definition")] + public AlertPropertiesDefinition Definition { get; set; } + + /// + /// Gets or sets alert description + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets source of alert. Possible values include: 'Preset', + /// 'User' + /// + [JsonProperty(PropertyName = "properties.source")] + public string Source { get; set; } + + /// + /// Gets or sets alert details + /// + [JsonProperty(PropertyName = "properties.details")] + public AlertPropertiesDetails Details { get; set; } + + /// + /// Gets or sets related budget + /// + [JsonProperty(PropertyName = "properties.costEntityId")] + public string CostEntityId { get; set; } + + /// + /// Gets or sets alert status. Possible values include: 'None', + /// 'Active', 'Overridden', 'Resolved', 'Dismissed' + /// + [JsonProperty(PropertyName = "properties.status")] + public string Status { get; set; } + + /// + /// Gets or sets dateTime in which alert was created + /// + [JsonProperty(PropertyName = "properties.creationTime")] + public string CreationTime { get; set; } + + /// + /// Gets or sets dateTime in which alert was closed + /// + [JsonProperty(PropertyName = "properties.closeTime")] + public string CloseTime { get; set; } + + /// + /// Gets or sets dateTime in which alert was last modified + /// + [JsonProperty(PropertyName = "properties.modificationTime")] + public string ModificationTime { get; set; } + + /// + /// Gets or sets user who last modified the alert + /// + [JsonProperty(PropertyName = "properties.statusModificationUserName")] + public string StatusModificationUserName { get; set; } + + /// + /// Gets or sets dateTime in which the alert status was last modified + /// + [JsonProperty(PropertyName = "properties.statusModificationTime")] + public string StatusModificationTime { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DownloadURL.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DownloadURL.cs new file mode 100644 index 0000000000000..321eb002bacd3 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DownloadURL.cs @@ -0,0 +1,72 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The URL to download the generated report. + /// + public partial class DownloadURL + { + /// + /// Initializes a new instance of the DownloadURL class. + /// + public DownloadURL() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DownloadURL class. + /// + /// The time at which report URL becomes + /// invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// The time at which report URL becomes + /// invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// The URL to download the generated + /// report. + public DownloadURL(System.DateTime? expiryTime = default(System.DateTime?), System.DateTime? validTill = default(System.DateTime?), string downloadUrl = default(string)) + { + ExpiryTime = expiryTime; + ValidTill = validTill; + DownloadUrl = downloadUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the time at which report URL becomes invalid/expires in UTC + /// e.g. 2020-12-08T05:55:59.4394737Z. + /// + [JsonProperty(PropertyName = "expiryTime")] + public System.DateTime? ExpiryTime { get; private set; } + + /// + /// Gets or sets the time at which report URL becomes invalid/expires + /// in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// + [JsonProperty(PropertyName = "validTill")] + public System.DateTime? ValidTill { get; set; } + + /// + /// Gets or sets the URL to download the generated report. + /// + [JsonProperty(PropertyName = "downloadUrl")] + public string DownloadUrl { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorDetails.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorDetails.cs new file mode 100644 index 0000000000000..f237d38c20151 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorDetails.cs @@ -0,0 +1,60 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The details of the error. + /// + public partial class ErrorDetails + { + /// + /// Initializes a new instance of the ErrorDetails class. + /// + public ErrorDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDetails class. + /// + /// Error code. + /// Error message indicating why the operation + /// failed. + public ErrorDetails(string code = default(string), string message = default(string)) + { + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets error code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// + /// Gets error message indicating why the operation failed. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorResponse.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 0000000000000..506ee1690c792 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorResponse.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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error response indicates that the service is not able to process the + /// incoming request. The reason is provided in the error message. + /// + /// Some Error responses: + /// + /// * 429 TooManyRequests - Request is throttled. Retry after waiting for + /// the time specified in the + /// "x-ms-ratelimit-microsoft.consumption-retry-after" header. + /// + /// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry + /// after waiting for the time specified in the "Retry-After" header. + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// The details of the error. + public ErrorResponse(ErrorDetails error = default(ErrorDetails)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the details of the error. + /// + [JsonProperty(PropertyName = "error")] + public ErrorDetails Error { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorResponseException.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorResponseException.cs new file mode 100644 index 0000000000000..a464dabb029b3 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorResponse + /// information. + /// + public partial class ErrorResponseException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + public ErrorResponseException() + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + public ErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExecutionStatus.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExecutionStatus.cs new file mode 100644 index 0000000000000..41f63b19afef0 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExecutionStatus.cs @@ -0,0 +1,27 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for ExecutionStatus. + /// + public static class ExecutionStatus + { + public const string Queued = "Queued"; + public const string InProgress = "InProgress"; + public const string Completed = "Completed"; + public const string Failed = "Failed"; + public const string Timeout = "Timeout"; + public const string NewDataNotAvailable = "NewDataNotAvailable"; + public const string DataNotAvailable = "DataNotAvailable"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExecutionType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExecutionType.cs new file mode 100644 index 0000000000000..71632ddbe3215 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExecutionType.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.CostManagement.Models +{ + + /// + /// Defines values for ExecutionType. + /// + public static class ExecutionType + { + public const string OnDemand = "OnDemand"; + public const string Scheduled = "Scheduled"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Export.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Export.cs new file mode 100644 index 0000000000000..c0fd4f3ab4c13 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Export.cs @@ -0,0 +1,153 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// An export resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class Export : CostManagementProxyResource + { + /// + /// Initializes a new instance of the Export class. + /// + public Export() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Export class. + /// + /// Has delivery information for the + /// export. + /// Has the definition for the export. + /// 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. + /// The format of the export being delivered. + /// Currently only 'Csv' is supported. Possible values include: + /// 'Csv' + /// If requested, has the most recent run + /// history for the export. + /// If set to true, exported data will be + /// partitioned by size and placed in a blob directory together with a + /// manifest file. Note: this option is currently available only for + /// Microsoft Customer Agreement commerce scopes. + /// If the export has an active + /// schedule, provides an estimate of the next run time. + /// Has schedule information for the + /// export. + public Export(ExportDeliveryInfo deliveryInfo, ExportDefinition definition, string id = default(string), string name = default(string), string type = default(string), string eTag = default(string), string format = default(string), ExportExecutionListResult runHistory = default(ExportExecutionListResult), bool? partitionData = default(bool?), System.DateTime? nextRunTimeEstimate = default(System.DateTime?), ExportSchedule schedule = default(ExportSchedule)) + : base(id, name, type, eTag) + { + Format = format; + DeliveryInfo = deliveryInfo; + Definition = definition; + RunHistory = runHistory; + PartitionData = partitionData; + NextRunTimeEstimate = nextRunTimeEstimate; + Schedule = schedule; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the format of the export being delivered. Currently + /// only 'Csv' is supported. Possible values include: 'Csv' + /// + [JsonProperty(PropertyName = "properties.format")] + public string Format { get; set; } + + /// + /// Gets or sets has delivery information for the export. + /// + [JsonProperty(PropertyName = "properties.deliveryInfo")] + public ExportDeliveryInfo DeliveryInfo { get; set; } + + /// + /// Gets or sets has the definition for the export. + /// + [JsonProperty(PropertyName = "properties.definition")] + public ExportDefinition Definition { get; set; } + + /// + /// Gets or sets if requested, has the most recent run history for the + /// export. + /// + [JsonProperty(PropertyName = "properties.runHistory")] + public ExportExecutionListResult RunHistory { get; set; } + + /// + /// Gets or sets if set to true, exported data will be partitioned by + /// size and placed in a blob directory together with a manifest file. + /// Note: this option is currently available only for Microsoft + /// Customer Agreement commerce scopes. + /// + [JsonProperty(PropertyName = "properties.partitionData")] + public bool? PartitionData { get; set; } + + /// + /// Gets if the export has an active schedule, provides an estimate of + /// the next run time. + /// + [JsonProperty(PropertyName = "properties.nextRunTimeEstimate")] + public System.DateTime? NextRunTimeEstimate { get; private set; } + + /// + /// Gets or sets has schedule information for the export. + /// + [JsonProperty(PropertyName = "properties.schedule")] + public ExportSchedule Schedule { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (DeliveryInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DeliveryInfo"); + } + if (Definition == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Definition"); + } + if (DeliveryInfo != null) + { + DeliveryInfo.Validate(); + } + if (Definition != null) + { + Definition.Validate(); + } + if (Schedule != null) + { + Schedule.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDataset.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDataset.cs new file mode 100644 index 0000000000000..8a8fb110b20e7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDataset.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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The definition for data in the export. + /// + public partial class ExportDataset + { + /// + /// Initializes a new instance of the ExportDataset class. + /// + public ExportDataset() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportDataset class. + /// + /// The granularity of rows in the export. + /// Currently only 'Daily' is supported. Possible values include: + /// 'Daily' + /// The export dataset + /// configuration. + public ExportDataset(string granularity = default(string), ExportDatasetConfiguration configuration = default(ExportDatasetConfiguration)) + { + Granularity = granularity; + Configuration = configuration; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the granularity of rows in the export. Currently only + /// 'Daily' is supported. Possible values include: 'Daily' + /// + [JsonProperty(PropertyName = "granularity")] + public string Granularity { get; set; } + + /// + /// Gets or sets the export dataset configuration. + /// + [JsonProperty(PropertyName = "configuration")] + public ExportDatasetConfiguration Configuration { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDatasetConfiguration.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDatasetConfiguration.cs new file mode 100644 index 0000000000000..27eade45d0857 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDatasetConfiguration.cs @@ -0,0 +1,60 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The export dataset configuration. Allows columns to be selected for the + /// export. If not provided then the export will include all available + /// columns. + /// + public partial class ExportDatasetConfiguration + { + /// + /// Initializes a new instance of the ExportDatasetConfiguration class. + /// + public ExportDatasetConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportDatasetConfiguration class. + /// + /// Array of column names to be included in the + /// export. If not provided then the export will include all available + /// columns. The available columns can vary by customer channel (see + /// examples). + public ExportDatasetConfiguration(IList columns = default(IList)) + { + Columns = columns; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets array of column names to be included in the export. If + /// not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [JsonProperty(PropertyName = "columns")] + public IList Columns { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDefinition.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDefinition.cs new file mode 100644 index 0000000000000..01e64a204a0d7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDefinition.cs @@ -0,0 +1,114 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The definition of an export. + /// + public partial class ExportDefinition + { + /// + /// Initializes a new instance of the ExportDefinition class. + /// + public ExportDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportDefinition class. + /// + /// The type of the export. Note that 'Usage' is + /// equivalent to 'ActualCost' and is applicable to exports that do not + /// yet provide data for charges or amortization for service + /// reservations. Possible values include: 'Usage', 'ActualCost', + /// 'AmortizedCost' + /// The time frame for pulling data for the + /// export. If custom, then a specific time period must be provided. + /// Possible values include: 'MonthToDate', 'BillingMonthToDate', + /// 'TheLastMonth', 'TheLastBillingMonth', 'WeekToDate', + /// 'Custom' + /// Has time period for pulling data for the + /// export. + /// The definition for data in the + /// export. + public ExportDefinition(string type, string timeframe, ExportTimePeriod timePeriod = default(ExportTimePeriod), ExportDataset dataSet = default(ExportDataset)) + { + Type = type; + Timeframe = timeframe; + TimePeriod = timePeriod; + DataSet = dataSet; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the export. Note that 'Usage' is + /// equivalent to 'ActualCost' and is applicable to exports that do not + /// yet provide data for charges or amortization for service + /// reservations. Possible values include: 'Usage', 'ActualCost', + /// 'AmortizedCost' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the time frame for pulling data for the export. If + /// custom, then a specific time period must be provided. Possible + /// values include: 'MonthToDate', 'BillingMonthToDate', + /// 'TheLastMonth', 'TheLastBillingMonth', 'WeekToDate', 'Custom' + /// + [JsonProperty(PropertyName = "timeframe")] + public string Timeframe { get; set; } + + /// + /// Gets or sets has time period for pulling data for the export. + /// + [JsonProperty(PropertyName = "timePeriod")] + public ExportTimePeriod TimePeriod { get; set; } + + /// + /// Gets or sets the definition for data in the export. + /// + [JsonProperty(PropertyName = "dataSet")] + public ExportDataset DataSet { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + if (Timeframe == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Timeframe"); + } + if (TimePeriod != null) + { + TimePeriod.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDeliveryDestination.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDeliveryDestination.cs new file mode 100644 index 0000000000000..1365e63493865 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDeliveryDestination.cs @@ -0,0 +1,141 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// This represents the blob storage account location where exports of + /// costs will be delivered. There are two ways to configure the + /// destination. The approach recommended for most customers is to specify + /// the resourceId of the storage account. This requires a one-time + /// registration of the account's subscription with the + /// Microsoft.CostManagementExports resource provider in order to give Cost + /// Management services access to the storage. When creating an export in + /// the Azure portal this registration is performed automatically but API + /// users may need to register the subscription explicitly (for more + /// information see + /// https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services + /// ). Another way to configure the destination is available ONLY to + /// Partners with a Microsoft Partner Agreement plan who are global admins + /// of their billing account. These Partners, instead of specifying the + /// resourceId of a storage account, can specify the storage account name + /// along with a SAS token for the account. This allows exports of costs to + /// a storage account in any tenant. The SAS token should be created for + /// the blob service with Service/Container/Object resource types and with + /// Read/Write/Delete/List/Add/Create permissions (for more information see + /// https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key + /// ). + /// + public partial class ExportDeliveryDestination + { + /// + /// Initializes a new instance of the ExportDeliveryDestination class. + /// + public ExportDeliveryDestination() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportDeliveryDestination class. + /// + /// The name of the container where exports + /// will be uploaded. If the container does not exist it will be + /// created. + /// The resource id of the storage account + /// where exports will be delivered. This is not required if a sasToken + /// and storageAccount are specified. + /// The name of the directory where + /// exports will be uploaded. + /// A SAS token for the storage account. For a + /// restricted set of Azure customers this together with storageAccount + /// can be specified instead of resourceId. Note: the value returned by + /// the API for this property will always be obfuscated. Returning this + /// same obfuscated value will not result in the SAS token being + /// updated. To update this value a new SAS token must be + /// specified. + /// The storage account where exports will + /// be uploaded. For a restricted set of Azure customers this together + /// with sasToken can be specified instead of resourceId. + public ExportDeliveryDestination(string container, string resourceId = default(string), string rootFolderPath = default(string), string sasToken = default(string), string storageAccount = default(string)) + { + ResourceId = resourceId; + Container = container; + RootFolderPath = rootFolderPath; + SasToken = sasToken; + StorageAccount = storageAccount; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource id of the storage account where exports + /// will be delivered. This is not required if a sasToken and + /// storageAccount are specified. + /// + [JsonProperty(PropertyName = "resourceId")] + public string ResourceId { get; set; } + + /// + /// Gets or sets the name of the container where exports will be + /// uploaded. If the container does not exist it will be created. + /// + [JsonProperty(PropertyName = "container")] + public string Container { get; set; } + + /// + /// Gets or sets the name of the directory where exports will be + /// uploaded. + /// + [JsonProperty(PropertyName = "rootFolderPath")] + public string RootFolderPath { get; set; } + + /// + /// Gets or sets a SAS token for the storage account. For a restricted + /// set of Azure customers this together with storageAccount can be + /// specified instead of resourceId. Note: the value returned by the + /// API for this property will always be obfuscated. Returning this + /// same obfuscated value will not result in the SAS token being + /// updated. To update this value a new SAS token must be specified. + /// + [JsonProperty(PropertyName = "sasToken")] + public string SasToken { get; set; } + + /// + /// Gets or sets the storage account where exports will be uploaded. + /// For a restricted set of Azure customers this together with sasToken + /// can be specified instead of resourceId. + /// + [JsonProperty(PropertyName = "storageAccount")] + public string StorageAccount { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Container == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Container"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDeliveryInfo.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDeliveryInfo.cs new file mode 100644 index 0000000000000..cc3ce7ad1f54b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDeliveryInfo.cs @@ -0,0 +1,70 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The delivery information associated with a export. + /// + public partial class ExportDeliveryInfo + { + /// + /// Initializes a new instance of the ExportDeliveryInfo class. + /// + public ExportDeliveryInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportDeliveryInfo class. + /// + /// Has destination for the export being + /// delivered. + public ExportDeliveryInfo(ExportDeliveryDestination destination) + { + Destination = destination; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets has destination for the export being delivered. + /// + [JsonProperty(PropertyName = "destination")] + public ExportDeliveryDestination Destination { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Destination == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Destination"); + } + if (Destination != null) + { + Destination.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportExecutionListResult.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportExecutionListResult.cs new file mode 100644 index 0000000000000..df7c424b0111c --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportExecutionListResult.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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of listing the run history of an export. + /// + public partial class ExportExecutionListResult + { + /// + /// Initializes a new instance of the ExportExecutionListResult class. + /// + public ExportExecutionListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportExecutionListResult class. + /// + /// A list of export runs. + public ExportExecutionListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets a list of export runs. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportListResult.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportListResult.cs new file mode 100644 index 0000000000000..87faaf1f33f44 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportListResult.cs @@ -0,0 +1,54 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of listing exports. It contains a list of available exports in + /// the scope provided. + /// + public partial class ExportListResult + { + /// + /// Initializes a new instance of the ExportListResult class. + /// + public ExportListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportListResult class. + /// + /// The list of exports. + public ExportListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of exports. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportRecurrencePeriod.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportRecurrencePeriod.cs new file mode 100644 index 0000000000000..80ee81ce363d2 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportRecurrencePeriod.cs @@ -0,0 +1,69 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The start and end date for recurrence schedule. + /// + public partial class ExportRecurrencePeriod + { + /// + /// Initializes a new instance of the ExportRecurrencePeriod class. + /// + public ExportRecurrencePeriod() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportRecurrencePeriod class. + /// + /// The start date of recurrence. + /// The end date of recurrence. + public ExportRecurrencePeriod(System.DateTime fromProperty, System.DateTime? to = default(System.DateTime?)) + { + FromProperty = fromProperty; + To = to; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start date of recurrence. + /// + [JsonProperty(PropertyName = "from")] + public System.DateTime FromProperty { get; set; } + + /// + /// Gets or sets the end date of recurrence. + /// + [JsonProperty(PropertyName = "to")] + public System.DateTime? To { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportRun.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportRun.cs new file mode 100644 index 0000000000000..9a5a7c7b81e07 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportRun.cs @@ -0,0 +1,153 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// An export run. + /// + [Rest.Serialization.JsonTransformation] + public partial class ExportRun : CostManagementProxyResource + { + /// + /// Initializes a new instance of the ExportRun class. + /// + public ExportRun() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportRun 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. + /// The type of the export run. Possible + /// values include: 'OnDemand', 'Scheduled' + /// The last known status of the export run. + /// Possible values include: 'Queued', 'InProgress', 'Completed', + /// 'Failed', 'Timeout', 'NewDataNotAvailable', + /// 'DataNotAvailable' + /// The identifier for the entity that + /// triggered the export. For on-demand runs it is the user email. For + /// scheduled runs it is 'System'. + /// The time when export was queued to be + /// run. + /// The time when export was picked + /// up to be run. + /// The time when the export run + /// finished. + /// The name of the exported file. + /// The export settings that were in effect + /// for this run. + /// The details of any error. + public ExportRun(string id = default(string), string name = default(string), string type = default(string), string eTag = default(string), string executionType = default(string), string status = default(string), string submittedBy = default(string), System.DateTime? submittedTime = default(System.DateTime?), System.DateTime? processingStartTime = default(System.DateTime?), System.DateTime? processingEndTime = default(System.DateTime?), string fileName = default(string), CommonExportProperties runSettings = default(CommonExportProperties), ErrorDetails error = default(ErrorDetails)) + : base(id, name, type, eTag) + { + ExecutionType = executionType; + Status = status; + SubmittedBy = submittedBy; + SubmittedTime = submittedTime; + ProcessingStartTime = processingStartTime; + ProcessingEndTime = processingEndTime; + FileName = fileName; + RunSettings = runSettings; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the export run. Possible values include: + /// 'OnDemand', 'Scheduled' + /// + [JsonProperty(PropertyName = "properties.executionType")] + public string ExecutionType { get; set; } + + /// + /// Gets or sets the last known status of the export run. Possible + /// values include: 'Queued', 'InProgress', 'Completed', 'Failed', + /// 'Timeout', 'NewDataNotAvailable', 'DataNotAvailable' + /// + [JsonProperty(PropertyName = "properties.status")] + public string Status { get; set; } + + /// + /// Gets or sets the identifier for the entity that triggered the + /// export. For on-demand runs it is the user email. For scheduled runs + /// it is 'System'. + /// + [JsonProperty(PropertyName = "properties.submittedBy")] + public string SubmittedBy { get; set; } + + /// + /// Gets or sets the time when export was queued to be run. + /// + [JsonProperty(PropertyName = "properties.submittedTime")] + public System.DateTime? SubmittedTime { get; set; } + + /// + /// Gets or sets the time when export was picked up to be run. + /// + [JsonProperty(PropertyName = "properties.processingStartTime")] + public System.DateTime? ProcessingStartTime { get; set; } + + /// + /// Gets or sets the time when the export run finished. + /// + [JsonProperty(PropertyName = "properties.processingEndTime")] + public System.DateTime? ProcessingEndTime { get; set; } + + /// + /// Gets or sets the name of the exported file. + /// + [JsonProperty(PropertyName = "properties.fileName")] + public string FileName { get; set; } + + /// + /// Gets or sets the export settings that were in effect for this run. + /// + [JsonProperty(PropertyName = "properties.runSettings")] + public CommonExportProperties RunSettings { get; set; } + + /// + /// Gets or sets the details of any error. + /// + [JsonProperty(PropertyName = "properties.error")] + public ErrorDetails Error { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RunSettings != null) + { + RunSettings.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportSchedule.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportSchedule.cs new file mode 100644 index 0000000000000..8f16d5ca5dc31 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportSchedule.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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The schedule associated with the export. + /// + public partial class ExportSchedule + { + /// + /// Initializes a new instance of the ExportSchedule class. + /// + public ExportSchedule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportSchedule class. + /// + /// The status of the export's schedule. If + /// 'Inactive', the export's schedule is paused. Possible values + /// include: 'Active', 'Inactive' + /// The schedule recurrence. Possible values + /// include: 'Daily', 'Weekly', 'Monthly', 'Annually' + /// Has start and end date of the + /// recurrence. The start date must be in future. If present, the end + /// date must be greater than start date. + public ExportSchedule(string status = default(string), string recurrence = default(string), ExportRecurrencePeriod recurrencePeriod = default(ExportRecurrencePeriod)) + { + Status = status; + Recurrence = recurrence; + RecurrencePeriod = recurrencePeriod; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the status of the export's schedule. If 'Inactive', + /// the export's schedule is paused. Possible values include: 'Active', + /// 'Inactive' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the schedule recurrence. Possible values include: + /// 'Daily', 'Weekly', 'Monthly', 'Annually' + /// + [JsonProperty(PropertyName = "recurrence")] + public string Recurrence { get; set; } + + /// + /// Gets or sets has start and end date of the recurrence. The start + /// date must be in future. If present, the end date must be greater + /// than start date. + /// + [JsonProperty(PropertyName = "recurrencePeriod")] + public ExportRecurrencePeriod RecurrencePeriod { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RecurrencePeriod != null) + { + RecurrencePeriod.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportTimePeriod.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportTimePeriod.cs new file mode 100644 index 0000000000000..43477d84012b7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportTimePeriod.cs @@ -0,0 +1,70 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The date range for data in the export. This should only be specified + /// with timeFrame set to 'Custom'. The maximum date range is 3 months. + /// + public partial class ExportTimePeriod + { + /// + /// Initializes a new instance of the ExportTimePeriod class. + /// + public ExportTimePeriod() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportTimePeriod class. + /// + /// The start date for export data. + /// The end date for export data. + public ExportTimePeriod(System.DateTime fromProperty, System.DateTime to) + { + FromProperty = fromProperty; + To = to; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start date for export data. + /// + [JsonProperty(PropertyName = "from")] + public System.DateTime FromProperty { get; set; } + + /// + /// Gets or sets the end date for export data. + /// + [JsonProperty(PropertyName = "to")] + public System.DateTime To { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportType.cs new file mode 100644 index 0000000000000..d053c79778aef --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportType.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.CostManagement.Models +{ + + /// + /// Defines values for ExportType. + /// + public static class ExportType + { + public const string Usage = "Usage"; + public const string ActualCost = "ActualCost"; + public const string AmortizedCost = "AmortizedCost"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExternalCloudProviderType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExternalCloudProviderType.cs new file mode 100644 index 0000000000000..37440470b71ab --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExternalCloudProviderType.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.CostManagement.Models +{ + + /// + /// Defines values for ExternalCloudProviderType. + /// + public static class ExternalCloudProviderType + { + public const string ExternalSubscriptions = "externalSubscriptions"; + public const string ExternalBillingAccounts = "externalBillingAccounts"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FileDestination.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FileDestination.cs new file mode 100644 index 0000000000000..2cc71b6c549d1 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FileDestination.cs @@ -0,0 +1,56 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Destination of the view data. This is optional. Currently only CSV + /// format is supported. + /// + public partial class FileDestination + { + /// + /// Initializes a new instance of the FileDestination class. + /// + public FileDestination() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FileDestination class. + /// + /// Destination of the view data. Currently + /// only CSV format is supported. + public FileDestination(IList fileFormats = default(IList)) + { + FileFormats = fileFormats; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets destination of the view data. Currently only CSV + /// format is supported. + /// + [JsonProperty(PropertyName = "fileFormats")] + public IList FileFormats { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FileFormat.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FileFormat.cs new file mode 100644 index 0000000000000..a1895aee70a8e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FileFormat.cs @@ -0,0 +1,21 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for FileFormat. + /// + public static class FileFormat + { + public const string Csv = "Csv"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastAggregation.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastAggregation.cs new file mode 100644 index 0000000000000..99c076f6df42f --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastAggregation.cs @@ -0,0 +1,81 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The aggregation expression to be used in the forecast. + /// + public partial class ForecastAggregation + { + /// + /// Initializes a new instance of the ForecastAggregation class. + /// + public ForecastAggregation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastAggregation class. + /// + /// The name of the column to aggregate. Possible + /// values include: 'PreTaxCostUSD', 'Cost', 'CostUSD', + /// 'PreTaxCost' + public ForecastAggregation(string name) + { + Name = name; + CustomInit(); + } + /// + /// Static constructor for ForecastAggregation class. + /// + static ForecastAggregation() + { + Function = "Sum"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the column to aggregate. Possible values + /// include: 'PreTaxCostUSD', 'Cost', 'CostUSD', 'PreTaxCost' + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// The name of the aggregation function to use. + /// + [JsonProperty(PropertyName = "function")] + public static string Function { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastColumn.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastColumn.cs new file mode 100644 index 0000000000000..3f1963bd8071f --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastColumn.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Forecast column properties + /// + public partial class ForecastColumn + { + /// + /// Initializes a new instance of the ForecastColumn class. + /// + public ForecastColumn() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastColumn class. + /// + /// The name of column. + /// The type of column. + public ForecastColumn(string name = default(string), string type = default(string)) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of column. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the type of column. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastComparisonExpression.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastComparisonExpression.cs new file mode 100644 index 0000000000000..3a2f4577c6c59 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastComparisonExpression.cs @@ -0,0 +1,102 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The comparison expression to be used in the forecast. + /// + public partial class ForecastComparisonExpression + { + /// + /// Initializes a new instance of the ForecastComparisonExpression + /// class. + /// + public ForecastComparisonExpression() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastComparisonExpression + /// class. + /// + /// The name of the column to use in + /// comparison. + /// Array of values to use for comparison + public ForecastComparisonExpression(string name, IList values) + { + Name = name; + Values = values; + CustomInit(); + } + /// + /// Static constructor for ForecastComparisonExpression class. + /// + static ForecastComparisonExpression() + { + OperatorProperty = "In"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the column to use in comparison. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets array of values to use for comparison + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + /// + /// The operator to use for comparison. + /// + [JsonProperty(PropertyName = "operator")] + public static string OperatorProperty { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Values == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Values"); + } + if (Values != null) + { + if (Values.Count < 1) + { + throw new ValidationException(ValidationRules.MinItems, "Values", 1); + } + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDataset.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDataset.cs new file mode 100644 index 0000000000000..84e1fc8ea6e50 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDataset.cs @@ -0,0 +1,118 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The definition of data present in the forecast. + /// + public partial class ForecastDataset + { + /// + /// Initializes a new instance of the ForecastDataset class. + /// + public ForecastDataset() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastDataset class. + /// + /// Dictionary of aggregation expression to + /// use in the forecast. The key of each item in the dictionary is the + /// alias for the aggregated column. forecast can have up to 2 + /// aggregation clauses. + /// The granularity of rows in the forecast. + /// Possible values include: 'Daily' + /// Has configuration information for the + /// data in the export. The configuration will be ignored if + /// aggregation and grouping are provided. + /// Has filter expression to use in the + /// forecast. + public ForecastDataset(IDictionary aggregation, string granularity = default(string), ForecastDatasetConfiguration configuration = default(ForecastDatasetConfiguration), ForecastFilter filter = default(ForecastFilter)) + { + Granularity = granularity; + Configuration = configuration; + Aggregation = aggregation; + Filter = filter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the granularity of rows in the forecast. Possible + /// values include: 'Daily' + /// + [JsonProperty(PropertyName = "granularity")] + public string Granularity { get; set; } + + /// + /// Gets or sets has configuration information for the data in the + /// export. The configuration will be ignored if aggregation and + /// grouping are provided. + /// + [JsonProperty(PropertyName = "configuration")] + public ForecastDatasetConfiguration Configuration { get; set; } + + /// + /// Gets or sets dictionary of aggregation expression to use in the + /// forecast. The key of each item in the dictionary is the alias for + /// the aggregated column. forecast can have up to 2 aggregation + /// clauses. + /// + [JsonProperty(PropertyName = "aggregation")] + public IDictionary Aggregation { get; set; } + + /// + /// Gets or sets has filter expression to use in the forecast. + /// + [JsonProperty(PropertyName = "filter")] + public ForecastFilter Filter { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Aggregation == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Aggregation"); + } + if (Aggregation != null) + { + foreach (var valueElement in Aggregation.Values) + { + if (valueElement != null) + { + valueElement.Validate(); + } + } + } + if (Filter != null) + { + Filter.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDatasetConfiguration.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDatasetConfiguration.cs new file mode 100644 index 0000000000000..081b538df67d1 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDatasetConfiguration.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The configuration of dataset in the forecast. + /// + public partial class ForecastDatasetConfiguration + { + /// + /// Initializes a new instance of the ForecastDatasetConfiguration + /// class. + /// + public ForecastDatasetConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastDatasetConfiguration + /// class. + /// + /// Array of column names to be included in the + /// forecast. Any valid forecast column name is allowed. If not + /// provided, then forecast includes all columns. + public ForecastDatasetConfiguration(IList columns = default(IList)) + { + Columns = columns; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets array of column names to be included in the forecast. + /// Any valid forecast column name is allowed. If not provided, then + /// forecast includes all columns. + /// + [JsonProperty(PropertyName = "columns")] + public IList Columns { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDefinition.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDefinition.cs new file mode 100644 index 0000000000000..7c3b537f838d7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDefinition.cs @@ -0,0 +1,131 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The definition of a forecast. + /// + public partial class ForecastDefinition + { + /// + /// Initializes a new instance of the ForecastDefinition class. + /// + public ForecastDefinition() + { + Dataset = new ForecastDataset(); + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastDefinition class. + /// + /// The type of the forecast. Possible values + /// include: 'Usage', 'ActualCost', 'AmortizedCost' + /// Has definition for data in this + /// forecast. + /// Has time period for pulling data for the + /// forecast. + /// A boolean determining if actualCost + /// will be included. + /// A boolean determining if + /// FreshPartialCost will be included. + public ForecastDefinition(string type, ForecastDataset dataset, ForecastTimePeriod timePeriod = default(ForecastTimePeriod), bool? includeActualCost = default(bool?), bool? includeFreshPartialCost = default(bool?)) + { + Type = type; + TimePeriod = timePeriod; + Dataset = dataset; + IncludeActualCost = includeActualCost; + IncludeFreshPartialCost = includeFreshPartialCost; + CustomInit(); + } + /// + /// Static constructor for ForecastDefinition class. + /// + static ForecastDefinition() + { + Timeframe = "Custom"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the forecast. Possible values include: + /// 'Usage', 'ActualCost', 'AmortizedCost' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets has time period for pulling data for the forecast. + /// + [JsonProperty(PropertyName = "timePeriod")] + public ForecastTimePeriod TimePeriod { get; set; } + + /// + /// Gets or sets has definition for data in this forecast. + /// + [JsonProperty(PropertyName = "dataset")] + public ForecastDataset Dataset { get; set; } + + /// + /// Gets or sets a boolean determining if actualCost will be included. + /// + [JsonProperty(PropertyName = "includeActualCost")] + public bool? IncludeActualCost { get; set; } + + /// + /// Gets or sets a boolean determining if FreshPartialCost will be + /// included. + /// + [JsonProperty(PropertyName = "includeFreshPartialCost")] + public bool? IncludeFreshPartialCost { get; set; } + + /// + /// The time frame for pulling data for the forecast. If custom, then a + /// specific time period must be provided. + /// + [JsonProperty(PropertyName = "timeframe")] + public static string Timeframe { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + if (Dataset == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Dataset"); + } + if (TimePeriod != null) + { + TimePeriod.Validate(); + } + if (Dataset != null) + { + Dataset.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastFilter.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastFilter.cs new file mode 100644 index 0000000000000..64c755c849fe4 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastFilter.cs @@ -0,0 +1,128 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The filter expression to be used in the export. + /// + public partial class ForecastFilter + { + /// + /// Initializes a new instance of the ForecastFilter class. + /// + public ForecastFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastFilter class. + /// + /// The logical "AND" expression. Must have at least + /// 2 items. + /// The logical "OR" expression. Must have at least 2 + /// items. + /// Has comparison expression for a + /// dimension + /// Has comparison expression for a tag + public ForecastFilter(IList and = default(IList), IList or = default(IList), ForecastComparisonExpression dimensions = default(ForecastComparisonExpression), ForecastComparisonExpression tags = default(ForecastComparisonExpression)) + { + And = and; + Or = or; + Dimensions = dimensions; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the logical "AND" expression. Must have at least 2 + /// items. + /// + [JsonProperty(PropertyName = "and")] + public IList And { get; set; } + + /// + /// Gets or sets the logical "OR" expression. Must have at least 2 + /// items. + /// + [JsonProperty(PropertyName = "or")] + public IList Or { get; set; } + + /// + /// Gets or sets has comparison expression for a dimension + /// + [JsonProperty(PropertyName = "dimensions")] + public ForecastComparisonExpression Dimensions { get; set; } + + /// + /// Gets or sets has comparison expression for a tag + /// + [JsonProperty(PropertyName = "tags")] + public ForecastComparisonExpression Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (And != null) + { + if (And.Count < 2) + { + throw new ValidationException(ValidationRules.MinItems, "And", 2); + } + foreach (var element in And) + { + if (element != null) + { + element.Validate(); + } + } + } + if (Or != null) + { + if (Or.Count < 2) + { + throw new ValidationException(ValidationRules.MinItems, "Or", 2); + } + foreach (var element1 in Or) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (Dimensions != null) + { + Dimensions.Validate(); + } + if (Tags != null) + { + Tags.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastResult.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastResult.cs new file mode 100644 index 0000000000000..a27495fc874e7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastResult.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of forecast. It contains all columns listed under groupings and + /// aggregation. + /// + [Rest.Serialization.JsonTransformation] + public partial class ForecastResult : CostManagementResource + { + /// + /// Initializes a new instance of the ForecastResult class. + /// + public ForecastResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastResult class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Location of the resource. + /// SKU of the resource. + /// ETag of the resource. + /// Resource tags. + /// The link (url) to the next page of + /// results. + /// Array of columns + /// Array of rows + public ForecastResult(string id = default(string), string name = default(string), string type = default(string), string location = default(string), string sku = default(string), string eTag = default(string), IDictionary tags = default(IDictionary), string nextLink = default(string), IList columns = default(IList), IList> rows = default(IList>)) + : base(id, name, type, location, sku, eTag, tags) + { + NextLink = nextLink; + Columns = columns; + Rows = rows; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the link (url) to the next page of results. + /// + [JsonProperty(PropertyName = "properties.nextLink")] + public string NextLink { get; set; } + + /// + /// Gets or sets array of columns + /// + [JsonProperty(PropertyName = "properties.columns")] + public IList Columns { get; set; } + + /// + /// Gets or sets array of rows + /// + [JsonProperty(PropertyName = "properties.rows")] + public IList> Rows { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimePeriod.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimePeriod.cs new file mode 100644 index 0000000000000..72a086a7c78a7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimePeriod.cs @@ -0,0 +1,70 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Has time period for pulling data for the forecast. + /// + public partial class ForecastTimePeriod + { + /// + /// Initializes a new instance of the ForecastTimePeriod class. + /// + public ForecastTimePeriod() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastTimePeriod class. + /// + /// The start date to pull data + /// from. + /// The end date to pull data to. + public ForecastTimePeriod(System.DateTime fromProperty, System.DateTime to) + { + FromProperty = fromProperty; + To = to; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start date to pull data from. + /// + [JsonProperty(PropertyName = "from")] + public System.DateTime FromProperty { get; set; } + + /// + /// Gets or sets the end date to pull data to. + /// + [JsonProperty(PropertyName = "to")] + public System.DateTime To { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimeframe.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimeframe.cs new file mode 100644 index 0000000000000..1a77dc75cfb87 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimeframe.cs @@ -0,0 +1,21 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for ForecastTimeframe. + /// + public static class ForecastTimeframe + { + public const string Custom = "Custom"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastType.cs new file mode 100644 index 0000000000000..f55f0139b65ec --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastType.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.CostManagement.Models +{ + + /// + /// Defines values for ForecastType. + /// + public static class ForecastType + { + public const string Usage = "Usage"; + public const string ActualCost = "ActualCost"; + public const string AmortizedCost = "AmortizedCost"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FormatType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FormatType.cs new file mode 100644 index 0000000000000..6c07b22a8a1f7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FormatType.cs @@ -0,0 +1,21 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for FormatType. + /// + public static class FormatType + { + public const string Csv = "Csv"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FunctionName.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FunctionName.cs new file mode 100644 index 0000000000000..f52fad0e4ed14 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FunctionName.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + + /// + /// Defines values for FunctionName. + /// + public static class FunctionName + { + public const string PreTaxCostUSD = "PreTaxCostUSD"; + public const string Cost = "Cost"; + public const string CostUSD = "CostUSD"; + public const string PreTaxCost = "PreTaxCost"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportCreateOperationHeaders.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportCreateOperationHeaders.cs new file mode 100644 index 0000000000000..40bc654ac51a7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportCreateOperationHeaders.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CreateOperation operation. + /// + public partial class GenerateCostDetailsReportCreateOperationHeaders + { + /// + /// Initializes a new instance of the + /// GenerateCostDetailsReportCreateOperationHeaders class. + /// + public GenerateCostDetailsReportCreateOperationHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateCostDetailsReportCreateOperationHeaders class. + /// + /// The URL to check the result of the + /// asynchronous operation. + /// The amount of delay to use while the + /// status of the operation is checked. The value is expressed in + /// seconds. + public GenerateCostDetailsReportCreateOperationHeaders(string location = default(string), int? retryAfter = default(int?)) + { + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the URL to check the result of the asynchronous + /// operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets the amount of delay to use while the status of the + /// operation is checked. The value is expressed in seconds. + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportErrorResponse.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportErrorResponse.cs new file mode 100644 index 0000000000000..ec05f8dc5377a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportErrorResponse.cs @@ -0,0 +1,77 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error response indicates that the service is not able to process the + /// incoming request. The reason is provided in the error message. + /// + /// Some Error responses: + /// + /// * 400 Bad Request - Invalid Request Payload. Request payload provided + /// is not in a json format or had an invalid member not accepted in the + /// request payload. + /// + /// * 400 Bad Request - Invalid request payload: can only have either + /// timePeriod or invoiceId or billingPeriod. API only allows data to be + /// pulled for either timePeriod or invoiceId or billingPeriod. Customer + /// should provide only one of these parameters. + /// + /// * 400 Bad Request - Start date must be after . API only allows data to + /// be pulled no older than 13 months from now. + /// + /// * 400 Bad Request - The maximum allowed date range is 1 months. API + /// only allows data to be pulled for 1 month or less. + /// + /// * 429 TooManyRequests - Request is throttled. Retry after waiting for + /// the time specified in the "retry-after" header. + /// + /// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry + /// after waiting for the time specified in the "Retry-After" header. + /// + public partial class GenerateCostDetailsReportErrorResponse + { + /// + /// Initializes a new instance of the + /// GenerateCostDetailsReportErrorResponse class. + /// + public GenerateCostDetailsReportErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateCostDetailsReportErrorResponse class. + /// + /// The details of the error. + public GenerateCostDetailsReportErrorResponse(ErrorDetails error = default(ErrorDetails)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the details of the error. + /// + [JsonProperty(PropertyName = "error")] + public ErrorDetails Error { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportErrorResponseException.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportErrorResponseException.cs new file mode 100644 index 0000000000000..124c2db22871b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with + /// GenerateCostDetailsReportErrorResponse information. + /// + public partial class GenerateCostDetailsReportErrorResponseException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public GenerateCostDetailsReportErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the GenerateCostDetailsReportErrorResponseException class. + /// + public GenerateCostDetailsReportErrorResponseException() + { + } + + /// + /// Initializes a new instance of the GenerateCostDetailsReportErrorResponseException class. + /// + /// The exception message. + public GenerateCostDetailsReportErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the GenerateCostDetailsReportErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public GenerateCostDetailsReportErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportRequestDefinition.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportRequestDefinition.cs new file mode 100644 index 0000000000000..fecd80cf2c610 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateCostDetailsReportRequestDefinition.cs @@ -0,0 +1,131 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The definition of a cost detailed report. + /// + public partial class GenerateCostDetailsReportRequestDefinition + { + /// + /// Initializes a new instance of the + /// GenerateCostDetailsReportRequestDefinition class. + /// + public GenerateCostDetailsReportRequestDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateCostDetailsReportRequestDefinition class. + /// + /// The type of the detailed report. By default + /// ActualCost is provided. Possible values include: + /// 'ActualCostCostDetailsMetricType', + /// 'AmortizedCostCostDetailsMetricType' + /// The specific date range of cost details + /// requested for the report. This parameter cannot be used alongside + /// either the invoiceId or billingPeriod parameters. If a timePeriod, + /// invoiceId or billingPeriod parameter is not provided in the request + /// body the API will return the current month's cost. API only allows + /// data to be pulled for 1 month or less and no older than 13 months. + /// If no timePeriod or billingPeriod or invoiceId is provided the API + /// defaults to the open month time period + /// This parameter can be used only by + /// Enterprise Agreement customers. Use the YearMonth(e.g. 202008) + /// format. This parameter cannot be used alongside either the + /// invoiceId or timePeriod parameters. If a timePeriod, invoiceId or + /// billingPeriod parameter is not provided in the request body the API + /// will return the current month's cost. + /// This parameter can only be used by + /// Microsoft Customer Agreement customers. Additionally, it can only + /// be used at the Billing Profile or Customer scope. This parameter + /// cannot be used alongside either the billingPeriod or timePeriod + /// parameters. If a timePeriod, invoiceId or billingPeriod parameter + /// is not provided in the request body the API will return the current + /// month's cost. + public GenerateCostDetailsReportRequestDefinition(string metric = default(string), CostDetailsTimePeriod timePeriod = default(CostDetailsTimePeriod), string billingPeriod = default(string), string invoiceId = default(string)) + { + Metric = metric; + TimePeriod = timePeriod; + BillingPeriod = billingPeriod; + InvoiceId = invoiceId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the detailed report. By default ActualCost + /// is provided. Possible values include: + /// 'ActualCostCostDetailsMetricType', + /// 'AmortizedCostCostDetailsMetricType' + /// + [JsonProperty(PropertyName = "metric")] + public string Metric { get; set; } + + /// + /// Gets or sets the specific date range of cost details requested for + /// the report. This parameter cannot be used alongside either the + /// invoiceId or billingPeriod parameters. If a timePeriod, invoiceId + /// or billingPeriod parameter is not provided in the request body the + /// API will return the current month's cost. API only allows data to + /// be pulled for 1 month or less and no older than 13 months. If no + /// timePeriod or billingPeriod or invoiceId is provided the API + /// defaults to the open month time period + /// + [JsonProperty(PropertyName = "timePeriod")] + public CostDetailsTimePeriod TimePeriod { get; set; } + + /// + /// Gets or sets this parameter can be used only by Enterprise + /// Agreement customers. Use the YearMonth(e.g. 202008) format. This + /// parameter cannot be used alongside either the invoiceId or + /// timePeriod parameters. If a timePeriod, invoiceId or billingPeriod + /// parameter is not provided in the request body the API will return + /// the current month's cost. + /// + [JsonProperty(PropertyName = "billingPeriod")] + public string BillingPeriod { get; set; } + + /// + /// Gets or sets this parameter can only be used by Microsoft Customer + /// Agreement customers. Additionally, it can only be used at the + /// Billing Profile or Customer scope. This parameter cannot be used + /// alongside either the billingPeriod or timePeriod parameters. If a + /// timePeriod, invoiceId or billingPeriod parameter is not provided in + /// the request body the API will return the current month's cost. + /// + [JsonProperty(PropertyName = "invoiceId")] + public string InvoiceId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (TimePeriod != null) + { + TimePeriod.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportCreateOperationHeaders.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportCreateOperationHeaders.cs new file mode 100644 index 0000000000000..680ffad1d88d2 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportCreateOperationHeaders.cs @@ -0,0 +1,86 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CreateOperation operation. + /// + public partial class GenerateDetailedCostReportCreateOperationHeaders + { + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportCreateOperationHeaders class. + /// + public GenerateDetailedCostReportCreateOperationHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportCreateOperationHeaders class. + /// + /// The URL to check the result of the + /// asynchronous operation. + /// The URL to check the + /// status of the asynchronous operation. + /// The URL to check the status of + /// the asynchronous operation. + /// The amount of delay to use while the + /// status of the operation is checked. The value is expressed in + /// seconds. + public GenerateDetailedCostReportCreateOperationHeaders(string location = default(string), string azureConsumptionAsyncOperation = default(string), string azureAsyncOperation = default(string), int? retryAfter = default(int?)) + { + Location = location; + AzureConsumptionAsyncOperation = azureConsumptionAsyncOperation; + AzureAsyncOperation = azureAsyncOperation; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the URL to check the result of the asynchronous + /// operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets the URL to check the status of the asynchronous + /// operation. + /// + [JsonProperty(PropertyName = "Azure-Consumption-AsyncOperation")] + public string AzureConsumptionAsyncOperation { get; set; } + + /// + /// Gets or sets the URL to check the status of the asynchronous + /// operation. + /// + [JsonProperty(PropertyName = "Azure-AsyncOperation")] + public string AzureAsyncOperation { get; set; } + + /// + /// Gets or sets the amount of delay to use while the status of the + /// operation is checked. The value is expressed in seconds. + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportDefinition.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportDefinition.cs new file mode 100644 index 0000000000000..48c10cc560465 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportDefinition.cs @@ -0,0 +1,122 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The definition of a cost detailed report. + /// + public partial class GenerateDetailedCostReportDefinition + { + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportDefinition class. + /// + public GenerateDetailedCostReportDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportDefinition class. + /// + /// The type of the detailed report. By default + /// ActualCost is provided. Possible values include: 'ActualCost', + /// 'AmortizedCost' + /// Has time period for pulling data for the + /// cost detailed report. Can only have one of either timePeriod or + /// invoiceId or billingPeriod parameters. If none provided current + /// month cost is provided. + /// Billing period in YearMonth(e.g. + /// 202008) format. Only for legacy enterprise customers can use this. + /// Can only have one of either timePeriod or invoiceId or + /// billingPeriod parameters. If none provided current month cost is + /// provided. + /// Invoice ID for Pay-as-you-go and Microsoft + /// Customer Agreement scopes. Can only have one of either timePeriod + /// or invoiceId or billingPeriod parameters. If none provided current + /// month cost is provided. + /// Customer ID for Microsoft Customer + /// Agreement scopes (Invoice Id is also required for this). + public GenerateDetailedCostReportDefinition(string metric = default(string), GenerateDetailedCostReportTimePeriod timePeriod = default(GenerateDetailedCostReportTimePeriod), string billingPeriod = default(string), string invoiceId = default(string), string customerId = default(string)) + { + Metric = metric; + TimePeriod = timePeriod; + BillingPeriod = billingPeriod; + InvoiceId = invoiceId; + CustomerId = customerId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the detailed report. By default ActualCost + /// is provided. Possible values include: 'ActualCost', 'AmortizedCost' + /// + [JsonProperty(PropertyName = "metric")] + public string Metric { get; set; } + + /// + /// Gets or sets has time period for pulling data for the cost detailed + /// report. Can only have one of either timePeriod or invoiceId or + /// billingPeriod parameters. If none provided current month cost is + /// provided. + /// + [JsonProperty(PropertyName = "timePeriod")] + public GenerateDetailedCostReportTimePeriod TimePeriod { get; set; } + + /// + /// Gets or sets billing period in YearMonth(e.g. 202008) format. Only + /// for legacy enterprise customers can use this. Can only have one of + /// either timePeriod or invoiceId or billingPeriod parameters. If none + /// provided current month cost is provided. + /// + [JsonProperty(PropertyName = "billingPeriod")] + public string BillingPeriod { get; set; } + + /// + /// Gets or sets invoice ID for Pay-as-you-go and Microsoft Customer + /// Agreement scopes. Can only have one of either timePeriod or + /// invoiceId or billingPeriod parameters. If none provided current + /// month cost is provided. + /// + [JsonProperty(PropertyName = "invoiceId")] + public string InvoiceId { get; set; } + + /// + /// Gets or sets customer ID for Microsoft Customer Agreement scopes + /// (Invoice Id is also required for this). + /// + [JsonProperty(PropertyName = "customerId")] + public string CustomerId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (TimePeriod != null) + { + TimePeriod.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportErrorResponse.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportErrorResponse.cs new file mode 100644 index 0000000000000..0e67a2b66da79 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportErrorResponse.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error response indicates that the service is not able to process the + /// incoming request. The reason is provided in the error message. + /// + /// Some Error responses: + /// + /// * 413 Request Entity Too Large - Request is throttled. The amount of + /// data required to fulfill the request exceeds the maximum size permitted + /// of 2Gb. Please utilize our Exports feature instead. + /// + /// * 429 TooManyRequests - Request is throttled. Retry after waiting for + /// the time specified in the + /// "x-ms-ratelimit-microsoft.consumption-retry-after" header. + /// + /// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry + /// after waiting for the time specified in the "Retry-After" header. + /// + public partial class GenerateDetailedCostReportErrorResponse + { + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportErrorResponse class. + /// + public GenerateDetailedCostReportErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportErrorResponse class. + /// + /// The details of the error. + public GenerateDetailedCostReportErrorResponse(ErrorDetails error = default(ErrorDetails)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the details of the error. + /// + [JsonProperty(PropertyName = "error")] + public ErrorDetails Error { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportErrorResponseException.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportErrorResponseException.cs new file mode 100644 index 0000000000000..5a2d3a6f17eb6 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with + /// GenerateDetailedCostReportErrorResponse information. + /// + public partial class GenerateDetailedCostReportErrorResponseException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public GenerateDetailedCostReportErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the GenerateDetailedCostReportErrorResponseException class. + /// + public GenerateDetailedCostReportErrorResponseException() + { + } + + /// + /// Initializes a new instance of the GenerateDetailedCostReportErrorResponseException class. + /// + /// The exception message. + public GenerateDetailedCostReportErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the GenerateDetailedCostReportErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public GenerateDetailedCostReportErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportMetricType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportMetricType.cs new file mode 100644 index 0000000000000..bff33102ae8e7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportMetricType.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.CostManagement.Models +{ + + /// + /// Defines values for GenerateDetailedCostReportMetricType. + /// + public static class GenerateDetailedCostReportMetricType + { + public const string ActualCost = "ActualCost"; + public const string AmortizedCost = "AmortizedCost"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportOperationResult.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportOperationResult.cs new file mode 100644 index 0000000000000..cfc35b86fd81a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportOperationResult.cs @@ -0,0 +1,102 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The result of the long running operation for cost detailed report. + /// + [Rest.Serialization.JsonTransformation] + public partial class GenerateDetailedCostReportOperationResult + { + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportOperationResult class. + /// + public GenerateDetailedCostReportOperationResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportOperationResult class. + /// + /// The ARM resource id of the long running + /// operation. + /// The name of the long running operation. + /// The type of the long running operation. + /// The time at which report URL becomes + /// invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// The time at which report URL becomes + /// invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// The URL to download the generated + /// report. + public GenerateDetailedCostReportOperationResult(string id = default(string), string name = default(string), string type = default(string), System.DateTime? expiryTime = default(System.DateTime?), System.DateTime? validTill = default(System.DateTime?), string downloadUrl = default(string)) + { + Id = id; + Name = name; + Type = type; + ExpiryTime = expiryTime; + ValidTill = validTill; + DownloadUrl = downloadUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ARM resource id of the long running operation. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the name of the long running operation. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the type of the long running operation. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets the time at which report URL becomes invalid/expires in UTC + /// e.g. 2020-12-08T05:55:59.4394737Z. + /// + [JsonProperty(PropertyName = "properties.expiryTime")] + public System.DateTime? ExpiryTime { get; private set; } + + /// + /// Gets or sets the time at which report URL becomes invalid/expires + /// in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// + [JsonProperty(PropertyName = "properties.validTill")] + public System.DateTime? ValidTill { get; set; } + + /// + /// Gets or sets the URL to download the generated report. + /// + [JsonProperty(PropertyName = "properties.downloadUrl")] + public string DownloadUrl { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportOperationStatuses.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportOperationStatuses.cs new file mode 100644 index 0000000000000..4c4376bb6ff41 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportOperationStatuses.cs @@ -0,0 +1,118 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The status of the long running operation for cost detailed report. + /// + [Rest.Serialization.JsonTransformation] + public partial class GenerateDetailedCostReportOperationStatuses + { + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportOperationStatuses class. + /// + public GenerateDetailedCostReportOperationStatuses() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportOperationStatuses class. + /// + /// The ID of the long running operation. + /// The name of the long running operation. + /// The status of the long running + /// operation. + /// The type of the long running operation. + /// The details of the error. + /// The time at which report URL becomes + /// invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// The time at which report URL becomes + /// invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// The URL to download the generated + /// report. + public GenerateDetailedCostReportOperationStatuses(string id = default(string), string name = default(string), Status status = default(Status), string type = default(string), ErrorDetails error = default(ErrorDetails), System.DateTime? expiryTime = default(System.DateTime?), System.DateTime? validTill = default(System.DateTime?), string downloadUrl = default(string)) + { + Id = id; + Name = name; + Status = status; + Type = type; + Error = error; + ExpiryTime = expiryTime; + ValidTill = validTill; + DownloadUrl = downloadUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ID of the long running operation. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the name of the long running operation. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the status of the long running operation. + /// + [JsonProperty(PropertyName = "status")] + public Status Status { get; set; } + + /// + /// Gets or sets the type of the long running operation. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the details of the error. + /// + [JsonProperty(PropertyName = "error")] + public ErrorDetails Error { get; set; } + + /// + /// Gets the time at which report URL becomes invalid/expires in UTC + /// e.g. 2020-12-08T05:55:59.4394737Z. + /// + [JsonProperty(PropertyName = "properties.expiryTime")] + public System.DateTime? ExpiryTime { get; private set; } + + /// + /// Gets or sets the time at which report URL becomes invalid/expires + /// in UTC e.g. 2020-12-08T05:55:59.4394737Z. + /// + [JsonProperty(PropertyName = "properties.validTill")] + public System.DateTime? ValidTill { get; set; } + + /// + /// Gets or sets the URL to download the generated report. + /// + [JsonProperty(PropertyName = "properties.downloadUrl")] + public string DownloadUrl { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportTimePeriod.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportTimePeriod.cs new file mode 100644 index 0000000000000..2d3760a1182ba --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateDetailedCostReportTimePeriod.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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The start and end date for pulling data for the cost detailed report. + /// + public partial class GenerateDetailedCostReportTimePeriod + { + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportTimePeriod class. + /// + public GenerateDetailedCostReportTimePeriod() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateDetailedCostReportTimePeriod class. + /// + /// The start date to pull data from. example + /// format 2020-03-15 + /// The end date to pull data to. example format + /// 2020-03-15 + public GenerateDetailedCostReportTimePeriod(string start, string end) + { + Start = start; + End = end; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start date to pull data from. example format + /// 2020-03-15 + /// + [JsonProperty(PropertyName = "start")] + public string Start { get; set; } + + /// + /// Gets or sets the end date to pull data to. example format + /// 2020-03-15 + /// + [JsonProperty(PropertyName = "end")] + public string End { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Start == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Start"); + } + if (End == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "End"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateReservationDetailsReportByBillingAccountIdHeaders.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateReservationDetailsReportByBillingAccountIdHeaders.cs new file mode 100644 index 0000000000000..cfa2a00549c14 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateReservationDetailsReportByBillingAccountIdHeaders.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for ByBillingAccountId operation. + /// + public partial class GenerateReservationDetailsReportByBillingAccountIdHeaders + { + /// + /// Initializes a new instance of the + /// GenerateReservationDetailsReportByBillingAccountIdHeaders class. + /// + public GenerateReservationDetailsReportByBillingAccountIdHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateReservationDetailsReportByBillingAccountIdHeaders class. + /// + /// The URL to check the status of the + /// asynchronous operation. + /// The amount of delay to use while the + /// status of the operation is checked. The value is expressed in + /// seconds. + public GenerateReservationDetailsReportByBillingAccountIdHeaders(string location = default(string), int? retryAfter = default(int?)) + { + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the URL to check the status of the asynchronous + /// operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets the amount of delay to use while the status of the + /// operation is checked. The value is expressed in seconds. + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateReservationDetailsReportByBillingProfileIdHeaders.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateReservationDetailsReportByBillingProfileIdHeaders.cs new file mode 100644 index 0000000000000..6b4bffd15321e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GenerateReservationDetailsReportByBillingProfileIdHeaders.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for ByBillingProfileId operation. + /// + public partial class GenerateReservationDetailsReportByBillingProfileIdHeaders + { + /// + /// Initializes a new instance of the + /// GenerateReservationDetailsReportByBillingProfileIdHeaders class. + /// + public GenerateReservationDetailsReportByBillingProfileIdHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GenerateReservationDetailsReportByBillingProfileIdHeaders class. + /// + /// The URL to check the status of the + /// asynchronous operation. + /// The amount of delay to use while the + /// status of the operation is checked. The value is expressed in + /// seconds. + public GenerateReservationDetailsReportByBillingProfileIdHeaders(string location = default(string), int? retryAfter = default(int?)) + { + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the URL to check the status of the asynchronous + /// operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets the amount of delay to use while the status of the + /// operation is checked. The value is expressed in seconds. + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Grain.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Grain.cs new file mode 100644 index 0000000000000..220d79570a7b7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Grain.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.CostManagement.Models +{ + + /// + /// Defines values for Grain. + /// + public static class Grain + { + /// + /// Hourly grain corresponds to value per hour. + /// + public const string Hourly = "Hourly"; + /// + /// Hourly grain corresponds to value per day. + /// + public const string Daily = "Daily"; + /// + /// Hourly grain corresponds to value per month. + /// + public const string Monthly = "Monthly"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GrainParameter.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GrainParameter.cs new file mode 100644 index 0000000000000..02774f647f695 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GrainParameter.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.CostManagement.Models +{ + + /// + /// Defines values for GrainParameter. + /// + public static class GrainParameter + { + /// + /// Hourly grain corresponds to value per hour. + /// + public const string Hourly = "Hourly"; + /// + /// Hourly grain corresponds to value per day. + /// + public const string Daily = "Daily"; + /// + /// Hourly grain corresponds to value per month. + /// + public const string Monthly = "Monthly"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GranularityType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GranularityType.cs new file mode 100644 index 0000000000000..bc21e31cffc15 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GranularityType.cs @@ -0,0 +1,21 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for GranularityType. + /// + public static class GranularityType + { + public const string Daily = "Daily"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/IncludedQuantityUtilizationSummary.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/IncludedQuantityUtilizationSummary.cs new file mode 100644 index 0000000000000..a34237e761454 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/IncludedQuantityUtilizationSummary.cs @@ -0,0 +1,123 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Included Quantity utilization summary resource. + /// + [Newtonsoft.Json.JsonObject("IncludedQuantity")] + [Rest.Serialization.JsonTransformation] + public partial class IncludedQuantityUtilizationSummary : BenefitUtilizationSummary + { + /// + /// Initializes a new instance of the + /// IncludedQuantityUtilizationSummary class. + /// + public IncludedQuantityUtilizationSummary() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// IncludedQuantityUtilizationSummary class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// ARM SKU name. For example, Standard_D1_V2 + /// for reservations and ComputeSavingsPlan for savings plan. + /// The benefit ID is the identifier of a + /// benefit within a benefit order. + /// The benefit order ID is the identifier + /// for a benefit purchase. Each benefit order ID represents a single + /// purchase transaction. For example: A reservation order contains + /// reservations. The reservation order specifies the VM size and + /// region for the reservations. + /// The benefit type. For example, + /// reservation or savings plan. Possible values include: + /// 'IncludedQuantity', 'Reservation', 'SavingsPlan' + /// Date corresponding to the utilization + /// record. If the grain of data is monthly, it will be first day of + /// month. + /// This is the utilized percentage + /// for the benefit ID. + public IncludedQuantityUtilizationSummary(string id = default(string), string name = default(string), string type = default(string), string armSkuName = default(string), string benefitId = default(string), string benefitOrderId = default(string), string benefitType = default(string), System.DateTime? usageDate = default(System.DateTime?), decimal? utilizationPercentage = default(decimal?)) + : base(id, name, type) + { + ArmSkuName = armSkuName; + BenefitId = benefitId; + BenefitOrderId = benefitOrderId; + BenefitType = benefitType; + UsageDate = usageDate; + UtilizationPercentage = utilizationPercentage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets ARM SKU name. For example, Standard_D1_V2 for reservations and + /// ComputeSavingsPlan for savings plan. + /// + [JsonProperty(PropertyName = "properties.armSkuName")] + public string ArmSkuName { get; private set; } + + /// + /// Gets the benefit ID is the identifier of a benefit within a benefit + /// order. + /// + [JsonProperty(PropertyName = "properties.benefitId")] + public string BenefitId { get; private set; } + + /// + /// Gets the benefit order ID is the identifier for a benefit purchase. + /// Each benefit order ID represents a single purchase transaction. For + /// example: A reservation order contains reservations. The reservation + /// order specifies the VM size and region for the reservations. + /// + [JsonProperty(PropertyName = "properties.benefitOrderId")] + public string BenefitOrderId { get; private set; } + + /// + /// Gets or sets the benefit type. For example, reservation or savings + /// plan. Possible values include: 'IncludedQuantity', 'Reservation', + /// 'SavingsPlan' + /// + [JsonProperty(PropertyName = "properties.benefitType")] + public string BenefitType { get; set; } + + /// + /// Gets date 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 this is the utilized percentage for the benefit ID. + /// + [JsonProperty(PropertyName = "properties.utilizationPercentage")] + public decimal? UtilizationPercentage { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/KpiProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/KpiProperties.cs new file mode 100644 index 0000000000000..2b73b6d962e26 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/KpiProperties.cs @@ -0,0 +1,69 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Each KPI must contain a 'type' and 'enabled' key. + /// + public partial class KpiProperties + { + /// + /// Initializes a new instance of the KpiProperties class. + /// + public KpiProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the KpiProperties class. + /// + /// KPI type (Forecast, Budget). Possible values + /// include: 'Forecast', 'Budget' + /// ID of resource related to metric (budget). + /// show the KPI in the UI? + public KpiProperties(string type = default(string), string id = default(string), bool? enabled = default(bool?)) + { + Type = type; + Id = id; + Enabled = enabled; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets KPI type (Forecast, Budget). Possible values include: + /// 'Forecast', 'Budget' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets ID of resource related to metric (budget). + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets show the KPI in the UI? + /// + [JsonProperty(PropertyName = "enabled")] + public bool? Enabled { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/KpiTypeType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/KpiTypeType.cs new file mode 100644 index 0000000000000..735baa7d36b30 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/KpiTypeType.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.CostManagement.Models +{ + + /// + /// Defines values for KpiTypeType. + /// + public static class KpiTypeType + { + public const string Forecast = "Forecast"; + public const string Budget = "Budget"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/LookBackPeriod.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/LookBackPeriod.cs new file mode 100644 index 0000000000000..46690dc282871 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/LookBackPeriod.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.CostManagement.Models +{ + + /// + /// Defines values for LookBackPeriod. + /// + public static class LookBackPeriod + { + /// + /// 7 days used to look back. + /// + public const string Last7Days = "Last7Days"; + /// + /// 30 days used to look back. + /// + public const string Last30Days = "Last30Days"; + /// + /// 60 days used to look back. + /// + public const string Last60Days = "Last60Days"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/MetricType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/MetricType.cs new file mode 100644 index 0000000000000..746d4df6e4d8b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/MetricType.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.CostManagement.Models +{ + + /// + /// Defines values for MetricType. + /// + public static class MetricType + { + public const string ActualCost = "ActualCost"; + public const string AmortizedCost = "AmortizedCost"; + public const string AHUB = "AHUB"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/NotificationProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/NotificationProperties.cs new file mode 100644 index 0000000000000..4011fff17e1b0 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/NotificationProperties.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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The properties of the scheduled action notification. + /// + public partial class NotificationProperties + { + /// + /// Initializes a new instance of the NotificationProperties class. + /// + public NotificationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NotificationProperties class. + /// + /// Array of email addresses. + /// Subject of the email. Length is limited to 70 + /// characters. + /// Locale of the email. + /// Optional message to be added in the email. + /// Length is limited to 250 characters. + /// Regional format used for formatting + /// date/time and currency values in the email. + public NotificationProperties(IList to, string subject, string language = default(string), string message = default(string), string regionalFormat = default(string)) + { + To = to; + Language = language; + Message = message; + RegionalFormat = regionalFormat; + Subject = subject; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets array of email addresses. + /// + [JsonProperty(PropertyName = "to")] + public IList To { get; set; } + + /// + /// Gets or sets locale of the email. + /// + [JsonProperty(PropertyName = "language")] + public string Language { get; set; } + + /// + /// Gets or sets optional message to be added in the email. Length is + /// limited to 250 characters. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets regional format used for formatting date/time and + /// currency values in the email. + /// + [JsonProperty(PropertyName = "regionalFormat")] + public string RegionalFormat { get; set; } + + /// + /// Gets or sets subject of the email. Length is limited to 70 + /// characters. + /// + [JsonProperty(PropertyName = "subject")] + public string Subject { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (To == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "To"); + } + if (Subject == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Subject"); + } + if (To != null) + { + if (To.Count > 20) + { + throw new ValidationException(ValidationRules.MaxItems, "To", 20); + } + if (To.Count < 1) + { + throw new ValidationException(ValidationRules.MinItems, "To", 1); + } + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Operation.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Operation.cs new file mode 100644 index 0000000000000..490d3d30eceb6 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Operation.cs @@ -0,0 +1,109 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// REST API Operation + /// + /// + /// Details of a REST API operation, returned from the Resource Provider + /// Operations API + /// + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + /// The name of the operation, as per Resource-Based + /// Access Control (RBAC). Examples: + /// "Microsoft.Compute/virtualMachines/write", + /// "Microsoft.Compute/virtualMachines/capture/action" + /// Whether the operation applies to + /// data-plane. This is "true" for data-plane operations and "false" + /// for ARM/control-plane operations. + /// Localized display information for this + /// particular operation. + /// The intended executor of the operation; as in + /// Resource Based Access Control (RBAC) and audit logs UX. Default + /// value is "user,system". Possible values include: 'user', 'system', + /// 'user,system' + /// Enum. Indicates the action type. + /// "Internal" refers to actions that are for internal only APIs. + /// Possible values include: 'Internal' + public Operation(string name = default(string), bool? isDataAction = default(bool?), OperationDisplay display = default(OperationDisplay), string origin = default(string), string actionType = default(string)) + { + Name = name; + IsDataAction = isDataAction; + Display = display; + Origin = origin; + ActionType = actionType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of the operation, as per Resource-Based Access + /// Control (RBAC). Examples: + /// "Microsoft.Compute/virtualMachines/write", + /// "Microsoft.Compute/virtualMachines/capture/action" + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets whether the operation applies to data-plane. This is "true" + /// for data-plane operations and "false" for ARM/control-plane + /// operations. + /// + [JsonProperty(PropertyName = "isDataAction")] + public bool? IsDataAction { get; private set; } + + /// + /// Gets or sets localized display information for this particular + /// operation. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; set; } + + /// + /// Gets the intended executor of the operation; as in Resource Based + /// Access Control (RBAC) and audit logs UX. Default value is + /// "user,system". Possible values include: 'user', 'system', + /// 'user,system' + /// + [JsonProperty(PropertyName = "origin")] + public string Origin { get; private set; } + + /// + /// Gets enum. Indicates the action type. "Internal" refers to actions + /// that are for internal only APIs. Possible values include: + /// 'Internal' + /// + [JsonProperty(PropertyName = "actionType")] + public string ActionType { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationDisplay.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 0000000000000..a71f4adb607ef --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationDisplay.cs @@ -0,0 +1,89 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Localized display information for this particular operation. + /// + public partial class OperationDisplay + { + /// + /// Initializes a new instance of the OperationDisplay class. + /// + public OperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplay class. + /// + /// The localized friendly form of the resource + /// provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + /// Compute". + /// The localized friendly name of the resource + /// type related to this operation. E.g. "Virtual Machines" or "Job + /// Schedule Collections". + /// The concise, localized friendly name for + /// the operation; suitable for dropdowns. E.g. "Create or Update + /// Virtual Machine", "Restart Virtual Machine". + /// The short, localized friendly description + /// of the operation; suitable for tool tips and detailed + /// views. + public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string)) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the localized friendly form of the resource provider name, + /// e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; private set; } + + /// + /// Gets the localized friendly name of the resource type related to + /// this operation. E.g. "Virtual Machines" or "Job Schedule + /// Collections". + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; private set; } + + /// + /// Gets the concise, localized friendly name for the operation; + /// suitable for dropdowns. E.g. "Create or Update Virtual Machine", + /// "Restart Virtual Machine". + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; private set; } + + /// + /// Gets the short, localized friendly description of the operation; + /// suitable for tool tips and detailed views. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationStatus.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationStatus.cs new file mode 100644 index 0000000000000..d04d5d0d4e758 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationStatus.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The status of the long running operation. + /// + [Rest.Serialization.JsonTransformation] + public partial class OperationStatus + { + /// + /// Initializes a new instance of the OperationStatus class. + /// + public OperationStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationStatus class. + /// + /// The status of the long running operation. + /// Possible values include: 'Running', 'Completed', 'Failed' + /// The CSV file from the reportUrl blob link + /// consists of reservation usage data with the following schema at + /// daily granularity. Possible values include: + /// 'InstanceFlexibilityGroup', 'InstanceFlexibilityRatio', + /// 'InstanceId', 'Kind', 'ReservationId', 'ReservationOrderId', + /// 'ReservedHours', 'SkuName', 'TotalReservedQuantity', 'UsageDate', + /// 'UsedHours' + /// The time at which report URL becomes + /// invalid. + public OperationStatus(string status = default(string), string reportUrl = default(string), System.DateTime? validUntil = default(System.DateTime?)) + { + Status = status; + ReportUrl = reportUrl; + ValidUntil = validUntil; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the status of the long running operation. Possible + /// values include: 'Running', 'Completed', 'Failed' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the CSV file from the reportUrl blob link consists of + /// reservation usage data with the following schema at daily + /// granularity. Possible values include: 'InstanceFlexibilityGroup', + /// 'InstanceFlexibilityRatio', 'InstanceId', 'Kind', 'ReservationId', + /// 'ReservationOrderId', 'ReservedHours', 'SkuName', + /// 'TotalReservedQuantity', 'UsageDate', 'UsedHours' + /// + [JsonProperty(PropertyName = "properties.reportUrl")] + public string ReportUrl { get; set; } + + /// + /// Gets or sets the time at which report URL becomes invalid. + /// + [JsonProperty(PropertyName = "properties.validUntil")] + public System.DateTime? ValidUntil { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationStatusType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationStatusType.cs new file mode 100644 index 0000000000000..d7151c8677ec1 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationStatusType.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.CostManagement.Models +{ + + /// + /// Defines values for OperationStatusType. + /// + public static class OperationStatusType + { + public const string Running = "Running"; + public const string Completed = "Completed"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperatorType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperatorType.cs new file mode 100644 index 0000000000000..04835817077f3 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperatorType.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.CostManagement.Models +{ + + /// + /// Defines values for OperatorType. + /// + public static class OperatorType + { + public const string In = "In"; + public const string Contains = "Contains"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Origin.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Origin.cs new file mode 100644 index 0000000000000..dbcbb2e7a6789 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Origin.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.CostManagement.Models +{ + + /// + /// Defines values for Origin. + /// + public static class Origin + { + public const string User = "user"; + public const string System = "system"; + public const string Usersystem = "user,system"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Page.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Page.cs new file mode 100644 index 0000000000000..a431dbedbb4d7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Page.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.CostManagement.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 Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Page1.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Page1.cs new file mode 100644 index 0000000000000..eac7c7f6b920a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/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.CostManagement.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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PivotProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PivotProperties.cs new file mode 100644 index 0000000000000..7761b4a3ea879 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PivotProperties.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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Each pivot must contain a 'type' and 'name'. + /// + public partial class PivotProperties + { + /// + /// Initializes a new instance of the PivotProperties class. + /// + public PivotProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PivotProperties class. + /// + /// Data type to show in view. Possible values + /// include: 'Dimension', 'TagKey' + /// Data field to show in view. + public PivotProperties(string type = default(string), string name = default(string)) + { + Type = type; + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets data type to show in view. Possible values include: + /// 'Dimension', 'TagKey' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets data field to show in view. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PivotTypeType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PivotTypeType.cs new file mode 100644 index 0000000000000..01ce2abd7bb73 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PivotTypeType.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.CostManagement.Models +{ + + /// + /// Defines values for PivotTypeType. + /// + public static class PivotTypeType + { + public const string Dimension = "Dimension"; + public const string TagKey = "TagKey"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PriceSheetDownloadByBillingProfileHeaders.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PriceSheetDownloadByBillingProfileHeaders.cs new file mode 100644 index 0000000000000..1102547f41a2f --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PriceSheetDownloadByBillingProfileHeaders.cs @@ -0,0 +1,74 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for DownloadByBillingProfile operation. + /// + public partial class PriceSheetDownloadByBillingProfileHeaders + { + /// + /// Initializes a new instance of the + /// PriceSheetDownloadByBillingProfileHeaders class. + /// + public PriceSheetDownloadByBillingProfileHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PriceSheetDownloadByBillingProfileHeaders 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. + /// The operation entity Id GUID. + public PriceSheetDownloadByBillingProfileHeaders(string location = default(string), string retryAfter = default(string), string oDataEntityId = default(string)) + { + Location = location; + RetryAfter = retryAfter; + 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 the operation entity Id GUID. + /// + [JsonProperty(PropertyName = "OData-EntityId")] + public string ODataEntityId { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PriceSheetDownloadHeaders.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PriceSheetDownloadHeaders.cs new file mode 100644 index 0000000000000..d6a939a3888f5 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PriceSheetDownloadHeaders.cs @@ -0,0 +1,72 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Download operation. + /// + public partial class PriceSheetDownloadHeaders + { + /// + /// Initializes a new instance of the PriceSheetDownloadHeaders class. + /// + public PriceSheetDownloadHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PriceSheetDownloadHeaders 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. + /// The operation entity Id GUID. + public PriceSheetDownloadHeaders(string location = default(string), string retryAfter = default(string), string oDataEntityId = default(string)) + { + Location = location; + RetryAfter = retryAfter; + 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 the operation entity Id GUID. + /// + [JsonProperty(PropertyName = "OData-EntityId")] + public string ODataEntityId { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ProxyResource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ProxyResource.cs new file mode 100644 index 0000000000000..abacfa33ce025 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ProxyResource.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.CostManagement.Models +{ + using System.Linq; + + /// + /// Proxy Resource + /// + /// + /// The resource model definition for a Azure Resource Manager proxy + /// resource. It will not have tags and a location + /// + public partial class ProxyResource : Resource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public ProxyResource(string id = default(string), string name = default(string), string type = default(string)) + : base(id, name, type) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryAggregation.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryAggregation.cs new file mode 100644 index 0000000000000..7c41b88bfd8e3 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryAggregation.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The aggregation expression to be used in the query. + /// + public partial class QueryAggregation + { + /// + /// Initializes a new instance of the QueryAggregation class. + /// + public QueryAggregation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryAggregation class. + /// + /// The name of the column to aggregate. + public QueryAggregation(string name) + { + Name = name; + CustomInit(); + } + /// + /// Static constructor for QueryAggregation class. + /// + static QueryAggregation() + { + Function = "Sum"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the column to aggregate. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// The name of the aggregation function to use. + /// + [JsonProperty(PropertyName = "function")] + public static string Function { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryColumn.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryColumn.cs new file mode 100644 index 0000000000000..8664819df350a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryColumn.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// QueryColumn properties + /// + public partial class QueryColumn + { + /// + /// Initializes a new instance of the QueryColumn class. + /// + public QueryColumn() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryColumn class. + /// + /// The name of column. + /// The type of column. + public QueryColumn(string name = default(string), string type = default(string)) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of column. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the type of column. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryColumnType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryColumnType.cs new file mode 100644 index 0000000000000..f67eba223d072 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryColumnType.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.CostManagement.Models +{ + + /// + /// Defines values for QueryColumnType. + /// + public static class QueryColumnType + { + public const string Tag = "Tag"; + public const string Dimension = "Dimension"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryComparisonExpression.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryComparisonExpression.cs new file mode 100644 index 0000000000000..8fbdf7f66b4d8 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryComparisonExpression.cs @@ -0,0 +1,100 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The comparison expression to be used in the query. + /// + public partial class QueryComparisonExpression + { + /// + /// Initializes a new instance of the QueryComparisonExpression class. + /// + public QueryComparisonExpression() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryComparisonExpression class. + /// + /// The name of the column to use in + /// comparison. + /// Array of values to use for comparison + public QueryComparisonExpression(string name, IList values) + { + Name = name; + Values = values; + CustomInit(); + } + /// + /// Static constructor for QueryComparisonExpression class. + /// + static QueryComparisonExpression() + { + OperatorProperty = "In"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the column to use in comparison. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets array of values to use for comparison + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + /// + /// The operator to use for comparison. + /// + [JsonProperty(PropertyName = "operator")] + public static string OperatorProperty { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Values == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Values"); + } + if (Values != null) + { + if (Values.Count < 1) + { + throw new ValidationException(ValidationRules.MinItems, "Values", 1); + } + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDataset.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDataset.cs new file mode 100644 index 0000000000000..c14a461248245 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDataset.cs @@ -0,0 +1,140 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The definition of data present in the query. + /// + public partial class QueryDataset + { + /// + /// Initializes a new instance of the QueryDataset class. + /// + public QueryDataset() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryDataset class. + /// + /// The granularity of rows in the query. + /// Possible values include: 'Daily' + /// Has configuration information for the + /// data in the export. The configuration will be ignored if + /// aggregation and grouping are provided. + /// Dictionary of aggregation expression to + /// use in the query. The key of each item in the dictionary is the + /// alias for the aggregated column. Query can have up to 2 aggregation + /// clauses. + /// Array of group by expression to use in the + /// query. Query can have up to 2 group by clauses. + /// The filter expression to use in the query. + /// Please reference our Query API REST documentation for how to + /// properly format the filter. + public QueryDataset(string granularity = default(string), QueryDatasetConfiguration configuration = default(QueryDatasetConfiguration), IDictionary aggregation = default(IDictionary), IList grouping = default(IList), QueryFilter filter = default(QueryFilter)) + { + Granularity = granularity; + Configuration = configuration; + Aggregation = aggregation; + Grouping = grouping; + Filter = filter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the granularity of rows in the query. Possible values + /// include: 'Daily' + /// + [JsonProperty(PropertyName = "granularity")] + public string Granularity { get; set; } + + /// + /// Gets or sets has configuration information for the data in the + /// export. The configuration will be ignored if aggregation and + /// grouping are provided. + /// + [JsonProperty(PropertyName = "configuration")] + public QueryDatasetConfiguration Configuration { get; set; } + + /// + /// Gets or sets dictionary of aggregation expression to use in the + /// query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + [JsonProperty(PropertyName = "aggregation")] + public IDictionary Aggregation { get; set; } + + /// + /// Gets or sets array of group by expression to use in the query. + /// Query can have up to 2 group by clauses. + /// + [JsonProperty(PropertyName = "grouping")] + public IList Grouping { get; set; } + + /// + /// Gets or sets the filter expression to use in the query. Please + /// reference our Query API REST documentation for how to properly + /// format the filter. + /// + [JsonProperty(PropertyName = "filter")] + public QueryFilter Filter { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Aggregation != null) + { + foreach (var valueElement in Aggregation.Values) + { + if (valueElement != null) + { + valueElement.Validate(); + } + } + } + if (Grouping != null) + { + if (Grouping.Count > 2) + { + throw new ValidationException(ValidationRules.MaxItems, "Grouping", 2); + } + foreach (var element in Grouping) + { + if (element != null) + { + element.Validate(); + } + } + } + if (Filter != null) + { + Filter.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDatasetConfiguration.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDatasetConfiguration.cs new file mode 100644 index 0000000000000..b1634e7060690 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDatasetConfiguration.cs @@ -0,0 +1,57 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The configuration of dataset in the query. + /// + public partial class QueryDatasetConfiguration + { + /// + /// Initializes a new instance of the QueryDatasetConfiguration class. + /// + public QueryDatasetConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryDatasetConfiguration class. + /// + /// Array of column names to be included in the + /// query. Any valid query column name is allowed. If not provided, + /// then query includes all columns. + public QueryDatasetConfiguration(IList columns = default(IList)) + { + Columns = columns; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets array of column names to be included in the query. Any + /// valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [JsonProperty(PropertyName = "columns")] + public IList Columns { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDefinition.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDefinition.cs new file mode 100644 index 0000000000000..5522f5a02a305 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDefinition.cs @@ -0,0 +1,117 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The definition of a query. + /// + public partial class QueryDefinition + { + /// + /// Initializes a new instance of the QueryDefinition class. + /// + public QueryDefinition() + { + Dataset = new QueryDataset(); + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryDefinition class. + /// + /// The type of the query. Possible values include: + /// 'Usage', 'ActualCost', 'AmortizedCost' + /// The time frame for pulling data for the + /// query. If custom, then a specific time period must be provided. + /// Possible values include: 'MonthToDate', 'BillingMonthToDate', + /// 'TheLastMonth', 'TheLastBillingMonth', 'WeekToDate', + /// 'Custom' + /// Has definition for data in this + /// query. + /// Has time period for pulling data for the + /// query. + public QueryDefinition(string type, string timeframe, QueryDataset dataset, QueryTimePeriod timePeriod = default(QueryTimePeriod)) + { + Type = type; + Timeframe = timeframe; + TimePeriod = timePeriod; + Dataset = dataset; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the query. Possible values include: + /// 'Usage', 'ActualCost', 'AmortizedCost' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the time frame for pulling data for the query. If + /// custom, then a specific time period must be provided. Possible + /// values include: 'MonthToDate', 'BillingMonthToDate', + /// 'TheLastMonth', 'TheLastBillingMonth', 'WeekToDate', 'Custom' + /// + [JsonProperty(PropertyName = "timeframe")] + public string Timeframe { get; set; } + + /// + /// Gets or sets has time period for pulling data for the query. + /// + [JsonProperty(PropertyName = "timePeriod")] + public QueryTimePeriod TimePeriod { get; set; } + + /// + /// Gets or sets has definition for data in this query. + /// + [JsonProperty(PropertyName = "dataset")] + public QueryDataset Dataset { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + if (Timeframe == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Timeframe"); + } + if (Dataset == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Dataset"); + } + if (TimePeriod != null) + { + TimePeriod.Validate(); + } + if (Dataset != null) + { + Dataset.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryFilter.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryFilter.cs new file mode 100644 index 0000000000000..a38b5a451e02a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryFilter.cs @@ -0,0 +1,128 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The filter expression to be used in the export. + /// + public partial class QueryFilter + { + /// + /// Initializes a new instance of the QueryFilter class. + /// + public QueryFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryFilter class. + /// + /// The logical "AND" expression. Must have at least + /// 2 items. + /// The logical "OR" expression. Must have at least 2 + /// items. + /// Has comparison expression for a + /// dimension + /// Has comparison expression for a tag + public QueryFilter(IList and = default(IList), IList or = default(IList), QueryComparisonExpression dimensions = default(QueryComparisonExpression), QueryComparisonExpression tags = default(QueryComparisonExpression)) + { + And = and; + Or = or; + Dimensions = dimensions; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the logical "AND" expression. Must have at least 2 + /// items. + /// + [JsonProperty(PropertyName = "and")] + public IList And { get; set; } + + /// + /// Gets or sets the logical "OR" expression. Must have at least 2 + /// items. + /// + [JsonProperty(PropertyName = "or")] + public IList Or { get; set; } + + /// + /// Gets or sets has comparison expression for a dimension + /// + [JsonProperty(PropertyName = "dimensions")] + public QueryComparisonExpression Dimensions { get; set; } + + /// + /// Gets or sets has comparison expression for a tag + /// + [JsonProperty(PropertyName = "tags")] + public QueryComparisonExpression Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (And != null) + { + if (And.Count < 2) + { + throw new ValidationException(ValidationRules.MinItems, "And", 2); + } + foreach (var element in And) + { + if (element != null) + { + element.Validate(); + } + } + } + if (Or != null) + { + if (Or.Count < 2) + { + throw new ValidationException(ValidationRules.MinItems, "Or", 2); + } + foreach (var element1 in Or) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (Dimensions != null) + { + Dimensions.Validate(); + } + if (Tags != null) + { + Tags.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryGrouping.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryGrouping.cs new file mode 100644 index 0000000000000..0f86a7c7dfee7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryGrouping.cs @@ -0,0 +1,79 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The group by expression to be used in the query. + /// + public partial class QueryGrouping + { + /// + /// Initializes a new instance of the QueryGrouping class. + /// + public QueryGrouping() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryGrouping class. + /// + /// Has type of the column to group. Possible values + /// include: 'Tag', 'Dimension' + /// The name of the column to group. + public QueryGrouping(string type, string name) + { + Type = type; + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets has type of the column to group. Possible values + /// include: 'Tag', 'Dimension' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the name of the column to group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryResult.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryResult.cs new file mode 100644 index 0000000000000..fb84b36111931 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryResult.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of query. It contains all columns listed under groupings and + /// aggregation. + /// + [Rest.Serialization.JsonTransformation] + public partial class QueryResult : CostManagementResource + { + /// + /// Initializes a new instance of the QueryResult class. + /// + public QueryResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryResult class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Location of the resource. + /// SKU of the resource. + /// ETag of the resource. + /// Resource tags. + /// The link (url) to the next page of + /// results. + /// Array of columns + /// Array of rows + public QueryResult(string id = default(string), string name = default(string), string type = default(string), string location = default(string), string sku = default(string), string eTag = default(string), IDictionary tags = default(IDictionary), string nextLink = default(string), IList columns = default(IList), IList> rows = default(IList>)) + : base(id, name, type, location, sku, eTag, tags) + { + NextLink = nextLink; + Columns = columns; + Rows = rows; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the link (url) to the next page of results. + /// + [JsonProperty(PropertyName = "properties.nextLink")] + public string NextLink { get; set; } + + /// + /// Gets or sets array of columns + /// + [JsonProperty(PropertyName = "properties.columns")] + public IList Columns { get; set; } + + /// + /// Gets or sets array of rows + /// + [JsonProperty(PropertyName = "properties.rows")] + public IList> Rows { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryTimePeriod.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryTimePeriod.cs new file mode 100644 index 0000000000000..ca613b375c0dc --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryTimePeriod.cs @@ -0,0 +1,70 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The start and end date for pulling data for the query. + /// + public partial class QueryTimePeriod + { + /// + /// Initializes a new instance of the QueryTimePeriod class. + /// + public QueryTimePeriod() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryTimePeriod class. + /// + /// The start date to pull data + /// from. + /// The end date to pull data to. + public QueryTimePeriod(System.DateTime fromProperty, System.DateTime to) + { + FromProperty = fromProperty; + To = to; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start date to pull data from. + /// + [JsonProperty(PropertyName = "from")] + public System.DateTime FromProperty { get; set; } + + /// + /// Gets or sets the end date to pull data to. + /// + [JsonProperty(PropertyName = "to")] + public System.DateTime To { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/RecommendationUsageDetails.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/RecommendationUsageDetails.cs new file mode 100644 index 0000000000000..673718934480c --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/RecommendationUsageDetails.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The additional details about the usage which are considered while + /// computing benefit recommendations. + /// + public partial class RecommendationUsageDetails + { + /// + /// Initializes a new instance of the RecommendationUsageDetails class. + /// + public RecommendationUsageDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RecommendationUsageDetails class. + /// + /// The grain of the usage. For example, + /// hourly or monthly etc. Possible values include: 'Hourly', 'Daily', + /// 'Monthly' + /// current cost without benefit i.e. charges at + /// the specified grain. + public RecommendationUsageDetails(string usageGrain = default(string), IList charges = default(IList)) + { + UsageGrain = usageGrain; + Charges = charges; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the grain of the usage. For example, hourly or monthly + /// etc. Possible values include: 'Hourly', 'Daily', 'Monthly' + /// + [JsonProperty(PropertyName = "usageGrain")] + public string UsageGrain { get; set; } + + /// + /// Gets current cost without benefit i.e. charges at the specified + /// grain. + /// + [JsonProperty(PropertyName = "charges")] + public IList Charges { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/RecurrenceType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/RecurrenceType.cs new file mode 100644 index 0000000000000..05d4ee88a98d8 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/RecurrenceType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + + /// + /// Defines values for RecurrenceType. + /// + public static class RecurrenceType + { + public const string Daily = "Daily"; + public const string Weekly = "Weekly"; + public const string Monthly = "Monthly"; + public const string Annually = "Annually"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigAggregation.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigAggregation.cs new file mode 100644 index 0000000000000..0f65a66d0699e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigAggregation.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The aggregation expression to be used in the report. + /// + public partial class ReportConfigAggregation + { + /// + /// Initializes a new instance of the ReportConfigAggregation class. + /// + public ReportConfigAggregation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReportConfigAggregation class. + /// + /// The name of the column to aggregate. + public ReportConfigAggregation(string name) + { + Name = name; + CustomInit(); + } + /// + /// Static constructor for ReportConfigAggregation class. + /// + static ReportConfigAggregation() + { + Function = "Sum"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the column to aggregate. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// The name of the aggregation function to use. + /// + [JsonProperty(PropertyName = "function")] + public static string Function { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigColumnType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigColumnType.cs new file mode 100644 index 0000000000000..1f891b17234d1 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigColumnType.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.CostManagement.Models +{ + + /// + /// Defines values for ReportConfigColumnType. + /// + public static class ReportConfigColumnType + { + public const string Tag = "Tag"; + public const string Dimension = "Dimension"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigComparisonExpression.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigComparisonExpression.cs new file mode 100644 index 0000000000000..61dc4e845a91c --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigComparisonExpression.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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The comparison expression to be used in the report. + /// + public partial class ReportConfigComparisonExpression + { + /// + /// Initializes a new instance of the ReportConfigComparisonExpression + /// class. + /// + public ReportConfigComparisonExpression() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReportConfigComparisonExpression + /// class. + /// + /// The name of the column to use in + /// comparison. + /// The operator to use for comparison. + /// Possible values include: 'In', 'Contains' + /// Array of values to use for comparison + public ReportConfigComparisonExpression(string name, string operatorProperty, IList values) + { + Name = name; + OperatorProperty = operatorProperty; + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the column to use in comparison. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the operator to use for comparison. Possible values + /// include: 'In', 'Contains' + /// + [JsonProperty(PropertyName = "operator")] + public string OperatorProperty { get; set; } + + /// + /// Gets or sets array of values to use for comparison + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (OperatorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); + } + if (Values == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Values"); + } + if (Values != null) + { + if (Values.Count < 1) + { + throw new ValidationException(ValidationRules.MinItems, "Values", 1); + } + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigDataset.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigDataset.cs new file mode 100644 index 0000000000000..605ea38bf6271 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigDataset.cs @@ -0,0 +1,156 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The definition of data present in the report. + /// + public partial class ReportConfigDataset + { + /// + /// Initializes a new instance of the ReportConfigDataset class. + /// + public ReportConfigDataset() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReportConfigDataset class. + /// + /// The granularity of rows in the report. + /// Possible values include: 'Daily', 'Monthly' + /// Has configuration information for the + /// data in the report. The configuration will be ignored if + /// aggregation and grouping are provided. + /// Dictionary of aggregation expression to + /// use in the report. The key of each item in the dictionary is the + /// alias for the aggregated column. Report can have up to 2 + /// aggregation clauses. + /// Array of group by expression to use in the + /// report. Report can have up to 2 group by clauses. + /// Array of order by expression to use in the + /// report. + /// Has filter expression to use in the + /// report. + public ReportConfigDataset(string granularity = default(string), ReportConfigDatasetConfiguration configuration = default(ReportConfigDatasetConfiguration), IDictionary aggregation = default(IDictionary), IList grouping = default(IList), IList sorting = default(IList), ReportConfigFilter filter = default(ReportConfigFilter)) + { + Granularity = granularity; + Configuration = configuration; + Aggregation = aggregation; + Grouping = grouping; + Sorting = sorting; + Filter = filter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the granularity of rows in the report. Possible values + /// include: 'Daily', 'Monthly' + /// + [JsonProperty(PropertyName = "granularity")] + public string Granularity { get; set; } + + /// + /// Gets or sets has configuration information for the data in the + /// report. The configuration will be ignored if aggregation and + /// grouping are provided. + /// + [JsonProperty(PropertyName = "configuration")] + public ReportConfigDatasetConfiguration Configuration { get; set; } + + /// + /// Gets or sets dictionary of aggregation expression to use in the + /// report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [JsonProperty(PropertyName = "aggregation")] + public IDictionary Aggregation { get; set; } + + /// + /// Gets or sets array of group by expression to use in the report. + /// Report can have up to 2 group by clauses. + /// + [JsonProperty(PropertyName = "grouping")] + public IList Grouping { get; set; } + + /// + /// Gets or sets array of order by expression to use in the report. + /// + [JsonProperty(PropertyName = "sorting")] + public IList Sorting { get; set; } + + /// + /// Gets or sets has filter expression to use in the report. + /// + [JsonProperty(PropertyName = "filter")] + public ReportConfigFilter Filter { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Aggregation != null) + { + foreach (var valueElement in Aggregation.Values) + { + if (valueElement != null) + { + valueElement.Validate(); + } + } + } + if (Grouping != null) + { + if (Grouping.Count > 2) + { + throw new ValidationException(ValidationRules.MaxItems, "Grouping", 2); + } + foreach (var element in Grouping) + { + if (element != null) + { + element.Validate(); + } + } + } + if (Sorting != null) + { + foreach (var element1 in Sorting) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (Filter != null) + { + Filter.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigDatasetConfiguration.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigDatasetConfiguration.cs new file mode 100644 index 0000000000000..eeb8dc20dc98d --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigDatasetConfiguration.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The configuration of dataset in the report. + /// + public partial class ReportConfigDatasetConfiguration + { + /// + /// Initializes a new instance of the ReportConfigDatasetConfiguration + /// class. + /// + public ReportConfigDatasetConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReportConfigDatasetConfiguration + /// class. + /// + /// Array of column names to be included in the + /// report. Any valid report column name is allowed. If not provided, + /// then report includes all columns. + public ReportConfigDatasetConfiguration(IList columns = default(IList)) + { + Columns = columns; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets array of column names to be included in the report. + /// Any valid report column name is allowed. If not provided, then + /// report includes all columns. + /// + [JsonProperty(PropertyName = "columns")] + public IList Columns { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigFilter.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigFilter.cs new file mode 100644 index 0000000000000..1def47fce4b36 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigFilter.cs @@ -0,0 +1,128 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The filter expression to be used in the report. + /// + public partial class ReportConfigFilter + { + /// + /// Initializes a new instance of the ReportConfigFilter class. + /// + public ReportConfigFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReportConfigFilter class. + /// + /// The logical "AND" expression. Must have at least + /// 2 items. + /// The logical "OR" expression. Must have at least 2 + /// items. + /// Has comparison expression for a + /// dimension + /// Has comparison expression for a tag + public ReportConfigFilter(IList and = default(IList), IList or = default(IList), ReportConfigComparisonExpression dimensions = default(ReportConfigComparisonExpression), ReportConfigComparisonExpression tags = default(ReportConfigComparisonExpression)) + { + And = and; + Or = or; + Dimensions = dimensions; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the logical "AND" expression. Must have at least 2 + /// items. + /// + [JsonProperty(PropertyName = "and")] + public IList And { get; set; } + + /// + /// Gets or sets the logical "OR" expression. Must have at least 2 + /// items. + /// + [JsonProperty(PropertyName = "or")] + public IList Or { get; set; } + + /// + /// Gets or sets has comparison expression for a dimension + /// + [JsonProperty(PropertyName = "dimensions")] + public ReportConfigComparisonExpression Dimensions { get; set; } + + /// + /// Gets or sets has comparison expression for a tag + /// + [JsonProperty(PropertyName = "tags")] + public ReportConfigComparisonExpression Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (And != null) + { + if (And.Count < 2) + { + throw new ValidationException(ValidationRules.MinItems, "And", 2); + } + foreach (var element in And) + { + if (element != null) + { + element.Validate(); + } + } + } + if (Or != null) + { + if (Or.Count < 2) + { + throw new ValidationException(ValidationRules.MinItems, "Or", 2); + } + foreach (var element1 in Or) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (Dimensions != null) + { + Dimensions.Validate(); + } + if (Tags != null) + { + Tags.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigGrouping.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigGrouping.cs new file mode 100644 index 0000000000000..ce12933eb064c --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigGrouping.cs @@ -0,0 +1,81 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The group by expression to be used in the report. + /// + public partial class ReportConfigGrouping + { + /// + /// Initializes a new instance of the ReportConfigGrouping class. + /// + public ReportConfigGrouping() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReportConfigGrouping class. + /// + /// Has type of the column to group. Possible values + /// include: 'Tag', 'Dimension' + /// The name of the column to group. This version + /// supports subscription lowest possible grain. + public ReportConfigGrouping(string type, string name) + { + Type = type; + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets has type of the column to group. Possible values + /// include: 'Tag', 'Dimension' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the name of the column to group. This version supports + /// subscription lowest possible grain. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigSorting.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigSorting.cs new file mode 100644 index 0000000000000..ae83953a20e47 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigSorting.cs @@ -0,0 +1,75 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The order by expression to be used in the report. + /// + public partial class ReportConfigSorting + { + /// + /// Initializes a new instance of the ReportConfigSorting class. + /// + public ReportConfigSorting() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReportConfigSorting class. + /// + /// The name of the column to sort. + /// Direction of sort. Possible values include: + /// 'Ascending', 'Descending' + public ReportConfigSorting(string name, string direction = default(string)) + { + Direction = direction; + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets direction of sort. Possible values include: + /// 'Ascending', 'Descending' + /// + [JsonProperty(PropertyName = "direction")] + public string Direction { get; set; } + + /// + /// Gets or sets the name of the column to sort. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigSortingType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigSortingType.cs new file mode 100644 index 0000000000000..500cedeb1d38a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigSortingType.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.CostManagement.Models +{ + + /// + /// Defines values for ReportConfigSortingType. + /// + public static class ReportConfigSortingType + { + public const string Ascending = "Ascending"; + public const string Descending = "Descending"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigTimePeriod.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigTimePeriod.cs new file mode 100644 index 0000000000000..2c4dabb854579 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigTimePeriod.cs @@ -0,0 +1,70 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The start and end date for pulling data for the report. + /// + public partial class ReportConfigTimePeriod + { + /// + /// Initializes a new instance of the ReportConfigTimePeriod class. + /// + public ReportConfigTimePeriod() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReportConfigTimePeriod class. + /// + /// The start date to pull data + /// from. + /// The end date to pull data to. + public ReportConfigTimePeriod(System.DateTime fromProperty, System.DateTime to) + { + FromProperty = fromProperty; + To = to; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start date to pull data from. + /// + [JsonProperty(PropertyName = "from")] + public System.DateTime FromProperty { get; set; } + + /// + /// Gets or sets the end date to pull data to. + /// + [JsonProperty(PropertyName = "to")] + public System.DateTime To { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportGranularityType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportGranularityType.cs new file mode 100644 index 0000000000000..cdd895d28b91f --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportGranularityType.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.CostManagement.Models +{ + + /// + /// Defines values for ReportGranularityType. + /// + public static class ReportGranularityType + { + public const string Daily = "Daily"; + public const string Monthly = "Monthly"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportOperationStatusType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportOperationStatusType.cs new file mode 100644 index 0000000000000..01d6e28d3ab47 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportOperationStatusType.cs @@ -0,0 +1,27 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for ReportOperationStatusType. + /// + public static class ReportOperationStatusType + { + public const string InProgress = "InProgress"; + public const string Completed = "Completed"; + public const string Failed = "Failed"; + public const string Queued = "Queued"; + public const string NoDataFound = "NoDataFound"; + public const string ReadyToDownload = "ReadyToDownload"; + public const string TimedOut = "TimedOut"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportTimeframeType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportTimeframeType.cs new file mode 100644 index 0000000000000..a46b7ecf8d17a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportTimeframeType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + + /// + /// Defines values for ReportTimeframeType. + /// + public static class ReportTimeframeType + { + public const string WeekToDate = "WeekToDate"; + public const string MonthToDate = "MonthToDate"; + public const string YearToDate = "YearToDate"; + public const string Custom = "Custom"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReservationReportSchema.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReservationReportSchema.cs new file mode 100644 index 0000000000000..9653feba2b22b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReservationReportSchema.cs @@ -0,0 +1,31 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for ReservationReportSchema. + /// + public static class ReservationReportSchema + { + public const string InstanceFlexibilityGroup = "InstanceFlexibilityGroup"; + public const string InstanceFlexibilityRatio = "InstanceFlexibilityRatio"; + public const string InstanceId = "InstanceId"; + public const string Kind = "Kind"; + public const string ReservationId = "ReservationId"; + public const string ReservationOrderId = "ReservationOrderId"; + public const string ReservedHours = "ReservedHours"; + public const string SkuName = "SkuName"; + public const string TotalReservedQuantity = "TotalReservedQuantity"; + public const string UsageDate = "UsageDate"; + public const string UsedHours = "UsedHours"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Resource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Resource.cs new file mode 100644 index 0000000000000..2a2de4bdb5696 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Resource.cs @@ -0,0 +1,79 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource + /// + /// + /// Common fields that are returned in the response for all Azure Resource + /// Manager resources + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public Resource(string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the resource + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SavingsPlanUtilizationSummary.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SavingsPlanUtilizationSummary.cs new file mode 100644 index 0000000000000..48f33232f30c4 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SavingsPlanUtilizationSummary.cs @@ -0,0 +1,151 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Savings plan utilization summary resource. + /// + [Newtonsoft.Json.JsonObject("SavingsPlan")] + [Rest.Serialization.JsonTransformation] + public partial class SavingsPlanUtilizationSummary : BenefitUtilizationSummary + { + /// + /// Initializes a new instance of the SavingsPlanUtilizationSummary + /// class. + /// + public SavingsPlanUtilizationSummary() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SavingsPlanUtilizationSummary + /// class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// ARM SKU name. For example, Standard_D1_V2 + /// for reservations and ComputeSavingsPlan for savings plan. + /// The benefit ID is the identifier of a + /// benefit within a benefit order. + /// The benefit order ID is the identifier + /// for a benefit purchase. Each benefit order ID represents a single + /// purchase transaction. For example: A reservation order contains + /// reservations. The reservation order specifies the VM size and + /// region for the reservations. + /// The benefit type. For example, + /// reservation or savings plan. Possible values include: + /// 'IncludedQuantity', 'Reservation', 'SavingsPlan' + /// Date corresponding to the utilization + /// record. If the grain of data is monthly, it will be first day of + /// month. + /// This is the average + /// utilization percentage for the benefit ID. + /// 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, utilization was + /// 10%, this field will return 10% for that day + /// 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, utilization was + /// 100%, this field will return 100% for that day. + public SavingsPlanUtilizationSummary(string id = default(string), string name = default(string), string type = default(string), string armSkuName = default(string), string benefitId = default(string), string benefitOrderId = default(string), string benefitType = default(string), System.DateTime? usageDate = default(System.DateTime?), decimal? avgUtilizationPercentage = default(decimal?), decimal? minUtilizationPercentage = default(decimal?), decimal? maxUtilizationPercentage = default(decimal?)) + : base(id, name, type) + { + ArmSkuName = armSkuName; + BenefitId = benefitId; + BenefitOrderId = benefitOrderId; + BenefitType = benefitType; + UsageDate = usageDate; + AvgUtilizationPercentage = avgUtilizationPercentage; + MinUtilizationPercentage = minUtilizationPercentage; + MaxUtilizationPercentage = maxUtilizationPercentage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets ARM SKU name. For example, Standard_D1_V2 for reservations and + /// ComputeSavingsPlan for savings plan. + /// + [JsonProperty(PropertyName = "properties.armSkuName")] + public string ArmSkuName { get; private set; } + + /// + /// Gets the benefit ID is the identifier of a benefit within a benefit + /// order. + /// + [JsonProperty(PropertyName = "properties.benefitId")] + public string BenefitId { get; private set; } + + /// + /// Gets the benefit order ID is the identifier for a benefit purchase. + /// Each benefit order ID represents a single purchase transaction. For + /// example: A reservation order contains reservations. The reservation + /// order specifies the VM size and region for the reservations. + /// + [JsonProperty(PropertyName = "properties.benefitOrderId")] + public string BenefitOrderId { get; private set; } + + /// + /// Gets or sets the benefit type. For example, reservation or savings + /// plan. Possible values include: 'IncludedQuantity', 'Reservation', + /// 'SavingsPlan' + /// + [JsonProperty(PropertyName = "properties.benefitType")] + public string BenefitType { get; set; } + + /// + /// Gets date 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 this is the average utilization percentage for the benefit ID. + /// + [JsonProperty(PropertyName = "properties.avgUtilizationPercentage")] + public decimal? AvgUtilizationPercentage { 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, utilization was 10%, this field will return 10% + /// for that day + /// + [JsonProperty(PropertyName = "properties.minUtilizationPercentage")] + public decimal? MinUtilizationPercentage { 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, utilization was 100%, this field will return 100% + /// for that day. + /// + [JsonProperty(PropertyName = "properties.maxUtilizationPercentage")] + public decimal? MaxUtilizationPercentage { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduleFrequency.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduleFrequency.cs new file mode 100644 index 0000000000000..9dfcb8a22884d --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduleFrequency.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.CostManagement.Models +{ + + /// + /// Defines values for ScheduleFrequency. + /// + public static class ScheduleFrequency + { + /// + /// Cost analysis data will be emailed every day. + /// + public const string Daily = "Daily"; + /// + /// Cost analysis data will be emailed every week. + /// + public const string Weekly = "Weekly"; + /// + /// Cost analysis data will be emailed every month. + /// + public const string Monthly = "Monthly"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduleProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduleProperties.cs new file mode 100644 index 0000000000000..d657d64e710d0 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduleProperties.cs @@ -0,0 +1,133 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The properties of the schedule. + /// + public partial class ScheduleProperties + { + /// + /// Initializes a new instance of the ScheduleProperties class. + /// + public ScheduleProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScheduleProperties class. + /// + /// Frequency of the schedule. Possible values + /// include: 'Daily', 'Weekly', 'Monthly' + /// The start date and time of the scheduled + /// action (UTC). + /// The end date and time of the scheduled action + /// (UTC). + /// UTC time at which cost analysis data will + /// be emailed. + /// Day names in english on which cost + /// analysis data will be emailed. This property is applicable when + /// frequency is Weekly or Monthly. + /// Weeks in which cost analysis data will + /// be emailed. This property is applicable when frequency is Monthly + /// and used in combination with daysOfWeek. + /// UTC day on which cost analysis data will + /// be emailed. Must be between 1 and 31. This property is applicable + /// when frequency is Monthly and overrides weeksOfMonth or + /// daysOfWeek. + public ScheduleProperties(string frequency, System.DateTime startDate, System.DateTime endDate, int? hourOfDay = default(int?), IList daysOfWeek = default(IList), IList weeksOfMonth = default(IList), int? dayOfMonth = default(int?)) + { + Frequency = frequency; + HourOfDay = hourOfDay; + DaysOfWeek = daysOfWeek; + WeeksOfMonth = weeksOfMonth; + DayOfMonth = dayOfMonth; + StartDate = startDate; + EndDate = endDate; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets frequency of the schedule. Possible values include: + /// 'Daily', 'Weekly', 'Monthly' + /// + [JsonProperty(PropertyName = "frequency")] + public string Frequency { get; set; } + + /// + /// Gets or sets UTC time at which cost analysis data will be emailed. + /// + [JsonProperty(PropertyName = "hourOfDay")] + public int? HourOfDay { get; set; } + + /// + /// Gets or sets day names in english on which cost analysis data will + /// be emailed. This property is applicable when frequency is Weekly or + /// Monthly. + /// + [JsonProperty(PropertyName = "daysOfWeek")] + public IList DaysOfWeek { get; set; } + + /// + /// Gets or sets weeks in which cost analysis data will be emailed. + /// This property is applicable when frequency is Monthly and used in + /// combination with daysOfWeek. + /// + [JsonProperty(PropertyName = "weeksOfMonth")] + public IList WeeksOfMonth { get; set; } + + /// + /// Gets or sets UTC day on which cost analysis data will be emailed. + /// Must be between 1 and 31. This property is applicable when + /// frequency is Monthly and overrides weeksOfMonth or daysOfWeek. + /// + [JsonProperty(PropertyName = "dayOfMonth")] + public int? DayOfMonth { get; set; } + + /// + /// Gets or sets the start date and time of the scheduled action (UTC). + /// + [JsonProperty(PropertyName = "startDate")] + public System.DateTime StartDate { get; set; } + + /// + /// Gets or sets the end date and time of the scheduled action (UTC). + /// + [JsonProperty(PropertyName = "endDate")] + public System.DateTime EndDate { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Frequency == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Frequency"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledAction.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledAction.cs new file mode 100644 index 0000000000000..ba688c6ad0d39 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledAction.cs @@ -0,0 +1,197 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Scheduled action definition. + /// + [Rest.Serialization.JsonTransformation] + public partial class ScheduledAction : ScheduledActionProxyResource + { + /// + /// Initializes a new instance of the ScheduledAction class. + /// + public ScheduledAction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScheduledAction class. + /// + /// Scheduled action name. + /// Notification properties based on + /// scheduled action kind. + /// Schedule of the scheduled action. + /// Status of the scheduled action. Possible + /// values include: 'Disabled', 'Enabled', 'Expired' + /// Cost analysis viewId used for scheduled + /// action. For example, + /// '/providers/Microsoft.CostManagement/views/swaggerExample' + /// Resource Etag. + /// Kind of the scheduled action. Possible values + /// include: 'Email', 'InsightAlert' + /// Kind of the scheduled action. + /// Destination format of the view data. + /// This is optional. + /// Email address of the point of + /// contact that should get the unsubscribe requests and notification + /// emails. + /// Cost Management scope like + /// '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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for ExternalBillingAccount scope, and + /// '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for ExternalSubscription scope. + public ScheduledAction(string displayName, NotificationProperties notification, ScheduleProperties schedule, string status, string viewId, string eTag = default(string), string kind = default(string), SystemData systemData = default(SystemData), FileDestination fileDestination = default(FileDestination), string notificationEmail = default(string), string scope = default(string)) + : base(eTag, kind, systemData) + { + DisplayName = displayName; + FileDestination = fileDestination; + Notification = notification; + NotificationEmail = notificationEmail; + Schedule = schedule; + Scope = scope; + Status = status; + ViewId = viewId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets scheduled action name. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets destination format of the view data. This is optional. + /// + [JsonProperty(PropertyName = "properties.fileDestination")] + public FileDestination FileDestination { get; set; } + + /// + /// Gets or sets notification properties based on scheduled action + /// kind. + /// + [JsonProperty(PropertyName = "properties.notification")] + public NotificationProperties Notification { get; set; } + + /// + /// Gets or sets email address of the point of contact that should get + /// the unsubscribe requests and notification emails. + /// + [JsonProperty(PropertyName = "properties.notificationEmail")] + public string NotificationEmail { get; set; } + + /// + /// Gets or sets schedule of the scheduled action. + /// + [JsonProperty(PropertyName = "properties.schedule")] + public ScheduleProperties Schedule { get; set; } + + /// + /// Gets or sets cost Management scope like + /// '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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for ExternalBillingAccount scope, and + /// '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for ExternalSubscription scope. + /// + [JsonProperty(PropertyName = "properties.scope")] + public string Scope { get; set; } + + /// + /// Gets or sets status of the scheduled action. Possible values + /// include: 'Disabled', 'Enabled', 'Expired' + /// + [JsonProperty(PropertyName = "properties.status")] + public string Status { get; set; } + + /// + /// Gets or sets cost analysis viewId used for scheduled action. For + /// example, '/providers/Microsoft.CostManagement/views/swaggerExample' + /// + [JsonProperty(PropertyName = "properties.viewId")] + public string ViewId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (DisplayName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DisplayName"); + } + if (Notification == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Notification"); + } + if (Schedule == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Schedule"); + } + if (Status == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Status"); + } + if (ViewId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ViewId"); + } + if (Notification != null) + { + Notification.Validate(); + } + if (Schedule != null) + { + Schedule.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledActionKind.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledActionKind.cs new file mode 100644 index 0000000000000..1d08fbb11c3e4 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledActionKind.cs @@ -0,0 +1,30 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for ScheduledActionKind. + /// + public static class ScheduledActionKind + { + /// + /// Cost analysis data will be emailed. + /// + public const string Email = "Email"; + /// + /// Cost anomaly information will be emailed. Available only on + /// subscription scope at daily frequency. If no anomaly is detected on + /// the resource, an email won't be sent. + /// + public const string InsightAlert = "InsightAlert"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledActionProxyResource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledActionProxyResource.cs new file mode 100644 index 0000000000000..978500628bc93 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledActionProxyResource.cs @@ -0,0 +1,73 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The Resource model definition. + /// + public partial class ScheduledActionProxyResource : IResource + { + /// + /// Initializes a new instance of the ScheduledActionProxyResource + /// class. + /// + public ScheduledActionProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScheduledActionProxyResource + /// class. + /// + /// Resource Etag. + /// Kind of the scheduled action. Possible values + /// include: 'Email', 'InsightAlert' + /// Kind of the scheduled action. + public ScheduledActionProxyResource(string eTag = default(string), string kind = default(string), SystemData systemData = default(SystemData)) + { + ETag = eTag; + Kind = kind; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Etag. + /// + [JsonProperty(PropertyName = "eTag")] + public string ETag { get; private set; } + + /// + /// Gets or sets kind of the scheduled action. Possible values include: + /// 'Email', 'InsightAlert' + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + /// + /// Gets or sets kind of the scheduled action. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledActionStatus.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledActionStatus.cs new file mode 100644 index 0000000000000..78ba6474ec0c9 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ScheduledActionStatus.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.CostManagement.Models +{ + + /// + /// Defines values for ScheduledActionStatus. + /// + public static class ScheduledActionStatus + { + /// + /// Scheduled action is saved but will not be run. + /// + public const string Disabled = "Disabled"; + /// + /// Scheduled action is saved and will be run. + /// + public const string Enabled = "Enabled"; + /// + /// Scheduled action is expired. + /// + public const string Expired = "Expired"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Scope.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Scope.cs new file mode 100644 index 0000000000000..c2adabb6d13fb --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Scope.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.CostManagement.Models +{ + + /// + /// Defines values for Scope. + /// + public static class Scope + { + /// + /// Single scope recommendation. + /// + public const string Single = "Single"; + /// + /// Shared scope recommendation. + /// + public const string Shared = "Shared"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SharedScopeBenefitRecommendationProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SharedScopeBenefitRecommendationProperties.cs new file mode 100644 index 0000000000000..77a9d63db85e2 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SharedScopeBenefitRecommendationProperties.cs @@ -0,0 +1,76 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of the benefit plan recommendation when scope is + /// 'Shared'. + /// + [Newtonsoft.Json.JsonObject("Shared")] + public partial class SharedScopeBenefitRecommendationProperties : BenefitRecommendationProperties + { + /// + /// Initializes a new instance of the + /// SharedScopeBenefitRecommendationProperties class. + /// + public SharedScopeBenefitRecommendationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SharedScopeBenefitRecommendationProperties class. + /// + /// The first usage date used for + /// looking back for computing the recommendation. + /// The last usage date used for + /// looking back for computing the recommendation. + /// The number of days of usage used to + /// look back for computing the recommendation. Possible values + /// include: 'Last7Days', 'Last30Days', 'Last60Days' + /// The total hours for which the cost is + /// covered. Its equal to number of records in a property + /// 'properties/usage/charges'. + /// The additional details about the usage which + /// are considered while computing benefit recommendations. + /// ARM SKU name. For example, Standard_D1_V2 + /// for Reservations and Compute_Savings_Plan for SavingsPlan. + /// Term period of the benefit. For example, P1Y or + /// P3Y. Possible values include: 'P1Y', 'P3Y' + /// Grain of the proposed + /// commitment amount. For example, hourly, monthly etc. Possible + /// values include: 'Hourly', 'Daily', 'Monthly' + /// An ISO 4217 currency code identifier for + /// the costs and savings amounts. + /// The current cost without benefit + /// corresponds to 'totalHours' property in a given look-back + /// period. + /// The details of the proposed + /// recommendation. + /// The list of all benefit + /// recommendations. + public SharedScopeBenefitRecommendationProperties(System.DateTime? firstConsumptionDate = default(System.DateTime?), System.DateTime? lastConsumptionDate = default(System.DateTime?), string lookBackPeriod = default(string), int? totalHours = default(int?), RecommendationUsageDetails usage = default(RecommendationUsageDetails), string armSkuName = default(string), string term = default(string), string commitmentGranularity = default(string), string currencyCode = default(string), decimal? costWithoutBenefit = default(decimal?), AllSavingsBenefitDetails recommendationDetails = default(AllSavingsBenefitDetails), AllSavingsList allRecommendationDetails = default(AllSavingsList)) + : base(firstConsumptionDate, lastConsumptionDate, lookBackPeriod, totalHours, usage, armSkuName, term, commitmentGranularity, currencyCode, costWithoutBenefit, recommendationDetails, allRecommendationDetails) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SingleScopeBenefitRecommendationProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SingleScopeBenefitRecommendationProperties.cs new file mode 100644 index 0000000000000..79eb4c22a30ba --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SingleScopeBenefitRecommendationProperties.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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of the benefit plan recommendation when scope is + /// 'Single'. + /// + [Newtonsoft.Json.JsonObject("Single")] + public partial class SingleScopeBenefitRecommendationProperties : BenefitRecommendationProperties + { + /// + /// Initializes a new instance of the + /// SingleScopeBenefitRecommendationProperties class. + /// + public SingleScopeBenefitRecommendationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SingleScopeBenefitRecommendationProperties class. + /// + /// The first usage date used for + /// looking back for computing the recommendation. + /// The last usage date used for + /// looking back for computing the recommendation. + /// The number of days of usage used to + /// look back for computing the recommendation. Possible values + /// include: 'Last7Days', 'Last30Days', 'Last60Days' + /// The total hours for which the cost is + /// covered. Its equal to number of records in a property + /// 'properties/usage/charges'. + /// The additional details about the usage which + /// are considered while computing benefit recommendations. + /// ARM SKU name. For example, Standard_D1_V2 + /// for Reservations and Compute_Savings_Plan for SavingsPlan. + /// Term period of the benefit. For example, P1Y or + /// P3Y. Possible values include: 'P1Y', 'P3Y' + /// Grain of the proposed + /// commitment amount. For example, hourly, monthly etc. Possible + /// values include: 'Hourly', 'Daily', 'Monthly' + /// An ISO 4217 currency code identifier for + /// the costs and savings amounts. + /// The current cost without benefit + /// corresponds to 'totalHours' property in a given look-back + /// period. + /// The details of the proposed + /// recommendation. + /// The list of all benefit + /// recommendations. + /// The subscription ID that this single + /// scope recommendation is for. Applicable only if recommendation is + /// for 'Single' scope. + /// The resource group that this single + /// scope recommendation is for. Applicable only if recommendation is + /// for 'Single' scope and 'ResourceGroup' request scope. + public SingleScopeBenefitRecommendationProperties(System.DateTime? firstConsumptionDate = default(System.DateTime?), System.DateTime? lastConsumptionDate = default(System.DateTime?), string lookBackPeriod = default(string), int? totalHours = default(int?), RecommendationUsageDetails usage = default(RecommendationUsageDetails), string armSkuName = default(string), string term = default(string), string commitmentGranularity = default(string), string currencyCode = default(string), decimal? costWithoutBenefit = default(decimal?), AllSavingsBenefitDetails recommendationDetails = default(AllSavingsBenefitDetails), AllSavingsList allRecommendationDetails = default(AllSavingsList), string subscriptionId = default(string), string resourceGroup = default(string)) + : base(firstConsumptionDate, lastConsumptionDate, lookBackPeriod, totalHours, usage, armSkuName, term, commitmentGranularity, currencyCode, costWithoutBenefit, recommendationDetails, allRecommendationDetails) + { + SubscriptionId = subscriptionId; + ResourceGroup = resourceGroup; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the subscription ID that this single scope recommendation is + /// for. Applicable only if recommendation is for 'Single' scope. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets the resource group that this single scope recommendation is + /// for. Applicable only if recommendation is for 'Single' scope and + /// 'ResourceGroup' request scope. + /// + [JsonProperty(PropertyName = "resourceGroup")] + public string ResourceGroup { get; private set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Status.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Status.cs new file mode 100644 index 0000000000000..73729afbe6a16 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Status.cs @@ -0,0 +1,56 @@ +// +// 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.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The status of the long running operation. + /// + public partial class Status + { + /// + /// Initializes a new instance of the Status class. + /// + public Status() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Status class. + /// + /// The status of the long running + /// operation. Possible values include: 'InProgress', 'Completed', + /// 'Failed', 'Queued', 'NoDataFound', 'ReadyToDownload', + /// 'TimedOut' + public Status(string statusProperty = default(string)) + { + StatusProperty = statusProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the status of the long running operation. Possible + /// values include: 'InProgress', 'Completed', 'Failed', 'Queued', + /// 'NoDataFound', 'ReadyToDownload', 'TimedOut' + /// + [JsonProperty(PropertyName = "status")] + public string StatusProperty { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/StatusType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/StatusType.cs new file mode 100644 index 0000000000000..c41578f2ab905 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/StatusType.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.CostManagement.Models +{ + + /// + /// Defines values for StatusType. + /// + public static class StatusType + { + public const string Active = "Active"; + public const string Inactive = "Inactive"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SystemData.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SystemData.cs new file mode 100644 index 0000000000000..6aa389bd20da0 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/SystemData.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Metadata pertaining to creation and last modification of the resource. + /// + public partial class SystemData + { + /// + /// Initializes a new instance of the SystemData class. + /// + public SystemData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemData class. + /// + /// The identity that created the + /// resource. + /// The type of identity that created the + /// resource. Possible values include: 'User', 'Application', + /// 'ManagedIdentity', 'Key' + /// The timestamp of resource creation + /// (UTC). + /// The identity that last modified the + /// resource. + /// The type of identity that last + /// modified the resource. Possible values include: 'User', + /// 'Application', 'ManagedIdentity', 'Key' + /// The timestamp of resource last + /// modification (UTC) + public SystemData(string createdBy = default(string), string createdByType = default(string), System.DateTime? createdAt = default(System.DateTime?), string lastModifiedBy = default(string), string lastModifiedByType = default(string), System.DateTime? lastModifiedAt = default(System.DateTime?)) + { + CreatedBy = createdBy; + CreatedByType = createdByType; + CreatedAt = createdAt; + LastModifiedBy = lastModifiedBy; + LastModifiedByType = lastModifiedByType; + LastModifiedAt = lastModifiedAt; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity that created the resource. + /// + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets the type of identity that created the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "createdByType")] + public string CreatedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource creation (UTC). + /// + [JsonProperty(PropertyName = "createdAt")] + public System.DateTime? CreatedAt { get; set; } + + /// + /// Gets or sets the identity that last modified the resource. + /// + [JsonProperty(PropertyName = "lastModifiedBy")] + public string LastModifiedBy { get; set; } + + /// + /// Gets or sets the type of identity that last modified the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "lastModifiedByType")] + public string LastModifiedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource last modification (UTC) + /// + [JsonProperty(PropertyName = "lastModifiedAt")] + public System.DateTime? LastModifiedAt { get; set; } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Term.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Term.cs new file mode 100644 index 0000000000000..e8c5650af80f6 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Term.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.CostManagement.Models +{ + + /// + /// Defines values for Term. + /// + public static class Term + { + /// + /// Benefit term is 1 year. + /// + public const string P1Y = "P1Y"; + /// + /// Benefit term is 3 years. + /// + public const string P3Y = "P3Y"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/TimeframeType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/TimeframeType.cs new file mode 100644 index 0000000000000..7dadbd2e3a5e7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/TimeframeType.cs @@ -0,0 +1,26 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for TimeframeType. + /// + public static class TimeframeType + { + public const string MonthToDate = "MonthToDate"; + public const string BillingMonthToDate = "BillingMonthToDate"; + public const string TheLastMonth = "TheLastMonth"; + public const string TheLastBillingMonth = "TheLastBillingMonth"; + public const string WeekToDate = "WeekToDate"; + public const string Custom = "Custom"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/TrackedResource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/TrackedResource.cs new file mode 100644 index 0000000000000..61f6e76707c70 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/TrackedResource.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tracked Resource + /// + /// + /// The resource model definition for an Azure Resource Manager tracked top + /// level resource which has 'tags' and a 'location' + /// + public partial class TrackedResource : Resource + { + /// + /// Initializes a new instance of the TrackedResource class. + /// + public TrackedResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TrackedResource class. + /// + /// The geo-location where the resource + /// lives + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Resource tags. + public TrackedResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type) + { + Tags = tags; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the geo-location where the resource lives + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/View.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/View.cs new file mode 100644 index 0000000000000..3b151ed9f9bc3 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/View.cs @@ -0,0 +1,270 @@ +// +// 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.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// States and configurations of Cost Analysis. + /// + [Rest.Serialization.JsonTransformation] + public partial class View : CostManagementProxyResource + { + /// + /// Initializes a new instance of the View class. + /// + public View() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the View class. + /// + /// The time frame for pulling data for the + /// report. If custom, then a specific time period must be provided. + /// Possible values include: 'WeekToDate', 'MonthToDate', 'YearToDate', + /// 'Custom' + /// 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. + /// User input name of the view. + /// Required. + /// Cost Management scope to save the view on. 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for ExternalBillingAccount scope, and + /// '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for ExternalSubscription scope. + /// Date the user created this view. + /// Date when the user last modified this + /// view. + /// Date range of the current view. + /// Currency of the current view. + /// Has time period for pulling data for the + /// report. + /// Has definition for data in this report + /// config. + /// If true, report includes + /// monetary commitment. + /// Chart type of the main view in Cost Analysis. + /// Required. Possible values include: 'Area', 'Line', 'StackedColumn', + /// 'GroupedColumn', 'Table' + /// Show costs accumulated over time. + /// Possible values include: 'true', 'false' + /// Metric to use when displaying costs. Possible + /// values include: 'ActualCost', 'AmortizedCost', 'AHUB' + /// List of KPIs to show in Cost Analysis + /// UI. + /// Configuration of 3 sub-views in the Cost + /// Analysis UI. + public View(string timeframe, string id = default(string), string name = default(string), string type = default(string), string eTag = default(string), string displayName = default(string), string scope = default(string), System.DateTime? createdOn = default(System.DateTime?), System.DateTime? modifiedOn = default(System.DateTime?), string dateRange = default(string), string currency = default(string), ReportConfigTimePeriod timePeriod = default(ReportConfigTimePeriod), ReportConfigDataset dataSet = default(ReportConfigDataset), bool? includeMonetaryCommitment = default(bool?), string chart = default(string), string accumulated = default(string), string metric = default(string), IList kpis = default(IList), IList pivots = default(IList)) + : base(id, name, type, eTag) + { + DisplayName = displayName; + Scope = scope; + CreatedOn = createdOn; + ModifiedOn = modifiedOn; + DateRange = dateRange; + Currency = currency; + Timeframe = timeframe; + TimePeriod = timePeriod; + DataSet = dataSet; + IncludeMonetaryCommitment = includeMonetaryCommitment; + Chart = chart; + Accumulated = accumulated; + Metric = metric; + Kpis = kpis; + Pivots = pivots; + CustomInit(); + } + /// + /// Static constructor for View class. + /// + static View() + { + ViewType = "Usage"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets user input name of the view. Required. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets cost Management scope to save the view on. 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + /// for Management Group scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for ExternalBillingAccount scope, and + /// '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for ExternalSubscription scope. + /// + [JsonProperty(PropertyName = "properties.scope")] + public string Scope { get; set; } + + /// + /// Gets date the user created this view. + /// + [JsonProperty(PropertyName = "properties.createdOn")] + public System.DateTime? CreatedOn { get; private set; } + + /// + /// Gets date when the user last modified this view. + /// + [JsonProperty(PropertyName = "properties.modifiedOn")] + public System.DateTime? ModifiedOn { get; private set; } + + /// + /// Gets date range of the current view. + /// + [JsonProperty(PropertyName = "properties.dateRange")] + public string DateRange { get; private set; } + + /// + /// Gets currency of the current view. + /// + [JsonProperty(PropertyName = "properties.currency")] + public string Currency { get; private set; } + + /// + /// Gets or sets the time frame for pulling data for the report. If + /// custom, then a specific time period must be provided. Possible + /// values include: 'WeekToDate', 'MonthToDate', 'YearToDate', 'Custom' + /// + [JsonProperty(PropertyName = "properties.query.timeframe")] + public string Timeframe { get; set; } + + /// + /// Gets or sets has time period for pulling data for the report. + /// + [JsonProperty(PropertyName = "properties.query.timePeriod")] + public ReportConfigTimePeriod TimePeriod { get; set; } + + /// + /// Gets or sets has definition for data in this report config. + /// + [JsonProperty(PropertyName = "properties.query.dataSet")] + public ReportConfigDataset DataSet { get; set; } + + /// + /// Gets or sets if true, report includes monetary commitment. + /// + [JsonProperty(PropertyName = "properties.query.includeMonetaryCommitment")] + public bool? IncludeMonetaryCommitment { get; set; } + + /// + /// Gets or sets chart type of the main view in Cost Analysis. + /// Required. Possible values include: 'Area', 'Line', 'StackedColumn', + /// 'GroupedColumn', 'Table' + /// + [JsonProperty(PropertyName = "properties.chart")] + public string Chart { get; set; } + + /// + /// Gets or sets show costs accumulated over time. Possible values + /// include: 'true', 'false' + /// + [JsonProperty(PropertyName = "properties.accumulated")] + public string Accumulated { get; set; } + + /// + /// Gets or sets metric to use when displaying costs. Possible values + /// include: 'ActualCost', 'AmortizedCost', 'AHUB' + /// + [JsonProperty(PropertyName = "properties.metric")] + public string Metric { get; set; } + + /// + /// Gets or sets list of KPIs to show in Cost Analysis UI. + /// + [JsonProperty(PropertyName = "properties.kpis")] + public IList Kpis { get; set; } + + /// + /// Gets or sets configuration of 3 sub-views in the Cost Analysis UI. + /// + [JsonProperty(PropertyName = "properties.pivots")] + public IList Pivots { get; set; } + + /// + /// The type of the report. Usage represents actual usage, forecast + /// represents forecasted data and UsageAndForecast represents both + /// usage and forecasted data. Actual usage and forecasted data can be + /// differentiated based on dates. + /// + [JsonProperty(PropertyName = "properties.query.type")] + public static string ViewType { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Timeframe == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Timeframe"); + } + if (TimePeriod != null) + { + TimePeriod.Validate(); + } + if (DataSet != null) + { + DataSet.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/WeeksOfMonth.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/WeeksOfMonth.cs new file mode 100644 index 0000000000000..5a3808d783235 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/WeeksOfMonth.cs @@ -0,0 +1,25 @@ +// +// 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.CostManagement.Models +{ + + /// + /// Defines values for WeeksOfMonth. + /// + public static class WeeksOfMonth + { + public const string First = "First"; + public const string Second = "Second"; + public const string Third = "Third"; + public const string Fourth = "Fourth"; + public const string Last = "Last"; + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Operations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Operations.cs new file mode 100644 index 0000000000000..183e87e1e919e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Operations.cs @@ -0,0 +1,397 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// Operations operations. + /// + internal partial class Operations : IServiceOperations, IOperations + { + /// + /// Initializes a new instance of the Operations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal Operations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Lists all of the available cost management REST API operations. + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + 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.CostManagement/operations").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all of the available cost management REST API operations. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/OperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/OperationsExtensions.cs new file mode 100644 index 0000000000000..f163a3dd59291 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/OperationsExtensions.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// Lists all of the available cost management REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available cost management REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all of the available cost management REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available cost management REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/PriceSheetOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/PriceSheetOperations.cs new file mode 100644 index 0000000000000..d0bec863a71f8 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/PriceSheetOperations.cs @@ -0,0 +1,571 @@ +// +// 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.CostManagement +{ + 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(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Gets a URL to download the pricesheet for an invoice. The operation is + /// supported for billing accounts with agreement type Microsoft Partner + /// Agreement or Microsoft Customer Agreement. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The ID that uniquely identifies an invoice. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DownloadWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDownloadWithHttpMessagesAsync(billingAccountName, billingProfileName, invoiceName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a URL to download the current month's pricesheet for a billing + /// profile. The operation is supported for billing accounts with agreement + /// type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to + /// Azure product growth, the Azure price sheet download experience in this + /// preview version will be updated from a single csv file to a Zip file + /// containing multiple csv files, each with max 200k records. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DownloadByBillingProfileWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDownloadByBillingProfileWithHttpMessagesAsync(billingAccountName, billingProfileName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a URL to download the pricesheet for an invoice. The operation is + /// supported for billing accounts with agreement type Microsoft Partner + /// Agreement or Microsoft Customer Agreement. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The ID that uniquely identifies an invoice. + /// + /// + /// 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 billingAccountName, string billingProfileName, string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (billingAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); + } + if (billingAccountName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(billingAccountName, "([A-Za-z0-9]+(-[A-Za-z0-9]+)+):([A-Za-z0-9]+(-[A-Za-z0-9]+)+)_[0-9]{4}-[0-9]{2}-[0-9]{2}")) + { + throw new ValidationException(ValidationRules.Pattern, "billingAccountName", "([A-Za-z0-9]+(-[A-Za-z0-9]+)+):([A-Za-z0-9]+(-[A-Za-z0-9]+)+)_[0-9]{4}-[0-9]{2}-[0-9]{2}"); + } + } + if (billingProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileName"); + } + if (billingProfileName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(billingProfileName, "([A-Za-z0-9]+(-[A-Za-z0-9]+)+)")) + { + throw new ValidationException(ValidationRules.Pattern, "billingProfileName", "([A-Za-z0-9]+(-[A-Za-z0-9]+)+)"); + } + } + if (invoiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "invoiceName"); + } + if (invoiceName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(invoiceName, "[A-Za-z0-9]+")) + { + throw new ValidationException(ValidationRules.Pattern, "invoiceName", "[A-Za-z0-9]+"); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("billingProfileName", billingProfileName); + tracingParameters.Add("invoiceName", invoiceName); + 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.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices/{invoiceName}/providers/Microsoft.CostManagement/pricesheets/default/download").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName)); + _url = _url.Replace("{invoiceName}", System.Uri.EscapeDataString(invoiceName)); + 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; + } + + /// + /// Gets a URL to download the current month's pricesheet for a billing + /// profile. The operation is supported for billing accounts with agreement + /// type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to + /// Azure product growth, the Azure price sheet download experience in this + /// preview version will be updated from a single csv file to a Zip file + /// containing multiple csv files, each with max 200k records. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// 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> BeginDownloadByBillingProfileWithHttpMessagesAsync(string billingAccountName, string billingProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (billingAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); + } + if (billingAccountName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(billingAccountName, "([A-Za-z0-9]+(-[A-Za-z0-9]+)+):([A-Za-z0-9]+(-[A-Za-z0-9]+)+)_[0-9]{4}-[0-9]{2}-[0-9]{2}")) + { + throw new ValidationException(ValidationRules.Pattern, "billingAccountName", "([A-Za-z0-9]+(-[A-Za-z0-9]+)+):([A-Za-z0-9]+(-[A-Za-z0-9]+)+)_[0-9]{4}-[0-9]{2}-[0-9]{2}"); + } + } + if (billingProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileName"); + } + if (billingProfileName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(billingProfileName, "([A-Za-z0-9]+(-[A-Za-z0-9]+)+)")) + { + throw new ValidationException(ValidationRules.Pattern, "billingProfileName", "([A-Za-z0-9]+(-[A-Za-z0-9]+)+)"); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("billingProfileName", billingProfileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDownloadByBillingProfile", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.CostManagement/pricesheets/default/download").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/PriceSheetOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/PriceSheetOperationsExtensions.cs new file mode 100644 index 0000000000000..0535f12edeb46 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/PriceSheetOperationsExtensions.cs @@ -0,0 +1,225 @@ +// +// 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.CostManagement +{ + 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 a URL to download the pricesheet for an invoice. The operation is + /// supported for billing accounts with agreement type Microsoft Partner + /// Agreement or Microsoft Customer Agreement. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The ID that uniquely identifies an invoice. + /// + public static DownloadURL Download(this IPriceSheetOperations operations, string billingAccountName, string billingProfileName, string invoiceName) + { + return operations.DownloadAsync(billingAccountName, billingProfileName, invoiceName).GetAwaiter().GetResult(); + } + + /// + /// Gets a URL to download the pricesheet for an invoice. The operation is + /// supported for billing accounts with agreement type Microsoft Partner + /// Agreement or Microsoft Customer Agreement. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The ID that uniquely identifies an invoice. + /// + /// + /// The cancellation token. + /// + public static async Task DownloadAsync(this IPriceSheetOperations operations, string billingAccountName, string billingProfileName, string invoiceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DownloadWithHttpMessagesAsync(billingAccountName, billingProfileName, invoiceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a URL to download the current month's pricesheet for a billing + /// profile. The operation is supported for billing accounts with agreement + /// type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to + /// Azure product growth, the Azure price sheet download experience in this + /// preview version will be updated from a single csv file to a Zip file + /// containing multiple csv files, each with max 200k records. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + public static DownloadURL DownloadByBillingProfile(this IPriceSheetOperations operations, string billingAccountName, string billingProfileName) + { + return operations.DownloadByBillingProfileAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult(); + } + + /// + /// Gets a URL to download the current month's pricesheet for a billing + /// profile. The operation is supported for billing accounts with agreement + /// type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to + /// Azure product growth, the Azure price sheet download experience in this + /// preview version will be updated from a single csv file to a Zip file + /// containing multiple csv files, each with max 200k records. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The cancellation token. + /// + public static async Task DownloadByBillingProfileAsync(this IPriceSheetOperations operations, string billingAccountName, string billingProfileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DownloadByBillingProfileWithHttpMessagesAsync(billingAccountName, billingProfileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a URL to download the pricesheet for an invoice. The operation is + /// supported for billing accounts with agreement type Microsoft Partner + /// Agreement or Microsoft Customer Agreement. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The ID that uniquely identifies an invoice. + /// + public static DownloadURL BeginDownload(this IPriceSheetOperations operations, string billingAccountName, string billingProfileName, string invoiceName) + { + return operations.BeginDownloadAsync(billingAccountName, billingProfileName, invoiceName).GetAwaiter().GetResult(); + } + + /// + /// Gets a URL to download the pricesheet for an invoice. The operation is + /// supported for billing accounts with agreement type Microsoft Partner + /// Agreement or Microsoft Customer Agreement. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The ID that uniquely identifies an invoice. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDownloadAsync(this IPriceSheetOperations operations, string billingAccountName, string billingProfileName, string invoiceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDownloadWithHttpMessagesAsync(billingAccountName, billingProfileName, invoiceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a URL to download the current month's pricesheet for a billing + /// profile. The operation is supported for billing accounts with agreement + /// type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to + /// Azure product growth, the Azure price sheet download experience in this + /// preview version will be updated from a single csv file to a Zip file + /// containing multiple csv files, each with max 200k records. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + public static DownloadURL BeginDownloadByBillingProfile(this IPriceSheetOperations operations, string billingAccountName, string billingProfileName) + { + return operations.BeginDownloadByBillingProfileAsync(billingAccountName, billingProfileName).GetAwaiter().GetResult(); + } + + /// + /// Gets a URL to download the current month's pricesheet for a billing + /// profile. The operation is supported for billing accounts with agreement + /// type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to + /// Azure product growth, the Azure price sheet download experience in this + /// preview version will be updated from a single csv file to a Zip file + /// containing multiple csv files, each with max 200k records. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID that uniquely identifies a billing account. + /// + /// + /// The ID that uniquely identifies a billing profile. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDownloadByBillingProfileAsync(this IPriceSheetOperations operations, string billingAccountName, string billingProfileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDownloadByBillingProfileWithHttpMessagesAsync(billingAccountName, billingProfileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperations.cs new file mode 100644 index 0000000000000..78777995c141a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperations.cs @@ -0,0 +1,491 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// QueryOperations operations. + /// + internal partial class QueryOperations : IServiceOperations, IQueryOperations + { + /// + /// Initializes a new instance of the QueryOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal QueryOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Query the usage data for scope defined. + /// + /// + /// + /// The scope associated with query and export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Parameters supplied to the CreateOrUpdate Query Config 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> UsageWithHttpMessagesAsync(string scope, QueryDefinition 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + 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("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Usage", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/query").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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // 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; + } + + /// + /// Query the usage data for external cloud provider type defined. + /// + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// Parameters supplied to the CreateOrUpdate Query Config 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> UsageByExternalCloudProviderTypeWithHttpMessagesAsync(string externalCloudProviderType, string externalCloudProviderId, QueryDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (externalCloudProviderType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "externalCloudProviderType"); + } + if (externalCloudProviderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "externalCloudProviderId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + 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("externalCloudProviderType", externalCloudProviderType); + tracingParameters.Add("externalCloudProviderId", externalCloudProviderId); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UsageByExternalCloudProviderType", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query").ToString(); + _url = _url.Replace("{externalCloudProviderType}", System.Uri.EscapeDataString(externalCloudProviderType)); + _url = _url.Replace("{externalCloudProviderId}", System.Uri.EscapeDataString(externalCloudProviderId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperationsExtensions.cs new file mode 100644 index 0000000000000..f3816c554ebf3 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperationsExtensions.cs @@ -0,0 +1,159 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for QueryOperations. + /// + public static partial class QueryOperationsExtensions + { + /// + /// Query the usage data for scope defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with query and export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// + public static QueryResult Usage(this IQueryOperations operations, string scope, QueryDefinition parameters) + { + return operations.UsageAsync(scope, parameters).GetAwaiter().GetResult(); + } + + /// + /// Query the usage data for scope defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with query and export operations. This includes + /// '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + /// resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// Billing Account scope and + /// '/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}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// + /// + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// + /// + /// The cancellation token. + /// + public static async Task UsageAsync(this IQueryOperations operations, string scope, QueryDefinition parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UsageWithHttpMessagesAsync(scope, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Query the usage data for external cloud provider type defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// + public static QueryResult UsageByExternalCloudProviderType(this IQueryOperations operations, string externalCloudProviderType, string externalCloudProviderId, QueryDefinition parameters) + { + return operations.UsageByExternalCloudProviderTypeAsync(externalCloudProviderType, externalCloudProviderId, parameters).GetAwaiter().GetResult(); + } + + /// + /// Query the usage data for external cloud provider type defined. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The external cloud provider type associated with dimension/query + /// operations. This includes 'externalSubscriptions' for linked account and + /// 'externalBillingAccounts' for consolidated account. Possible values + /// include: 'externalSubscriptions', 'externalBillingAccounts' + /// + /// + /// This can be '{externalSubscriptionId}' for linked account or + /// '{externalBillingAccountId}' for consolidated account used with + /// dimension/query operations. + /// + /// + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// + /// + /// The cancellation token. + /// + public static async Task UsageByExternalCloudProviderTypeAsync(this IQueryOperations operations, string externalCloudProviderType, string externalCloudProviderId, QueryDefinition parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UsageByExternalCloudProviderTypeWithHttpMessagesAsync(externalCloudProviderType, externalCloudProviderId, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ScheduledActionsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ScheduledActionsOperations.cs new file mode 100644 index 0000000000000..ea055073f3dde --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ScheduledActionsOperations.cs @@ -0,0 +1,2767 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// ScheduledActionsOperations operations. + /// + internal partial class ScheduledActionsOperations : IServiceOperations, IScheduledActionsOperations + { + /// + /// Initializes a new instance of the ScheduledActionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ScheduledActionsOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// List all private scheduled actions. + /// + /// + /// + /// May be used to filter scheduled actions by properties/viewId. Supported + /// operator is 'eq'. + /// + /// + /// 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 filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.CostManagement/scheduledActions").ToString(); + 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; + } + + /// + /// List all shared scheduled actions within the given scope. + /// + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// May be used to filter scheduled actions by properties/viewId. Supported + /// operator is 'eq'. + /// + /// + /// 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>> ListByScopeWithHttpMessagesAsync(string scope, string filter = 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"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/scheduledActions").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + 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; + } + + /// + /// Create or update a private scheduled action. + /// + /// + /// Scheduled action name. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// 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 name, ScheduledAction scheduledAction, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (scheduledAction == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scheduledAction"); + } + if (scheduledAction != null) + { + scheduledAction.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("name", name); + tracingParameters.Add("scheduledAction", scheduledAction); + 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("/") ? "" : "/")), "providers/Microsoft.CostManagement/scheduledActions/{name}").ToString(); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + 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(scheduledAction != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(scheduledAction, 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; + } + + /// + /// Get the private scheduled action by name. + /// + /// + /// + /// Scheduled action 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 name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("name", name); + 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.CostManagement/scheduledActions/{name}").ToString(); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a private scheduled action. + /// + /// + /// + /// Scheduled action 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 name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.CostManagement/scheduledActions/{name}").ToString(); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + 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 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update a shared scheduled action within the given scope. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action name. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// 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> CreateOrUpdateByScopeWithHttpMessagesAsync(string scope, string name, ScheduledAction scheduledAction, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (scheduledAction == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scheduledAction"); + } + if (scheduledAction != null) + { + scheduledAction.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("name", name); + tracingParameters.Add("scheduledAction", scheduledAction); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + 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(scheduledAction != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(scheduledAction, 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; + } + + /// + /// Get the shared scheduled action from the given scope by name. + /// + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action 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> GetByScopeWithHttpMessagesAsync(string scope, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a scheduled action within the given scope. + /// + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action 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 DeleteByScopeWithHttpMessagesAsync(string scope, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + 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 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Processes a private scheduled action. + /// + /// + /// Scheduled action 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 RunWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Run", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.CostManagement/scheduledActions/{name}/execute").ToString(); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + 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) + { + 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; + } + + /// + /// Runs a shared scheduled action within the given scope. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action 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 RunByScopeWithHttpMessagesAsync(string scope, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "RunByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}/execute").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + 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) + { + 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; + } + + /// + /// Checks availability and correctness of the name for a scheduled action. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// 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> CheckNameAvailabilityWithHttpMessagesAsync(CheckNameAvailabilityRequest checkNameAvailabilityRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (checkNameAvailabilityRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "checkNameAvailabilityRequest"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("checkNameAvailabilityRequest", checkNameAvailabilityRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.CostManagement/checkNameAvailability").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(checkNameAvailabilityRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(checkNameAvailabilityRequest, 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) + { + 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; + } + + /// + /// Checks availability and correctness of the name for a scheduled action + /// within the given scope. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// 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> CheckNameAvailabilityByScopeWithHttpMessagesAsync(string scope, CheckNameAvailabilityRequest checkNameAvailabilityRequest, 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (checkNameAvailabilityRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "checkNameAvailabilityRequest"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("checkNameAvailabilityRequest", checkNameAvailabilityRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailabilityByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/checkNameAvailability").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(checkNameAvailabilityRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(checkNameAvailabilityRequest, 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) + { + 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; + } + + /// + /// List all private scheduled actions. + /// + /// + /// + /// 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; + } + + /// + /// List all shared scheduled actions within the given 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>> ListByScopeNextWithHttpMessagesAsync(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, "ListByScopeNext", 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ScheduledActionsOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ScheduledActionsOperationsExtensions.cs new file mode 100644 index 0000000000000..eb9999137d00f --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ScheduledActionsOperationsExtensions.cs @@ -0,0 +1,775 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ScheduledActionsOperations. + /// + public static partial class ScheduledActionsOperationsExtensions + { + /// + /// List all private scheduled actions. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// May be used to filter scheduled actions by properties/viewId. Supported + /// operator is 'eq'. + /// + public static IPage List(this IScheduledActionsOperations operations, string filter = default(string)) + { + return operations.ListAsync(filter).GetAwaiter().GetResult(); + } + + /// + /// List all private scheduled actions. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// May be used to filter scheduled actions by properties/viewId. Supported + /// operator is 'eq'. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IScheduledActionsOperations operations, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all shared scheduled actions within the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// May be used to filter scheduled actions by properties/viewId. Supported + /// operator is 'eq'. + /// + public static IPage ListByScope(this IScheduledActionsOperations operations, string scope, string filter = default(string)) + { + return operations.ListByScopeAsync(scope, filter).GetAwaiter().GetResult(); + } + + /// + /// List all shared scheduled actions within the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// May be used to filter scheduled actions by properties/viewId. Supported + /// operator is 'eq'. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByScopeAsync(this IScheduledActionsOperations 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; + } + } + + /// + /// Create or update a private scheduled action. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action name. + /// + /// + /// Scheduled action to be created or updated. + /// + public static ScheduledAction CreateOrUpdate(this IScheduledActionsOperations operations, string name, ScheduledAction scheduledAction) + { + return operations.CreateOrUpdateAsync(name, scheduledAction).GetAwaiter().GetResult(); + } + + /// + /// Create or update a private scheduled action. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action name. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IScheduledActionsOperations operations, string name, ScheduledAction scheduledAction, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(name, scheduledAction, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the private scheduled action by name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action name. + /// + public static ScheduledAction Get(this IScheduledActionsOperations operations, string name) + { + return operations.GetAsync(name).GetAwaiter().GetResult(); + } + + /// + /// Get the private scheduled action by name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action name. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IScheduledActionsOperations operations, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a private scheduled action. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action name. + /// + public static void Delete(this IScheduledActionsOperations operations, string name) + { + operations.DeleteAsync(name).GetAwaiter().GetResult(); + } + + /// + /// Delete a private scheduled action. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IScheduledActionsOperations operations, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create or update a shared scheduled action within the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action name. + /// + /// + /// Scheduled action to be created or updated. + /// + public static ScheduledAction CreateOrUpdateByScope(this IScheduledActionsOperations operations, string scope, string name, ScheduledAction scheduledAction) + { + return operations.CreateOrUpdateByScopeAsync(scope, name, scheduledAction).GetAwaiter().GetResult(); + } + + /// + /// Create or update a shared scheduled action within the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action name. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateByScopeAsync(this IScheduledActionsOperations operations, string scope, string name, ScheduledAction scheduledAction, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateByScopeWithHttpMessagesAsync(scope, name, scheduledAction, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the shared scheduled action from the given scope by name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action name. + /// + public static ScheduledAction GetByScope(this IScheduledActionsOperations operations, string scope, string name) + { + return operations.GetByScopeAsync(scope, name).GetAwaiter().GetResult(); + } + + /// + /// Get the shared scheduled action from the given scope by name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action name. + /// + /// + /// The cancellation token. + /// + public static async Task GetByScopeAsync(this IScheduledActionsOperations operations, string scope, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetByScopeWithHttpMessagesAsync(scope, name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a scheduled action within the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action name. + /// + public static void DeleteByScope(this IScheduledActionsOperations operations, string scope, string name) + { + operations.DeleteByScopeAsync(scope, name).GetAwaiter().GetResult(); + } + + /// + /// Delete a scheduled action within the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteByScopeAsync(this IScheduledActionsOperations operations, string scope, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteByScopeWithHttpMessagesAsync(scope, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Processes a private scheduled action. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action name. + /// + public static void Run(this IScheduledActionsOperations operations, string name) + { + operations.RunAsync(name).GetAwaiter().GetResult(); + } + + /// + /// Processes a private scheduled action. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action name. + /// + /// + /// The cancellation token. + /// + public static async Task RunAsync(this IScheduledActionsOperations operations, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.RunWithHttpMessagesAsync(name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Runs a shared scheduled action within the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action name. + /// + public static void RunByScope(this IScheduledActionsOperations operations, string scope, string name) + { + operations.RunByScopeAsync(scope, name).GetAwaiter().GetResult(); + } + + /// + /// Runs a shared scheduled action within the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action name. + /// + /// + /// The cancellation token. + /// + public static async Task RunByScopeAsync(this IScheduledActionsOperations operations, string scope, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.RunByScopeWithHttpMessagesAsync(scope, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks availability and correctness of the name for a scheduled action. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action to be created or updated. + /// + public static CheckNameAvailabilityResponse CheckNameAvailability(this IScheduledActionsOperations operations, CheckNameAvailabilityRequest checkNameAvailabilityRequest) + { + return operations.CheckNameAvailabilityAsync(checkNameAvailabilityRequest).GetAwaiter().GetResult(); + } + + /// + /// Checks availability and correctness of the name for a scheduled action. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// The cancellation token. + /// + public static async Task CheckNameAvailabilityAsync(this IScheduledActionsOperations operations, CheckNameAvailabilityRequest checkNameAvailabilityRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(checkNameAvailabilityRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Checks availability and correctness of the name for a scheduled action + /// within the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action to be created or updated. + /// + public static CheckNameAvailabilityResponse CheckNameAvailabilityByScope(this IScheduledActionsOperations operations, string scope, CheckNameAvailabilityRequest checkNameAvailabilityRequest) + { + return operations.CheckNameAvailabilityByScopeAsync(scope, checkNameAvailabilityRequest).GetAwaiter().GetResult(); + } + + /// + /// Checks availability and correctness of the name for a scheduled action + /// within the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with scheduled action 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. Note: Insight Alerts are only available on + /// subscription scope. + /// + /// + /// Scheduled action to be created or updated. + /// + /// + /// The cancellation token. + /// + public static async Task CheckNameAvailabilityByScopeAsync(this IScheduledActionsOperations operations, string scope, CheckNameAvailabilityRequest checkNameAvailabilityRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckNameAvailabilityByScopeWithHttpMessagesAsync(scope, checkNameAvailabilityRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all private scheduled actions. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IScheduledActionsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all private scheduled actions. + /// + /// + /// + /// 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 IScheduledActionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all shared scheduled actions within the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByScopeNext(this IScheduledActionsOperations operations, string nextPageLink) + { + return operations.ListByScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all shared scheduled actions within the given 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> ListByScopeNextAsync(this IScheduledActionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/SdkInfo_CostManagementClient.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/SdkInfo_CostManagementClient.cs new file mode 100644 index 0000000000000..f8dd1061e8ddb --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/SdkInfo_CostManagementClient.cs @@ -0,0 +1,43 @@ + +// +// 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.CostManagement +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_CostManagementClient + { + get + { + return new Tuple[] + { + new Tuple("Billing", "BenefitUtilizationSummaries", "2022-10-01"), + new Tuple("Billing", "GenerateReservationDetailsReport", "2022-10-01"), + new Tuple("Billing", "PriceSheet", "2022-10-01"), + new Tuple("BillingBenefits", "BenefitUtilizationSummaries", "2022-10-01"), + new Tuple("CostManagement", "Alerts", "2022-10-01"), + new Tuple("CostManagement", "BenefitRecommendations", "2022-10-01"), + new Tuple("CostManagement", "Dimensions", "2022-10-01"), + new Tuple("CostManagement", "Exports", "2022-10-01"), + new Tuple("CostManagement", "Forecast", "2022-10-01"), + new Tuple("CostManagement", "GenerateCostDetailsReport", "2022-10-01"), + new Tuple("CostManagement", "GenerateDetailedCostReport", "2022-10-01"), + new Tuple("CostManagement", "GenerateDetailedCostReportOperationResults", "2022-10-01"), + new Tuple("CostManagement", "GenerateDetailedCostReportOperationStatus", "2022-10-01"), + new Tuple("CostManagement", "Operations", "2022-10-01"), + new Tuple("CostManagement", "Query", "2022-10-01"), + new Tuple("CostManagement", "ScheduledActions", "2022-10-01"), + new Tuple("CostManagement", "Views", "2022-10-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ViewsOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ViewsOperations.cs new file mode 100644 index 0000000000000..d3ab26911e44d --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ViewsOperations.cs @@ -0,0 +1,2000 @@ +// +// 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.CostManagement +{ + 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; + + /// + /// ViewsOperations operations. + /// + internal partial class ViewsOperations : IServiceOperations, IViewsOperations + { + /// + /// Initializes a new instance of the ViewsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ViewsOperations(CostManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CostManagementClient + /// + public CostManagementClient Client { get; private set; } + + /// + /// Lists all views by tenant and object. + /// + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + 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.CostManagement/views").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all views at the given scope. + /// + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription 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>> ListByScopeWithHttpMessagesAsync(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"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // 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, "ListByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/views").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(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 view by view name. + /// + /// + /// + /// View 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 viewName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (viewName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "viewName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("viewName", viewName); + 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.CostManagement/views/{viewName}").ToString(); + _url = _url.Replace("{viewName}", System.Uri.EscapeDataString(viewName)); + 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 view. Update operation requires latest + /// eTag to be set in the request. You may obtain the latest eTag by performing + /// a get operation. Create operation does not require eTag. + /// + /// + /// + /// View name + /// + /// + /// Parameters supplied to the CreateOrUpdate View 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 viewName, View parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (viewName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "viewName"); + } + 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("viewName", viewName); + 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("/") ? "" : "/")), "providers/Microsoft.CostManagement/views/{viewName}").ToString(); + _url = _url.Replace("{viewName}", System.Uri.EscapeDataString(viewName)); + 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 view. + /// + /// + /// + /// View 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 viewName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (viewName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "viewName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("viewName", viewName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.CostManagement/views/{viewName}").ToString(); + _url = _url.Replace("{viewName}", System.Uri.EscapeDataString(viewName)); + 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 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the view for the defined scope by view name. + /// + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View 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> GetByScopeWithHttpMessagesAsync(string scope, string viewName, 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (viewName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "viewName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("viewName", viewName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/views/{viewName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{viewName}", System.Uri.EscapeDataString(viewName)); + 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 view. Update operation requires latest + /// eTag to be set in the request. You may obtain the latest eTag by performing + /// a get operation. Create operation does not require eTag. + /// + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View name + /// + /// + /// Parameters supplied to the CreateOrUpdate View 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> CreateOrUpdateByScopeWithHttpMessagesAsync(string scope, string viewName, View 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (viewName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "viewName"); + } + 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("viewName", viewName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/views/{viewName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{viewName}", System.Uri.EscapeDataString(viewName)); + 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 view. + /// + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View 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 DeleteByScopeWithHttpMessagesAsync(string scope, string viewName, 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 (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (viewName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "viewName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("viewName", viewName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.CostManagement/views/{viewName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{viewName}", System.Uri.EscapeDataString(viewName)); + 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 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all views by tenant and object. + /// + /// + /// + /// 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; + } + + /// + /// Lists all views at the given 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>> ListByScopeNextWithHttpMessagesAsync(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, "ListByScopeNext", 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/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ViewsOperationsExtensions.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ViewsOperationsExtensions.cs new file mode 100644 index 0000000000000..6d5ef2286b39b --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ViewsOperationsExtensions.cs @@ -0,0 +1,563 @@ +// +// 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.CostManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ViewsOperations. + /// + public static partial class ViewsOperationsExtensions + { + /// + /// Lists all views by tenant and object. + /// + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IViewsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all views by tenant and object. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IViewsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all views at the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + public static IPage ListByScope(this IViewsOperations operations, string scope) + { + return operations.ListByScopeAsync(scope).GetAwaiter().GetResult(); + } + + /// + /// Lists all views at the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByScopeAsync(this IViewsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByScopeWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the view by view name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// View name + /// + public static View Get(this IViewsOperations operations, string viewName) + { + return operations.GetAsync(viewName).GetAwaiter().GetResult(); + } + + /// + /// Gets the view by view name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// View name + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IViewsOperations operations, string viewName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(viewName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to create or update a view. Update operation requires latest + /// eTag to be set in the request. You may obtain the latest eTag by performing + /// a get operation. Create operation does not require eTag. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// View name + /// + /// + /// Parameters supplied to the CreateOrUpdate View operation. + /// + public static View CreateOrUpdate(this IViewsOperations operations, string viewName, View parameters) + { + return operations.CreateOrUpdateAsync(viewName, parameters).GetAwaiter().GetResult(); + } + + /// + /// The operation to create or update a view. Update operation requires latest + /// eTag to be set in the request. You may obtain the latest eTag by performing + /// a get operation. Create operation does not require eTag. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// View name + /// + /// + /// Parameters supplied to the CreateOrUpdate View operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IViewsOperations operations, string viewName, View parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(viewName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to delete a view. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// View name + /// + public static void Delete(this IViewsOperations operations, string viewName) + { + operations.DeleteAsync(viewName).GetAwaiter().GetResult(); + } + + /// + /// The operation to delete a view. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// View name + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IViewsOperations operations, string viewName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(viewName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the view for the defined scope by view name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View name + /// + public static View GetByScope(this IViewsOperations operations, string scope, string viewName) + { + return operations.GetByScopeAsync(scope, viewName).GetAwaiter().GetResult(); + } + + /// + /// Gets the view for the defined scope by view name. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View name + /// + /// + /// The cancellation token. + /// + public static async Task GetByScopeAsync(this IViewsOperations operations, string scope, string viewName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetByScopeWithHttpMessagesAsync(scope, viewName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to create or update a view. Update operation requires latest + /// eTag to be set in the request. 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 view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View name + /// + /// + /// Parameters supplied to the CreateOrUpdate View operation. + /// + public static View CreateOrUpdateByScope(this IViewsOperations operations, string scope, string viewName, View parameters) + { + return operations.CreateOrUpdateByScopeAsync(scope, viewName, parameters).GetAwaiter().GetResult(); + } + + /// + /// The operation to create or update a view. Update operation requires latest + /// eTag to be set in the request. 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 view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View name + /// + /// + /// Parameters supplied to the CreateOrUpdate View operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateByScopeAsync(this IViewsOperations operations, string scope, string viewName, View parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateByScopeWithHttpMessagesAsync(scope, viewName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to delete a view. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View name + /// + public static void DeleteByScope(this IViewsOperations operations, string scope, string viewName) + { + operations.DeleteByScopeAsync(scope, viewName).GetAwaiter().GetResult(); + } + + /// + /// The operation to delete a view. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with view 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, + /// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, + /// 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + /// Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + /// for External Billing Account scope and + /// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + /// for External Subscription scope. + /// + /// + /// View name + /// + /// + /// The cancellation token. + /// + public static async Task DeleteByScopeAsync(this IViewsOperations operations, string scope, string viewName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteByScopeWithHttpMessagesAsync(scope, viewName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all views by tenant and object. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IViewsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all views by tenant and object. + /// + /// + /// + /// 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 IViewsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all views at the given scope. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByScopeNext(this IViewsOperations operations, string nextPageLink) + { + return operations.ListByScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all views at the given 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> ListByScopeNextAsync(this IViewsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}