From b4e2c3bc8f3e849b66e77342c42498e2455e1589 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Thu, 14 May 2020 01:01:15 +0000 Subject: [PATCH] Generated from 56fa09b4747cbadec3d17b44a01885dbe5df7e26 prettifying --- .../Generated/ConsumptionManagementClient.cs | 6 + .../Generated/IConsumptionManagementClient.cs | 5 + ...ervationRecommendationDetailsOperations.cs | 58 +++++ ...ationDetailsCalculatedSavingsProperties.cs | 99 ++++++++ .../ReservationRecommendationDetailsModel.cs | 108 ++++++++ ...RecommendationDetailsResourceProperties.cs | 99 ++++++++ ...nRecommendationDetailsSavingsProperties.cs | 99 ++++++++ ...ionRecommendationDetailsUsageProperties.cs | 100 ++++++++ ...ervationRecommendationDetailsOperations.cs | 239 ++++++++++++++++++ ...commendationDetailsOperationsExtensions.cs | 75 ++++++ .../SdkInfo_ConsumptionManagementClient.cs | 1 + 11 files changed, 889 insertions(+) create mode 100644 sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/IReservationRecommendationDetailsOperations.cs create mode 100644 sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsCalculatedSavingsProperties.cs create mode 100644 sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsModel.cs create mode 100644 sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsResourceProperties.cs create mode 100644 sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsSavingsProperties.cs create mode 100644 sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsUsageProperties.cs create mode 100644 sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ReservationRecommendationDetailsOperations.cs create mode 100644 sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ReservationRecommendationDetailsOperationsExtensions.cs diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ConsumptionManagementClient.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ConsumptionManagementClient.cs index 40838c5b8565..a995a8152025 100644 --- a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ConsumptionManagementClient.cs +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ConsumptionManagementClient.cs @@ -121,6 +121,11 @@ public partial class ConsumptionManagementClient : ServiceClient public virtual IReservationRecommendationsOperations ReservationRecommendations { get; private set; } + /// + /// Gets the IReservationRecommendationDetailsOperations. + /// + public virtual IReservationRecommendationDetailsOperations ReservationRecommendationDetails { get; private set; } + /// /// Gets the IReservationTransactionsOperations. /// @@ -411,6 +416,7 @@ private void Initialize() ReservationsSummaries = new ReservationsSummariesOperations(this); ReservationsDetails = new ReservationsDetailsOperations(this); ReservationRecommendations = new ReservationRecommendationsOperations(this); + ReservationRecommendationDetails = new ReservationRecommendationDetailsOperations(this); ReservationTransactions = new ReservationTransactionsOperations(this); PriceSheet = new PriceSheetOperations(this); Forecasts = new ForecastsOperations(this); diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/IConsumptionManagementClient.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/IConsumptionManagementClient.cs index baeab3127236..b249b8cbfabc 100644 --- a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/IConsumptionManagementClient.cs +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/IConsumptionManagementClient.cs @@ -116,6 +116,11 @@ public partial interface IConsumptionManagementClient : System.IDisposable /// IReservationRecommendationsOperations ReservationRecommendations { get; } + /// + /// Gets the IReservationRecommendationDetailsOperations. + /// + IReservationRecommendationDetailsOperations ReservationRecommendationDetails { get; } + /// /// Gets the IReservationTransactionsOperations. /// diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/IReservationRecommendationDetailsOperations.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/IReservationRecommendationDetailsOperations.cs new file mode 100644 index 000000000000..d6c27c830867 --- /dev/null +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/IReservationRecommendationDetailsOperations.cs @@ -0,0 +1,58 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ReservationRecommendationDetailsOperations operations. + /// + public partial interface IReservationRecommendationDetailsOperations + { + /// + /// Details of a reservation recommendation for what-if analysis of + /// reserved instances. + /// + /// + /// + /// The scope associated with reservation recommendation details + /// operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}', + /// /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for BillingAccount scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile 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> GetWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsCalculatedSavingsProperties.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsCalculatedSavingsProperties.cs new file mode 100644 index 000000000000..1a74a769fa3a --- /dev/null +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsCalculatedSavingsProperties.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details of estimated savings. + /// + public partial class ReservationRecommendationDetailsCalculatedSavingsProperties + { + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsCalculatedSavingsProperties class. + /// + public ReservationRecommendationDetailsCalculatedSavingsProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsCalculatedSavingsProperties class. + /// + /// The cost without reservation. + /// The difference between total reservation + /// cost and reservation cost. + /// The quantity for calculated savings. + /// The exact cost of the estimated usage + /// using reservation. + /// The cost of the suggested + /// quantity. + /// The amount saved by purchasing the + /// recommended quantity of reservation. + public ReservationRecommendationDetailsCalculatedSavingsProperties(double? onDemandCost = default(double?), double? overageCost = default(double?), double? quantity = default(double?), double? reservationCost = default(double?), double? totalReservationCost = default(double?), double? savings = default(double?)) + { + OnDemandCost = onDemandCost; + OverageCost = overageCost; + Quantity = quantity; + ReservationCost = reservationCost; + TotalReservationCost = totalReservationCost; + Savings = savings; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the cost without reservation. + /// + [JsonProperty(PropertyName = "onDemandCost")] + public double? OnDemandCost { get; private set; } + + /// + /// Gets the difference between total reservation cost and reservation + /// cost. + /// + [JsonProperty(PropertyName = "overageCost")] + public double? OverageCost { get; private set; } + + /// + /// Gets the quantity for calculated savings. + /// + [JsonProperty(PropertyName = "quantity")] + public double? Quantity { get; private set; } + + /// + /// Gets the exact cost of the estimated usage using reservation. + /// + [JsonProperty(PropertyName = "reservationCost")] + public double? ReservationCost { get; private set; } + + /// + /// Gets the cost of the suggested quantity. + /// + [JsonProperty(PropertyName = "totalReservationCost")] + public double? TotalReservationCost { get; private set; } + + /// + /// Gets the amount saved by purchasing the recommended quantity of + /// reservation. + /// + [JsonProperty(PropertyName = "savings")] + public double? Savings { get; private set; } + + } +} diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsModel.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsModel.cs new file mode 100644 index 000000000000..37404f69195c --- /dev/null +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsModel.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.Consumption.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Reservation recommendation details. + /// + [Rest.Serialization.JsonTransformation] + public partial class ReservationRecommendationDetailsModel : Resource + { + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsModel class. + /// + public ReservationRecommendationDetailsModel() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsModel class. + /// + /// Resource Id. + /// Resource name. + /// Resource type. + /// Resource tags. + /// An ISO 4217 currency code identifier for the + /// costs and savings + /// Resource specific properties. + /// Resource Group. + /// Savings information for the + /// recommendation. + /// Scope of the reservation, ex: Single or + /// Shared. + /// Historical usage details used to calculate the + /// estimated savings. + public ReservationRecommendationDetailsModel(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string currency = default(string), ReservationRecommendationDetailsResourceProperties resource = default(ReservationRecommendationDetailsResourceProperties), string resourceGroup = default(string), ReservationRecommendationDetailsSavingsProperties savings = default(ReservationRecommendationDetailsSavingsProperties), string scope = default(string), ReservationRecommendationDetailsUsageProperties usage = default(ReservationRecommendationDetailsUsageProperties)) + : base(id, name, type, tags) + { + Currency = currency; + Resource = resource; + ResourceGroup = resourceGroup; + Savings = savings; + Scope = scope; + Usage = usage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets an ISO 4217 currency code identifier for the costs and savings + /// + [JsonProperty(PropertyName = "properties.currency")] + public string Currency { get; private set; } + + /// + /// Gets resource specific properties. + /// + [JsonProperty(PropertyName = "properties.resource")] + public ReservationRecommendationDetailsResourceProperties Resource { get; private set; } + + /// + /// Gets resource Group. + /// + [JsonProperty(PropertyName = "properties.resourceGroup")] + public string ResourceGroup { get; private set; } + + /// + /// Gets savings information for the recommendation. + /// + [JsonProperty(PropertyName = "properties.savings")] + public ReservationRecommendationDetailsSavingsProperties Savings { get; private set; } + + /// + /// Gets scope of the reservation, ex: Single or Shared. + /// + [JsonProperty(PropertyName = "properties.scope")] + public string Scope { get; private set; } + + /// + /// Gets historical usage details used to calculate the estimated + /// savings. + /// + [JsonProperty(PropertyName = "properties.usage")] + public ReservationRecommendationDetailsUsageProperties Usage { get; private set; } + + } +} diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsResourceProperties.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsResourceProperties.cs new file mode 100644 index 000000000000..de7d4fe2d500 --- /dev/null +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsResourceProperties.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Details of the resource. + /// + public partial class ReservationRecommendationDetailsResourceProperties + { + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsResourceProperties class. + /// + public ReservationRecommendationDetailsResourceProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsResourceProperties class. + /// + /// List of subscriptions for which the + /// reservation is applied. + /// On demand rate of the resource. + /// Azure product ex: Standard_E8s_v3 + /// etc. + /// Azure resource region ex:EastUS, WestUS + /// etc. + /// Reservation rate of the + /// resource. + /// The azure resource type. + public ReservationRecommendationDetailsResourceProperties(IList appliedScopes = default(IList), double? onDemandRate = default(double?), string product = default(string), string region = default(string), double? reservationRate = default(double?), string resourceType = default(string)) + { + AppliedScopes = appliedScopes; + OnDemandRate = onDemandRate; + Product = product; + Region = region; + ReservationRate = reservationRate; + ResourceType = resourceType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of subscriptions for which the reservation is applied. + /// + [JsonProperty(PropertyName = "appliedScopes")] + public IList AppliedScopes { get; private set; } + + /// + /// Gets on demand rate of the resource. + /// + [JsonProperty(PropertyName = "onDemandRate")] + public double? OnDemandRate { get; private set; } + + /// + /// Gets azure product ex: Standard_E8s_v3 etc. + /// + [JsonProperty(PropertyName = "product")] + public string Product { get; private set; } + + /// + /// Gets azure resource region ex:EastUS, WestUS etc. + /// + [JsonProperty(PropertyName = "region")] + public string Region { get; private set; } + + /// + /// Gets reservation rate of the resource. + /// + [JsonProperty(PropertyName = "reservationRate")] + public double? ReservationRate { get; private set; } + + /// + /// Gets the azure resource type. + /// + [JsonProperty(PropertyName = "resourceType")] + public string ResourceType { get; private set; } + + } +} diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsSavingsProperties.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsSavingsProperties.cs new file mode 100644 index 000000000000..ea622863e0e9 --- /dev/null +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsSavingsProperties.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Details of the estimated savings. + /// + public partial class ReservationRecommendationDetailsSavingsProperties + { + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsSavingsProperties class. + /// + public ReservationRecommendationDetailsSavingsProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsSavingsProperties class. + /// + /// List of calculated savings. + /// Number of days of usage to look back + /// used for computing the recommendation. + /// Number of recommended units of + /// the resource. + /// Term period of the reservation, + /// ex: P1Y or P3Y. + /// Type of savings, ex: instance. + /// Measurement unit ex: hour etc. + public ReservationRecommendationDetailsSavingsProperties(IList calculatedSavings = default(IList), int? lookBackPeriod = default(int?), double? recommendedQuantity = default(double?), string reservationOrderTerm = default(string), string savingsType = default(string), string unitOfMeasure = default(string)) + { + CalculatedSavings = calculatedSavings; + LookBackPeriod = lookBackPeriod; + RecommendedQuantity = recommendedQuantity; + ReservationOrderTerm = reservationOrderTerm; + SavingsType = savingsType; + UnitOfMeasure = unitOfMeasure; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of calculated savings. + /// + [JsonProperty(PropertyName = "calculatedSavings")] + public IList CalculatedSavings { get; set; } + + /// + /// Gets number of days of usage to look back used for computing the + /// recommendation. + /// + [JsonProperty(PropertyName = "lookBackPeriod")] + public int? LookBackPeriod { get; private set; } + + /// + /// Gets number of recommended units of the resource. + /// + [JsonProperty(PropertyName = "recommendedQuantity")] + public double? RecommendedQuantity { get; private set; } + + /// + /// Gets term period of the reservation, ex: P1Y or P3Y. + /// + [JsonProperty(PropertyName = "reservationOrderTerm")] + public string ReservationOrderTerm { get; private set; } + + /// + /// Gets type of savings, ex: instance. + /// + [JsonProperty(PropertyName = "savingsType")] + public string SavingsType { get; private set; } + + /// + /// Gets measurement unit ex: hour etc. + /// + [JsonProperty(PropertyName = "unitOfMeasure")] + public string UnitOfMeasure { get; private set; } + + } +} diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsUsageProperties.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsUsageProperties.cs new file mode 100644 index 000000000000..8c03e54915dc --- /dev/null +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/Models/ReservationRecommendationDetailsUsageProperties.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.Consumption.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Details about historical usage data that has been used for computing + /// the recommendation. + /// + public partial class ReservationRecommendationDetailsUsageProperties + { + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsUsageProperties class. + /// + public ReservationRecommendationDetailsUsageProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ReservationRecommendationDetailsUsageProperties class. + /// + /// The first usage date used for + /// looking back for computing the recommendation. + /// The last usage date used for + /// looking back for computing the recommendation. + /// What the usage data values represent + /// ex: virtual machine instance. + /// The breakdown of historical resource usage. + /// The values are in the order of usage between the + /// firstConsumptionDate and the lastConsumptionDate. + /// The grain of the values represented in the + /// usage data ex: hourly. + public ReservationRecommendationDetailsUsageProperties(string firstConsumptionDate = default(string), string lastConsumptionDate = default(string), string lookBackUnitType = default(string), IList usageData = default(IList), string usageGrain = default(string)) + { + FirstConsumptionDate = firstConsumptionDate; + LastConsumptionDate = lastConsumptionDate; + LookBackUnitType = lookBackUnitType; + UsageData = usageData; + UsageGrain = usageGrain; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the first usage date used for looking back for computing the + /// recommendation. + /// + [JsonProperty(PropertyName = "firstConsumptionDate")] + public string FirstConsumptionDate { get; private set; } + + /// + /// Gets the last usage date used for looking back for computing the + /// recommendation. + /// + [JsonProperty(PropertyName = "lastConsumptionDate")] + public string LastConsumptionDate { get; private set; } + + /// + /// Gets what the usage data values represent ex: virtual machine + /// instance. + /// + [JsonProperty(PropertyName = "lookBackUnitType")] + public string LookBackUnitType { get; private set; } + + /// + /// Gets the breakdown of historical resource usage. The values are in + /// the order of usage between the firstConsumptionDate and the + /// lastConsumptionDate. + /// + [JsonProperty(PropertyName = "usageData")] + public IList UsageData { get; private set; } + + /// + /// Gets the grain of the values represented in the usage data ex: + /// hourly. + /// + [JsonProperty(PropertyName = "usageGrain")] + public string UsageGrain { get; private set; } + + } +} diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ReservationRecommendationDetailsOperations.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ReservationRecommendationDetailsOperations.cs new file mode 100644 index 000000000000..59b97bb05a31 --- /dev/null +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ReservationRecommendationDetailsOperations.cs @@ -0,0 +1,239 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ReservationRecommendationDetailsOperations operations. + /// + internal partial class ReservationRecommendationDetailsOperations : IServiceOperations, IReservationRecommendationDetailsOperations + { + /// + /// Initializes a new instance of the ReservationRecommendationDetailsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ReservationRecommendationDetailsOperations(ConsumptionManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ConsumptionManagementClient + /// + public ConsumptionManagementClient Client { get; private set; } + + /// + /// Details of a reservation recommendation for what-if analysis of reserved + /// instances. + /// + /// + /// + /// The scope associated with reservation recommendation details operations. + /// This includes '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}', + /// /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// BillingAccount scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile 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> GetWithHttpMessagesAsync(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, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Consumption/reservationRecommendationDetails").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 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ReservationRecommendationDetailsOperationsExtensions.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ReservationRecommendationDetailsOperationsExtensions.cs new file mode 100644 index 000000000000..82cd6dc7c588 --- /dev/null +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/ReservationRecommendationDetailsOperationsExtensions.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.Consumption +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ReservationRecommendationDetailsOperations. + /// + public static partial class ReservationRecommendationDetailsOperationsExtensions + { + /// + /// Details of a reservation recommendation for what-if analysis of reserved + /// instances. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with reservation recommendation details operations. + /// This includes '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}', + /// /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// BillingAccount scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope + /// + public static ReservationRecommendationDetailsModel Get(this IReservationRecommendationDetailsOperations operations, string scope) + { + return operations.GetAsync(scope).GetAwaiter().GetResult(); + } + + /// + /// Details of a reservation recommendation for what-if analysis of reserved + /// instances. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope associated with reservation recommendation details operations. + /// This includes '/subscriptions/{subscriptionId}/' for subscription scope, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}', + /// /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + /// BillingAccount scope, and + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for billingProfile scope + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IReservationRecommendationDetailsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/SdkInfo_ConsumptionManagementClient.cs b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/SdkInfo_ConsumptionManagementClient.cs index 7dbefc695103..97bf3bdcc0a1 100644 --- a/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/SdkInfo_ConsumptionManagementClient.cs +++ b/sdk/consumption/Microsoft.Azure.Management.Consumption/src/Generated/SdkInfo_ConsumptionManagementClient.cs @@ -33,6 +33,7 @@ public static IEnumerable> ApiInfo_ConsumptionMana new Tuple("Consumption", "Marketplaces", "2019-10-01"), new Tuple("Consumption", "Operations", "2019-10-01"), new Tuple("Consumption", "PriceSheet", "2019-10-01"), + new Tuple("Consumption", "ReservationRecommendationDetails", "2019-10-01"), new Tuple("Consumption", "ReservationRecommendations", "2019-10-01"), new Tuple("Consumption", "ReservationsDetails", "2019-10-01"), new Tuple("Consumption", "ReservationsSummaries", "2019-10-01"),