From 6f6ff3f031ca90106163c754bc06395853149262 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 1 Apr 2021 08:57:51 +0000 Subject: [PATCH] CodeGen from PR 13758 in Azure/azure-rest-api-specs Merge 28586cc01fd8dc095c442566784e16617777ec23 into 467bc839e205459f530f4b33e08e57882734a8f5 --- .../src/Generated/AlertsOperations.cs | 863 ++++++++ .../Generated/AlertsOperationsExtensions.cs | 305 +++ .../src/Generated/CostManagementClient.cs | 394 ++++ .../src/Generated/DimensionsOperations.cs | 488 +++++ .../DimensionsOperationsExtensions.cs | 186 ++ .../src/Generated/ExportsOperations.cs | 1286 +++++++++++ .../Generated/ExportsOperationsExtensions.cs | 501 +++++ .../src/Generated/ForecastOperations.cs | 499 +++++ .../Generated/ForecastOperationsExtensions.cs | 183 ++ .../src/Generated/IAlertsOperations.cs | 188 ++ .../src/Generated/ICostManagementClient.cs | 108 + .../src/Generated/IDimensionsOperations.cs | 118 + .../src/Generated/IExportsOperations.cs | 294 +++ .../src/Generated/IForecastOperations.cs | 120 + .../src/Generated/IOperations.cs | 68 + .../src/Generated/IQueryOperations.cs | 105 + .../src/Generated/IViewsOperations.cs | 345 +++ .../src/Generated/Models/AccumulatedType.cs | 22 + .../src/Generated/Models/Alert.cs | 146 ++ .../src/Generated/Models/AlertCategory.cs | 24 + .../src/Generated/Models/AlertCriteria.cs | 34 + .../src/Generated/Models/AlertOperator.cs | 26 + .../Models/AlertPropertiesDefinition.cs | 86 + .../Models/AlertPropertiesDetails.cs | 188 ++ .../src/Generated/Models/AlertSource.cs | 22 + .../src/Generated/Models/AlertStatus.cs | 25 + .../Generated/Models/AlertTimeGrainType.cs | 27 + .../src/Generated/Models/AlertType.cs | 27 + .../src/Generated/Models/AlertsResult.cs | 62 + .../src/Generated/Models/ChartType.cs | 25 + .../Models/CommonExportProperties.cs | 117 + .../src/Generated/Models/Dimension.cs | 121 + .../Generated/Models/DismissAlertPayload.cs | 139 ++ .../src/Generated/Models/ErrorDetails.cs | 60 + .../src/Generated/Models/ErrorResponse.cs | 61 + .../Models/ErrorResponseException.cs | 62 + .../src/Generated/Models/ExecutionStatus.cs | 27 + .../src/Generated/Models/ExecutionType.cs | 22 + .../src/Generated/Models/Export.cs | 139 ++ .../src/Generated/Models/ExportDataset.cs | 63 + .../Models/ExportDatasetConfiguration.cs | 60 + .../src/Generated/Models/ExportDefinition.cs | 114 + .../Models/ExportDeliveryDestination.cs | 98 + .../Generated/Models/ExportDeliveryInfo.cs | 70 + .../src/Generated/Models/ExportExecution.cs | 154 ++ .../Models/ExportExecutionListResult.cs | 53 + .../src/Generated/Models/ExportListResult.cs | 54 + .../Models/ExportRecurrencePeriod.cs | 69 + .../src/Generated/Models/ExportSchedule.cs | 90 + .../src/Generated/Models/ExportTimePeriod.cs | 70 + .../src/Generated/Models/ExportType.cs | 23 + .../Models/ExternalCloudProviderType.cs | 22 + .../src/Generated/Models/ForecastDataset.cs | 113 + .../Generated/Models/ForecastDefinition.cs | 131 ++ .../Generated/Models/ForecastTimeframeType.cs | 26 + .../src/Generated/Models/ForecastType.cs | 23 + .../src/Generated/Models/FormatType.cs | 21 + .../src/Generated/Models/GranularityType.cs | 21 + .../src/Generated/Models/KpiProperties.cs | 69 + .../src/Generated/Models/KpiTypeType.cs | 22 + .../src/Generated/Models/MetricType.cs | 23 + .../src/Generated/Models/Operation.cs | 61 + .../src/Generated/Models/OperationDisplay.cs | 71 + .../src/Generated/Models/OperatorType.cs | 22 + .../src/Generated/Models/Page.cs | 53 + .../src/Generated/Models/Page1.cs | 53 + .../src/Generated/Models/PivotProperties.cs | 61 + .../src/Generated/Models/PivotTypeType.cs | 22 + .../src/Generated/Models/ProxyResource.cs | 81 + .../src/Generated/Models/QueryAggregation.cs | 78 + .../src/Generated/Models/QueryColumn.cs | 56 + .../src/Generated/Models/QueryColumnType.cs | 22 + .../Models/QueryComparisonExpression.cs | 100 + .../src/Generated/Models/QueryDataset.cs | 137 ++ .../Models/QueryDatasetConfiguration.cs | 57 + .../src/Generated/Models/QueryDefinition.cs | 112 + .../src/Generated/Models/QueryFilter.cs | 140 ++ .../src/Generated/Models/QueryGrouping.cs | 79 + .../src/Generated/Models/QueryResult.cs | 79 + .../src/Generated/Models/QueryTimePeriod.cs | 70 + .../src/Generated/Models/RecurrenceType.cs | 24 + .../Models/ReportConfigAggregation.cs | 78 + .../Models/ReportConfigColumnType.cs | 22 + .../ReportConfigComparisonExpression.cs | 103 + .../Generated/Models/ReportConfigDataset.cs | 156 ++ .../ReportConfigDatasetConfiguration.cs | 59 + .../Generated/Models/ReportConfigFilter.cs | 140 ++ .../Generated/Models/ReportConfigGrouping.cs | 81 + .../Generated/Models/ReportConfigSorting.cs | 75 + .../Models/ReportConfigTimePeriod.cs | 70 + .../Generated/Models/ReportGranularityType.cs | 22 + .../Generated/Models/ReportTimeframeType.cs | 24 + .../src/Generated/Models/Resource.cs | 79 + .../src/Generated/Models/StatusType.cs | 22 + .../src/Generated/Models/TimeframeType.cs | 26 + .../src/Generated/Models/View.cs | 245 +++ .../src/Generated/Operations.cs | 390 ++++ .../src/Generated/OperationsExtensions.cs | 87 + .../src/Generated/QueryOperations.cs | 477 ++++ .../Generated/QueryOperationsExtensions.cs | 159 ++ .../Generated/SdkInfo_CostManagementClient.cs | 33 + .../src/Generated/ViewsOperations.cs | 1944 +++++++++++++++++ .../Generated/ViewsOperationsExtensions.cs | 563 +++++ 103 files changed, 15135 insertions(+) create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/AlertsOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/AlertsOperationsExtensions.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/CostManagementClient.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/DimensionsOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/DimensionsOperationsExtensions.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ExportsOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ExportsOperationsExtensions.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ForecastOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ForecastOperationsExtensions.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IAlertsOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ICostManagementClient.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IDimensionsOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IExportsOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IForecastOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IQueryOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IViewsOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AccumulatedType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Alert.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertCategory.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertCriteria.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertOperator.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertPropertiesDefinition.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertPropertiesDetails.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertSource.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertStatus.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertTimeGrainType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertsResult.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ChartType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CommonExportProperties.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Dimension.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DismissAlertPayload.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorDetails.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorResponse.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ErrorResponseException.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExecutionStatus.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExecutionType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Export.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDataset.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDatasetConfiguration.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDefinition.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDeliveryDestination.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDeliveryInfo.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportExecution.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportExecutionListResult.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportListResult.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportRecurrencePeriod.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportSchedule.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportTimePeriod.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExternalCloudProviderType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDataset.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDefinition.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimeframeType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/FormatType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/GranularityType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/KpiProperties.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/KpiTypeType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/MetricType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Operation.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationDisplay.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperatorType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Page.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Page1.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PivotProperties.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/PivotTypeType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ProxyResource.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryAggregation.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryColumn.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryColumnType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryComparisonExpression.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDataset.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDatasetConfiguration.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDefinition.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryFilter.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryGrouping.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryResult.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryTimePeriod.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/RecurrenceType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigAggregation.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigColumnType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigComparisonExpression.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigDataset.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigDatasetConfiguration.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigFilter.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigGrouping.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigSorting.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigTimePeriod.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportGranularityType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportTimeframeType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Resource.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/StatusType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/TimeframeType.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/View.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Operations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/OperationsExtensions.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperationsExtensions.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/SdkInfo_CostManagementClient.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ViewsOperations.cs create mode 100644 sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ViewsOperationsExtensions.cs 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..c4e3b5d5022e2 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/AlertsOperations.cs @@ -0,0 +1,863 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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 (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 (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 (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 (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/CostManagementClient.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/CostManagementClient.cs new file mode 100644 index 0000000000000..f9dd3acf03231 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/CostManagementClient.cs @@ -0,0 +1,394 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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; + + 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; } + + /// + /// Version of the API to be used with the client request. The current version + /// is 2020-06-01. + /// + 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 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 IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IExportsOperations. + /// + public virtual IExportsOperations Exports { 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() + { + Views = new ViewsOperations(this); + Alerts = new AlertsOperations(this); + Forecast = new ForecastOperations(this); + Dimensions = new DimensionsOperations(this); + Query = new QueryOperations(this); + Operations = new Operations(this); + Exports = new ExportsOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2020-06-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() + } + }; + 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..c6dd2a31ded42 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/DimensionsOperations.cs @@ -0,0 +1,488 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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"); + } + // 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) + { + 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"); + } + // 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..43866f6053c56 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ExportsOperations.cs @@ -0,0 +1,1286 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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 + /// execution 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"); + } + // 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 + /// executions 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 (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 (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 (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 execute 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 (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 execution 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 (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..549c59e09147a --- /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 + /// execution 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 + /// execution 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 + /// executions 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 + /// executions 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 execute 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 execute 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 execution 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 execution 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..02a464f11043e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ForecastOperations.cs @@ -0,0 +1,499 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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 (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) + { + 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 (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..e2b8ed6bee3b5 --- /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 QueryResult 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 QueryResult 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/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/ICostManagementClient.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ICostManagementClient.cs new file mode 100644 index 0000000000000..7357f2279ae78 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ICostManagementClient.cs @@ -0,0 +1,108 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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; + + /// + /// + 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; } + + /// + /// Version of the API to be used with the client request. The current + /// version is 2020-06-01. + /// + 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 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 IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IExportsOperations. + /// + IExportsOperations Exports { 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..1ada67441e6dc --- /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 execution 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 executions 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 execute 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 execution 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..b6de521772d09 --- /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/IOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/IOperations.cs new file mode 100644 index 0000000000000..40f06071f8b9e --- /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/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/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/Alert.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Alert.cs new file mode 100644 index 0000000000000..348cba42ffadc --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Alert.cs @@ -0,0 +1,146 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An individual alert. + /// + [Rest.Serialization.JsonTransformation] + public partial class Alert : Resource + { + /// + /// 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. + /// Resource tags. + /// 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 + /// dateTime in which the alert + /// status was last modified + public Alert(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), 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, tags) + { + 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; } + + /// + /// + [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..1a8abb2c74c7e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/AlertPropertiesDetails.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.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 + 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)) + { + 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; + 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; } + + } +} 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/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/CommonExportProperties.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CommonExportProperties.cs new file mode 100644 index 0000000000000..155f4e973ae93 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/CommonExportProperties.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 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 + /// execution history for the export. + /// If the export has an active + /// schedule, provides an estimate of the next execution time. + public CommonExportProperties(ExportDeliveryInfo deliveryInfo, ExportDefinition definition, string format = default(string), ExportExecutionListResult runHistory = default(ExportExecutionListResult), System.DateTime? nextRunTimeEstimate = default(System.DateTime?)) + { + Format = format; + DeliveryInfo = deliveryInfo; + Definition = definition; + RunHistory = runHistory; + 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 execution history + /// for the export. + /// + [JsonProperty(PropertyName = "runHistory")] + public ExportExecutionListResult RunHistory { get; set; } + + /// + /// Gets if the export has an active schedule, provides an estimate of + /// the next execution 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/Dimension.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Dimension.cs new file mode 100644 index 0000000000000..bedc1db5737d9 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Dimension.cs @@ -0,0 +1,121 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + [Rest.Serialization.JsonTransformation] + public partial class Dimension : Resource + { + /// + /// 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. + /// Resource tags. + /// Dimension description. + /// Filter enabled. + /// Grouping enabled. + /// 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), 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, 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; } + + /// + /// + [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..22f928d9f462a --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/DismissAlertPayload.cs @@ -0,0 +1,139 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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 + /// 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; } + + /// + /// + [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/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..d274c13e85f2e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Export.cs @@ -0,0 +1,139 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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 : ProxyResource + { + /// + /// 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 + /// execution history for the export. + /// If the export has an active + /// schedule, provides an estimate of the next execution 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), System.DateTime? nextRunTimeEstimate = default(System.DateTime?), ExportSchedule schedule = default(ExportSchedule)) + : base(id, name, type, eTag) + { + Format = format; + DeliveryInfo = deliveryInfo; + Definition = definition; + RunHistory = runHistory; + 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 execution history + /// for the export. + /// + [JsonProperty(PropertyName = "properties.runHistory")] + public ExportExecutionListResult RunHistory { get; set; } + + /// + /// Gets if the export has an active schedule, provides an estimate of + /// the next execution 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..59ebff5a5c10e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportDeliveryDestination.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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 destination information for the delivery of the export. To allow + /// access to a storage account, you must register the account's + /// subscription with the Microsoft.CostManagementExports resource + /// provider. This is required once per subscription. When creating an + /// export in the Azure portal, it is done automatically, however API users + /// need to register the subscription. For more information see + /// https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services + /// . + /// + public partial class ExportDeliveryDestination + { + /// + /// Initializes a new instance of the ExportDeliveryDestination class. + /// + public ExportDeliveryDestination() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportDeliveryDestination class. + /// + /// The resource id of the storage account + /// where exports will be delivered. + /// The name of the container where exports + /// will be uploaded. + /// The name of the directory where + /// exports will be uploaded. + public ExportDeliveryDestination(string resourceId, string container, string rootFolderPath = default(string)) + { + ResourceId = resourceId; + Container = container; + RootFolderPath = rootFolderPath; + 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. + /// + [JsonProperty(PropertyName = "resourceId")] + public string ResourceId { get; set; } + + /// + /// Gets or sets the name of the container where exports will be + /// uploaded. + /// + [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; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ResourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ResourceId"); + } + 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/ExportExecution.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportExecution.cs new file mode 100644 index 0000000000000..24c31aaeea5ba --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportExecution.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.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// An export execution. + /// + [Rest.Serialization.JsonTransformation] + public partial class ExportExecution : ProxyResource + { + /// + /// Initializes a new instance of the ExportExecution class. + /// + public ExportExecution() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportExecution 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 execution. + /// Possible values include: 'OnDemand', 'Scheduled' + /// The last known status of the export execution. + /// Possible values include: 'Queued', 'InProgress', 'Completed', + /// 'Failed', 'Timeout', 'NewDataNotAvailable', + /// 'DataNotAvailable' + /// The identifier for the entity that + /// executed the export. For OnDemand executions it is the user email. + /// For scheduled executions it is 'System'. + /// The time when export was queued to be + /// executed. + /// The time when export was picked + /// up to be executed. + /// The time when the export execution + /// finished. + /// The name of the exported file. + /// The export settings that were in effect + /// for this execution. + /// The details of any error. + public ExportExecution(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 execution. Possible values + /// include: 'OnDemand', 'Scheduled' + /// + [JsonProperty(PropertyName = "properties.executionType")] + public string ExecutionType { get; set; } + + /// + /// Gets or sets the last known status of the export execution. + /// 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 executed the + /// export. For OnDemand executions it is the user email. For scheduled + /// executions it is 'System'. + /// + [JsonProperty(PropertyName = "properties.submittedBy")] + public string SubmittedBy { get; set; } + + /// + /// Gets or sets the time when export was queued to be executed. + /// + [JsonProperty(PropertyName = "properties.submittedTime")] + public System.DateTime? SubmittedTime { get; set; } + + /// + /// Gets or sets the time when export was picked up to be executed. + /// + [JsonProperty(PropertyName = "properties.processingStartTime")] + public System.DateTime? ProcessingStartTime { get; set; } + + /// + /// Gets or sets the time when the export execution 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 + /// execution. + /// + [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/ExportExecutionListResult.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ExportExecutionListResult.cs new file mode 100644 index 0000000000000..eae775f5804c3 --- /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 execution 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 executions. + 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 executions. + /// + [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/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/ForecastDataset.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDataset.cs new file mode 100644 index 0000000000000..8dfb0f731cb35 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastDataset.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.Models +{ + 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. + /// + /// 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. + /// 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. + /// Has filter expression to use in the + /// forecast. + public ForecastDataset(string granularity = default(string), QueryDatasetConfiguration configuration = default(QueryDatasetConfiguration), IDictionary aggregation = default(IDictionary), QueryFilter filter = default(QueryFilter)) + { + 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 QueryDatasetConfiguration 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 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 (Filter != null) + { + Filter.Validate(); + } + } + } +} 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..992a19dcbf170 --- /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() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ForecastDefinition class. + /// + /// The type of the forecast. Possible values + /// include: 'Usage', 'ActualCost', 'AmortizedCost' + /// The time frame for pulling data for the + /// forecast. 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 + /// forecast. + /// Has definition for data in this + /// forecast. + /// a boolean determining if actualCost + /// will be included + /// a boolean determining if + /// FreshPartialCost will be included + public ForecastDefinition(string type, string timeframe, QueryTimePeriod timePeriod = default(QueryTimePeriod), ForecastDataset dataset = default(ForecastDataset), bool? includeActualCost = default(bool?), bool? includeFreshPartialCost = default(bool?)) + { + Type = type; + Timeframe = timeframe; + TimePeriod = timePeriod; + Dataset = dataset; + IncludeActualCost = includeActualCost; + IncludeFreshPartialCost = includeFreshPartialCost; + CustomInit(); + } + + /// + /// 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 the time frame for pulling data for the forecast. 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 forecast. + /// + [JsonProperty(PropertyName = "timePeriod")] + public QueryTimePeriod 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; } + + /// + /// 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(); + } + if (Dataset != null) + { + Dataset.Validate(); + } + } + } +} diff --git a/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimeframeType.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimeframeType.cs new file mode 100644 index 0000000000000..96a2bda5b97b3 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ForecastTimeframeType.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 ForecastTimeframeType. + /// + public static class ForecastTimeframeType + { + 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/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/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/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/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/Operation.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Operation.cs new file mode 100644 index 0000000000000..bed6fe698a613 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Operation.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; + + /// + /// A Cost management REST API operation. + /// + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + /// Operation name: + /// {provider}/{resource}/{operation}. + /// The object that represents the + /// operation. + public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay)) + { + Name = name; + Display = display; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets operation name: {provider}/{resource}/{operation}. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the object that represents the operation. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; 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..b8731cf3636b7 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/OperationDisplay.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CostManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The object that represents the operation. + /// + public partial class OperationDisplay + { + /// + /// Initializes a new instance of the OperationDisplay class. + /// + public OperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplay class. + /// + /// Service provider: + /// Microsoft.CostManagement. + /// Resource on which the operation is + /// performed: Dimensions, Query. + /// Operation type: Read, write, delete, + /// etc. + public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string)) + { + Provider = provider; + Resource = resource; + Operation = operation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets service provider: Microsoft.CostManagement. + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; private set; } + + /// + /// Gets resource on which the operation is performed: Dimensions, + /// Query. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; private set; } + + /// + /// Gets operation type: Read, write, delete, etc. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; private set; } + + } +} 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/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/ProxyResource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ProxyResource.cs new file mode 100644 index 0000000000000..d38be096c86a3 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ProxyResource.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 Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The Resource model definition. + /// + public partial class ProxyResource : IResource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource 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 ProxyResource(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/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..ae1335336a584 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryColumn.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; + + 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..87acc81ccf02e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDataset.cs @@ -0,0 +1,137 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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. + /// Has filter expression to use in the + /// query. + 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 has filter expression to use in the query. + /// + [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..e889bfe1712d8 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryDefinition.cs @@ -0,0 +1,112 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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() + { + 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 time period for pulling data for the + /// query. + /// Has definition for data in this + /// query. + public QueryDefinition(string type, string timeframe, QueryTimePeriod timePeriod = default(QueryTimePeriod), QueryDataset dataset = default(QueryDataset)) + { + 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 (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..88ac8eb310b4c --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryFilter.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 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. + /// The logical "NOT" expression. + /// Has comparison expression for a + /// dimension + /// Has comparison expression for a tag + public QueryFilter(IList and = default(IList), IList or = default(IList), QueryFilter not = default(QueryFilter), QueryComparisonExpression dimension = default(QueryComparisonExpression), QueryComparisonExpression tag = default(QueryComparisonExpression)) + { + And = and; + Or = or; + Not = not; + Dimension = dimension; + Tag = tag; + 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 the logical "NOT" expression. + /// + [JsonProperty(PropertyName = "not")] + public QueryFilter Not { get; set; } + + /// + /// Gets or sets has comparison expression for a dimension + /// + [JsonProperty(PropertyName = "dimension")] + public QueryComparisonExpression Dimension { get; set; } + + /// + /// Gets or sets has comparison expression for a tag + /// + [JsonProperty(PropertyName = "tag")] + public QueryComparisonExpression Tag { 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 (Not != null) + { + Not.Validate(); + } + if (Dimension != null) + { + Dimension.Validate(); + } + if (Tag != null) + { + Tag.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..237f71770e472 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/QueryResult.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.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 : Resource + { + /// + /// 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. + /// 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), IDictionary tags = default(IDictionary), string nextLink = default(string), IList columns = default(IList), IList> rows = default(IList>)) + : base(id, name, type, 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/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..501c07680265d --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/ReportConfigFilter.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 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. + /// The logical "NOT" expression. + /// Has comparison expression for a + /// dimension + /// Has comparison expression for a tag + public ReportConfigFilter(IList and = default(IList), IList or = default(IList), ReportConfigFilter not = default(ReportConfigFilter), ReportConfigComparisonExpression dimension = default(ReportConfigComparisonExpression), ReportConfigComparisonExpression tag = default(ReportConfigComparisonExpression)) + { + And = and; + Or = or; + Not = not; + Dimension = dimension; + Tag = tag; + 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 the logical "NOT" expression. + /// + [JsonProperty(PropertyName = "not")] + public ReportConfigFilter Not { get; set; } + + /// + /// Gets or sets has comparison expression for a dimension + /// + [JsonProperty(PropertyName = "dimension")] + public ReportConfigComparisonExpression Dimension { get; set; } + + /// + /// Gets or sets has comparison expression for a tag + /// + [JsonProperty(PropertyName = "tag")] + public ReportConfigComparisonExpression Tag { 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 (Not != null) + { + Not.Validate(); + } + if (Dimension != null) + { + Dimension.Validate(); + } + if (Tag != null) + { + Tag.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/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/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/Resource.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/Resource.cs new file mode 100644 index 0000000000000..c6dbf27e4db33 --- /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.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The Resource model definition. + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + public Resource(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + 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 resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; private 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/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/View.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/View.cs new file mode 100644 index 0000000000000..af80e43c9a91c --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Models/View.cs @@ -0,0 +1,245 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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 : ProxyResource + { + /// + /// 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. + /// Has time period for pulling data for the + /// report. + /// Has definition for data in this report + /// config. + /// 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?), ReportConfigTimePeriod timePeriod = default(ReportConfigTimePeriod), ReportConfigDataset dataset = default(ReportConfigDataset), 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; + Timeframe = timeframe; + TimePeriod = timePeriod; + Dataset = dataset; + 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 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 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/Operations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Operations.cs new file mode 100644 index 0000000000000..543e92a76ccd1 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/Operations.cs @@ -0,0 +1,390 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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"); + } + // 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..ca66a0020fdd1 --- /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/QueryOperations.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperations.cs new file mode 100644 index 0000000000000..8cbee05d37f3f --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/QueryOperations.cs @@ -0,0 +1,477 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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 (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) + { + 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 (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/SdkInfo_CostManagementClient.cs b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/SdkInfo_CostManagementClient.cs new file mode 100644 index 0000000000000..13d787479829e --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/SdkInfo_CostManagementClient.cs @@ -0,0 +1,33 @@ + +// +// Code generated 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("CostManagement", "Alerts", "2020-06-01"), + new Tuple("CostManagement", "Dimensions", "2020-06-01"), + new Tuple("CostManagement", "Exports", "2020-06-01"), + new Tuple("CostManagement", "Forecast", "2020-06-01"), + new Tuple("CostManagement", "Operations", "2020-06-01"), + new Tuple("CostManagement", "Query", "2020-06-01"), + new Tuple("CostManagement", "Views", "2020-06-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..f13c10f809fc9 --- /dev/null +++ b/sdk/cost-management/Microsoft.Azure.Management.CostManagement/src/Generated/ViewsOperations.cs @@ -0,0 +1,1944 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated 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"); + } + // 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"); + } + // 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 (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 (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 (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 (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 (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 (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; + } + } + + } +}