diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/ConsumptionExtensions.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/ConsumptionExtensions.cs index 8399f734ff42..6c0cb884f4c8 100644 --- a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/ConsumptionExtensions.cs +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/ConsumptionExtensions.cs @@ -29,6 +29,48 @@ private static TenantResourceExtensionClient GetExtensionClient(TenantResource t ); } + /// + /// Lists all of the available consumption REST API operations. + /// + /// + /// Request Path + /// /providers/Microsoft.Consumption/operations + /// + /// + /// Operation Id + /// OperationsResult_List + /// + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetOperationsResultsAsync(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + return GetExtensionClient(tenantResource).GetOperationsResultsAsync(cancellationToken); + } + + /// + /// Lists all of the available consumption REST API operations. + /// + /// + /// Request Path + /// /providers/Microsoft.Consumption/operations + /// + /// + /// Operation Id + /// OperationsResult_List + /// + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetOperationsResults(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + return GetExtensionClient(tenantResource).GetOperationsResults(cancellationToken); + } + private static SubscriptionResourceExtensionClient GetExtensionClient(SubscriptionResource subscriptionResource) { return subscriptionResource.GetCachedClient((client) => @@ -84,6 +126,108 @@ public static Response GetPriceSheet(this SubscriptionResource return GetExtensionClient(subscriptionResource).GetPriceSheet(expand, skipToken, top, cancellationToken); } + /// + /// List the price sheet for a subscription. Price sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default + /// + /// + /// Operation Id + /// PriceSheets_Get + /// + /// + /// + /// The instance the method will execute against. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + public static async Task> GetPriceSheetAsync(this SubscriptionResource subscriptionResource, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + return await GetExtensionClient(subscriptionResource).GetPriceSheetAsync(expand, skiptoken, top, cancellationToken).ConfigureAwait(false); + } + + /// + /// List the price sheet for a subscription. Price sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default + /// + /// + /// Operation Id + /// PriceSheets_Get + /// + /// + /// + /// The instance the method will execute against. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + public static Response GetPriceSheet(this SubscriptionResource subscriptionResource, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + return GetExtensionClient(subscriptionResource).GetPriceSheet(expand, skiptoken, top, cancellationToken); + } + + /// + /// Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default + /// + /// + /// Operation Id + /// PriceSheets_GetByBillingPeriod + /// + /// + /// + /// The instance the method will execute against. + /// Billing Period Name. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public static async Task> GetByBillingPeriodPriceSheetAsync(this SubscriptionResource subscriptionResource, string billingPeriodName, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(billingPeriodName, nameof(billingPeriodName)); + + return await GetExtensionClient(subscriptionResource).GetByBillingPeriodPriceSheetAsync(billingPeriodName, expand, skiptoken, top, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default + /// + /// + /// Operation Id + /// PriceSheets_GetByBillingPeriod + /// + /// + /// + /// The instance the method will execute against. + /// Billing Period Name. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public static Response GetByBillingPeriodPriceSheet(this SubscriptionResource subscriptionResource, string billingPeriodName, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(billingPeriodName, nameof(billingPeriodName)); + + return GetExtensionClient(subscriptionResource).GetByBillingPeriodPriceSheet(billingPeriodName, expand, skiptoken, top, cancellationToken); + } + private static ManagementGroupResourceExtensionClient GetExtensionClient(ManagementGroupResource managementGroupResource) { return managementGroupResource.GetCachedClient((client) => diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs index 5a5d7630ac7e..b8a3a3aebb80 100644 --- a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs @@ -21,6 +21,8 @@ internal partial class SubscriptionResourceExtensionClient : ArmResource { private ClientDiagnostics _priceSheetClientDiagnostics; private PriceSheetRestOperations _priceSheetRestClient; + private ClientDiagnostics _priceSheetsClientDiagnostics; + private PriceSheetsRestOperations _priceSheetsRestClient; /// Initializes a new instance of the class for mocking. protected SubscriptionResourceExtensionClient() @@ -36,6 +38,8 @@ internal SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifie private ClientDiagnostics PriceSheetClientDiagnostics => _priceSheetClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Consumption", ProviderConstants.DefaultProviderNamespace, Diagnostics); private PriceSheetRestOperations PriceSheetRestClient => _priceSheetRestClient ??= new PriceSheetRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics PriceSheetsClientDiagnostics => _priceSheetsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Consumption", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private PriceSheetsRestOperations PriceSheetsRestClient => _priceSheetsRestClient ??= new PriceSheetsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private string GetApiVersionOrNull(ResourceType resourceType) { @@ -108,5 +112,139 @@ public virtual Response GetPriceSheet(string expand = null, st throw; } } + + /// + /// List the price sheet for a subscription. Price sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default + /// + /// + /// Operation Id + /// PriceSheets_Get + /// + /// + /// + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + public virtual async Task> GetPriceSheetAsync(string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + using var scope = PriceSheetsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetPriceSheet"); + scope.Start(); + try + { + var response = await PriceSheetsRestClient.GetAsync(Id.SubscriptionId, expand, skiptoken, top, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List the price sheet for a subscription. Price sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default + /// + /// + /// Operation Id + /// PriceSheets_Get + /// + /// + /// + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + public virtual Response GetPriceSheet(string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + using var scope = PriceSheetsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetPriceSheet"); + scope.Start(); + try + { + var response = PriceSheetsRestClient.Get(Id.SubscriptionId, expand, skiptoken, top, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default + /// + /// + /// Operation Id + /// PriceSheets_GetByBillingPeriod + /// + /// + /// + /// Billing Period Name. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + public virtual async Task> GetByBillingPeriodPriceSheetAsync(string billingPeriodName, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + using var scope = PriceSheetsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetByBillingPeriodPriceSheet"); + scope.Start(); + try + { + var response = await PriceSheetsRestClient.GetByBillingPeriodAsync(Id.SubscriptionId, billingPeriodName, expand, skiptoken, top, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default + /// + /// + /// Operation Id + /// PriceSheets_GetByBillingPeriod + /// + /// + /// + /// Billing Period Name. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + public virtual Response GetByBillingPeriodPriceSheet(string billingPeriodName, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + using var scope = PriceSheetsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetByBillingPeriodPriceSheet"); + scope.Start(); + try + { + var response = PriceSheetsRestClient.GetByBillingPeriod(Id.SubscriptionId, billingPeriodName, expand, skiptoken, top, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } } } diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/TenantResourceExtensionClient.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/TenantResourceExtensionClient.cs index 6cfccef7ab75..bac759b38f69 100644 --- a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/TenantResourceExtensionClient.cs +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Extensions/TenantResourceExtensionClient.cs @@ -33,6 +33,8 @@ internal partial class TenantResourceExtensionClient : ArmResource private LotsRestOperations _lotsRestClient; private ClientDiagnostics _creditsClientDiagnostics; private CreditsRestOperations _creditsRestClient; + private ClientDiagnostics _operationsResultClientDiagnostics; + private OperationsResultRestOperations _operationsResultRestClient; /// Initializes a new instance of the class for mocking. protected TenantResourceExtensionClient() @@ -60,11 +62,57 @@ internal TenantResourceExtensionClient(ArmClient client, ResourceIdentifier id) private LotsRestOperations LotsRestClient => _lotsRestClient ??= new LotsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private ClientDiagnostics CreditsClientDiagnostics => _creditsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Consumption", ProviderConstants.DefaultProviderNamespace, Diagnostics); private CreditsRestOperations CreditsRestClient => _creditsRestClient ??= new CreditsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics OperationsResultClientDiagnostics => _operationsResultClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Consumption", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private OperationsResultRestOperations OperationsResultRestClient => _operationsResultRestClient ??= new OperationsResultRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private string GetApiVersionOrNull(ResourceType resourceType) { TryGetApiVersion(resourceType, out string apiVersion); return apiVersion; } + + /// + /// Lists all of the available consumption REST API operations. + /// + /// + /// Request Path + /// /providers/Microsoft.Consumption/operations + /// + /// + /// Operation Id + /// OperationsResult_List + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetOperationsResultsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => OperationsResultRestClient.CreateListRequest(); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OperationsResultRestClient.CreateListNextPageRequest(nextLink); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, OperationV2.DeserializeOperationV2, OperationsResultClientDiagnostics, Pipeline, "TenantResourceExtensionClient.GetOperationsResults", "value", "nextLink", cancellationToken); + } + + /// + /// Lists all of the available consumption REST API operations. + /// + /// + /// Request Path + /// /providers/Microsoft.Consumption/operations + /// + /// + /// Operation Id + /// OperationsResult_List + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetOperationsResults(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => OperationsResultRestClient.CreateListRequest(); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OperationsResultRestClient.CreateListNextPageRequest(nextLink); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, OperationV2.DeserializeOperationV2, OperationsResultClientDiagnostics, Pipeline, "TenantResourceExtensionClient.GetOperationsResults", "value", "nextLink", cancellationToken); + } } } diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/MeterDetailsV2.Serialization.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/MeterDetailsV2.Serialization.cs new file mode 100644 index 000000000000..8ed5a5780016 --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/MeterDetailsV2.Serialization.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Consumption.Models +{ + public partial class MeterDetailsV2 + { + internal static MeterDetailsV2 DeserializeMeterDetailsV2(JsonElement element) + { + Optional meterName = default; + Optional meterCategory = default; + Optional meterSubCategory = default; + Optional unit = default; + Optional meterLocation = default; + Optional totalIncludedQuantity = default; + Optional pretaxStandardRate = default; + Optional serviceName = default; + Optional serviceTier = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("meterName"u8)) + { + meterName = property.Value.GetString(); + continue; + } + if (property.NameEquals("meterCategory"u8)) + { + meterCategory = property.Value.GetString(); + continue; + } + if (property.NameEquals("meterSubCategory"u8)) + { + meterSubCategory = property.Value.GetString(); + continue; + } + if (property.NameEquals("unit"u8)) + { + unit = property.Value.GetString(); + continue; + } + if (property.NameEquals("meterLocation"u8)) + { + meterLocation = property.Value.GetString(); + continue; + } + if (property.NameEquals("totalIncludedQuantity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + totalIncludedQuantity = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("pretaxStandardRate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + pretaxStandardRate = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("serviceName"u8)) + { + serviceName = property.Value.GetString(); + continue; + } + if (property.NameEquals("serviceTier"u8)) + { + serviceTier = property.Value.GetString(); + continue; + } + } + return new MeterDetailsV2(meterName.Value, meterCategory.Value, meterSubCategory.Value, unit.Value, meterLocation.Value, Optional.ToNullable(totalIncludedQuantity), Optional.ToNullable(pretaxStandardRate), serviceName.Value, serviceTier.Value); + } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/MeterDetailsV2.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/MeterDetailsV2.cs new file mode 100644 index 000000000000..df7c2b520a6d --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/MeterDetailsV2.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Consumption.Models +{ + /// The properties of the meter detail. + public partial class MeterDetailsV2 + { + /// Initializes a new instance of MeterDetailsV2. + internal MeterDetailsV2() + { + } + + /// Initializes a new instance of MeterDetailsV2. + /// The name of the meter, within the given meter category. + /// The category of the meter, for example, 'Cloud services', 'Networking', etc.. + /// The subcategory of the meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + /// The unit in which the meter consumption is charged, for example, 'Hours', 'GB', etc. + /// The location in which the Azure service is available. + /// The total included quantity associated with the offer. + /// The pretax listing price. + /// The name of the service. + /// The service tier. + internal MeterDetailsV2(string meterName, string meterCategory, string meterSubCategory, string unit, string meterLocation, float? totalIncludedQuantity, float? pretaxStandardRate, string serviceName, string serviceTier) + { + MeterName = meterName; + MeterCategory = meterCategory; + MeterSubCategory = meterSubCategory; + Unit = unit; + MeterLocation = meterLocation; + TotalIncludedQuantity = totalIncludedQuantity; + PretaxStandardRate = pretaxStandardRate; + ServiceName = serviceName; + ServiceTier = serviceTier; + } + + /// The name of the meter, within the given meter category. + public string MeterName { get; } + /// The category of the meter, for example, 'Cloud services', 'Networking', etc.. + public string MeterCategory { get; } + /// The subcategory of the meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + public string MeterSubCategory { get; } + /// The unit in which the meter consumption is charged, for example, 'Hours', 'GB', etc. + public string Unit { get; } + /// The location in which the Azure service is available. + public string MeterLocation { get; } + /// The total included quantity associated with the offer. + public float? TotalIncludedQuantity { get; } + /// The pretax listing price. + public float? PretaxStandardRate { get; } + /// The name of the service. + public string ServiceName { get; } + /// The service tier. + public string ServiceTier { get; } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationListResultV2.Serialization.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationListResultV2.Serialization.cs new file mode 100644 index 000000000000..b45498260c89 --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationListResultV2.Serialization.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Consumption.Models +{ + internal partial class OperationListResultV2 + { + internal static OperationListResultV2 DeserializeOperationListResultV2(JsonElement element) + { + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(OperationV2.DeserializeOperationV2(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new OperationListResultV2(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationListResultV2.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationListResultV2.cs new file mode 100644 index 000000000000..f18fc0a9bff3 --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationListResultV2.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Consumption.Models +{ + /// Result of listing consumption operations. It contains a list of operations and a URL link to get the next set of results. + internal partial class OperationListResultV2 + { + /// Initializes a new instance of OperationListResultV2. + internal OperationListResultV2() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of OperationListResultV2. + /// List of consumption operations supported by the Microsoft.Consumption resource provider. + /// URL to get the next set of operation list results if there are any. + internal OperationListResultV2(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// List of consumption operations supported by the Microsoft.Consumption resource provider. + public IReadOnlyList Value { get; } + /// URL to get the next set of operation list results if there are any. + public string NextLink { get; } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2.Serialization.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2.Serialization.cs new file mode 100644 index 000000000000..155085dfe58d --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2.Serialization.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Consumption.Models +{ + public partial class OperationV2 + { + internal static OperationV2 DeserializeOperationV2(JsonElement element) + { + Optional id = default; + Optional name = default; + Optional isDataAction = default; + Optional origin = default; + Optional display = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("isDataAction"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + isDataAction = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("origin"u8)) + { + origin = property.Value.GetString(); + continue; + } + if (property.NameEquals("display"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + display = OperationV2Display.DeserializeOperationV2Display(property.Value); + continue; + } + } + return new OperationV2(id.Value, name.Value, Optional.ToNullable(isDataAction), origin.Value, display.Value); + } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2.cs new file mode 100644 index 000000000000..e4b531b9f9b0 --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Consumption.Models +{ + /// A Consumption REST API operation. + public partial class OperationV2 + { + /// Initializes a new instance of OperationV2. + internal OperationV2() + { + } + + /// Initializes a new instance of OperationV2. + /// Operation Id. + /// Operation name: {provider}/{resource}/{operation}. + /// Indicates whether the operation is a data action. + /// Origin of the operation. + /// The object that represents the operation. + internal OperationV2(string id, string name, bool? isDataAction, string origin, OperationV2Display display) + { + Id = id; + Name = name; + IsDataAction = isDataAction; + Origin = origin; + Display = display; + } + + /// Operation Id. + public string Id { get; } + /// Operation name: {provider}/{resource}/{operation}. + public string Name { get; } + /// Indicates whether the operation is a data action. + public bool? IsDataAction { get; } + /// Origin of the operation. + public string Origin { get; } + /// The object that represents the operation. + public OperationV2Display Display { get; } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2Display.Serialization.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2Display.Serialization.cs new file mode 100644 index 000000000000..99fa56adb9b1 --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2Display.Serialization.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Consumption.Models +{ + public partial class OperationV2Display + { + internal static OperationV2Display DeserializeOperationV2Display(JsonElement element) + { + Optional provider = default; + Optional resource = default; + Optional operation = default; + Optional description = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("resource"u8)) + { + resource = property.Value.GetString(); + continue; + } + if (property.NameEquals("operation"u8)) + { + operation = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + } + return new OperationV2Display(provider.Value, resource.Value, operation.Value, description.Value); + } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2Display.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2Display.cs new file mode 100644 index 000000000000..95b99994c72f --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/OperationV2Display.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Consumption.Models +{ + /// The object that represents the operation. + public partial class OperationV2Display + { + /// Initializes a new instance of OperationV2Display. + internal OperationV2Display() + { + } + + /// Initializes a new instance of OperationV2Display. + /// Service provider: Microsoft.Consumption. + /// Resource on which the operation is performed: UsageDetail, etc. + /// Operation type: Read, write, delete, etc. + /// Description of the operation. + internal OperationV2Display(string provider, string resource, string operation, string description) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + } + + /// Service provider: Microsoft.Consumption. + public string Provider { get; } + /// Resource on which the operation is performed: UsageDetail, etc. + public string Resource { get; } + /// Operation type: Read, write, delete, etc. + public string Operation { get; } + /// Description of the operation. + public string Description { get; } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetPropertiesV2.Serialization.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetPropertiesV2.Serialization.cs new file mode 100644 index 000000000000..badbf29359f1 --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetPropertiesV2.Serialization.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Consumption.Models +{ + public partial class PriceSheetPropertiesV2 + { + internal static PriceSheetPropertiesV2 DeserializePriceSheetPropertiesV2(JsonElement element) + { + Optional billingPeriodId = default; + Optional meterId = default; + Optional meterDetails = default; + Optional unitOfMeasure = default; + Optional includedQuantity = default; + Optional partNumber = default; + Optional unitPrice = default; + Optional currencyCode = default; + Optional offerId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("billingPeriodId"u8)) + { + billingPeriodId = property.Value.GetString(); + continue; + } + if (property.NameEquals("meterId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + meterId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("meterDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + meterDetails = MeterDetailsV2.DeserializeMeterDetailsV2(property.Value); + continue; + } + if (property.NameEquals("unitOfMeasure"u8)) + { + unitOfMeasure = property.Value.GetString(); + continue; + } + if (property.NameEquals("includedQuantity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + includedQuantity = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("partNumber"u8)) + { + partNumber = property.Value.GetString(); + continue; + } + if (property.NameEquals("unitPrice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + unitPrice = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("currencyCode"u8)) + { + currencyCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("offerId"u8)) + { + offerId = property.Value.GetString(); + continue; + } + } + return new PriceSheetPropertiesV2(billingPeriodId.Value, Optional.ToNullable(meterId), meterDetails.Value, unitOfMeasure.Value, Optional.ToNullable(includedQuantity), partNumber.Value, Optional.ToNullable(unitPrice), currencyCode.Value, offerId.Value); + } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetPropertiesV2.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetPropertiesV2.cs new file mode 100644 index 000000000000..fff6ee953bd5 --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetPropertiesV2.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Consumption.Models +{ + /// The properties of the price sheet. + public partial class PriceSheetPropertiesV2 + { + /// Initializes a new instance of PriceSheetPropertiesV2. + internal PriceSheetPropertiesV2() + { + } + + /// Initializes a new instance of PriceSheetPropertiesV2. + /// The id of the billing period resource that the usage belongs to. + /// The meter id (GUID). + /// The details about the meter. By default this is not populated, unless it's specified in $expand. + /// Unit of measure. + /// Included quality for an offer. + /// Part Number. + /// Unit Price. + /// Currency Code. + /// Offer Id. + internal PriceSheetPropertiesV2(string billingPeriodId, Guid? meterId, MeterDetailsV2 meterDetails, string unitOfMeasure, float? includedQuantity, string partNumber, float? unitPrice, string currencyCode, string offerId) + { + BillingPeriodId = billingPeriodId; + MeterId = meterId; + MeterDetails = meterDetails; + UnitOfMeasure = unitOfMeasure; + IncludedQuantity = includedQuantity; + PartNumber = partNumber; + UnitPrice = unitPrice; + CurrencyCode = currencyCode; + OfferId = offerId; + } + + /// The id of the billing period resource that the usage belongs to. + public string BillingPeriodId { get; } + /// The meter id (GUID). + public Guid? MeterId { get; } + /// The details about the meter. By default this is not populated, unless it's specified in $expand. + public MeterDetailsV2 MeterDetails { get; } + /// Unit of measure. + public string UnitOfMeasure { get; } + /// Included quality for an offer. + public float? IncludedQuantity { get; } + /// Part Number. + public string PartNumber { get; } + /// Unit Price. + public float? UnitPrice { get; } + /// Currency Code. + public string CurrencyCode { get; } + /// Offer Id. + public string OfferId { get; } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetResultV2.Serialization.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetResultV2.Serialization.cs new file mode 100644 index 000000000000..4b309ee3f7b3 --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetResultV2.Serialization.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Consumption.Models +{ + public partial class PriceSheetResultV2 + { + internal static PriceSheetResultV2 DeserializePriceSheetResultV2(JsonElement element) + { + Optional etag = default; + Optional> tags = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional> pricesheets = default; + Optional nextLink = default; + Optional download = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("etag"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + etag = new ETag(property.Value.GetString()); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("pricesheets"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(PriceSheetPropertiesV2.DeserializePriceSheetPropertiesV2(item)); + } + pricesheets = array; + continue; + } + if (property0.NameEquals("nextLink"u8)) + { + nextLink = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("download"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + download = MeterDetailsV2.DeserializeMeterDetailsV2(property0.Value); + continue; + } + } + continue; + } + } + return new PriceSheetResultV2(id, name, type, systemData.Value, Optional.ToList(pricesheets), nextLink.Value, download.Value, Optional.ToNullable(etag), Optional.ToDictionary(tags)); + } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetResultV2.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetResultV2.cs new file mode 100644 index 000000000000..c4a8b7c849dd --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/Models/PriceSheetResultV2.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Consumption.Models +{ + /// An pricesheet resource. + public partial class PriceSheetResultV2 : ResourceData + { + /// Initializes a new instance of PriceSheetResultV2. + internal PriceSheetResultV2() + { + Pricesheets = new ChangeTrackingList(); + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of PriceSheetResultV2. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Price sheet. + /// The link (url) to the next page of results. + /// Pricesheet download details. + /// The etag for the resource. + /// Resource tags. + internal PriceSheetResultV2(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IReadOnlyList pricesheets, string nextLink, MeterDetailsV2 download, ETag? etag, IReadOnlyDictionary tags) : base(id, name, resourceType, systemData) + { + Pricesheets = pricesheets; + NextLink = nextLink; + Download = download; + ETag = etag; + Tags = tags; + } + + /// Price sheet. + public IReadOnlyList Pricesheets { get; } + /// The link (url) to the next page of results. + public string NextLink { get; } + /// Pricesheet download details. + public MeterDetailsV2 Download { get; } + /// The etag for the resource. + public ETag? ETag { get; } + /// Resource tags. + public IReadOnlyDictionary Tags { get; } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/OperationsResultRestOperations.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/OperationsResultRestOperations.cs new file mode 100644 index 000000000000..a67d54a17cbf --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/OperationsResultRestOperations.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Consumption.Models; + +namespace Azure.ResourceManager.Consumption +{ + internal partial class OperationsResultRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of OperationsResultRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public OperationsResultRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2022-06-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Consumption/operations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists all of the available consumption REST API operations. + /// The cancellation token to use. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationListResultV2 value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = OperationListResultV2.DeserializeOperationListResultV2(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all of the available consumption REST API operations. + /// The cancellation token to use. + public Response List(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationListResultV2 value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = OperationListResultV2.DeserializeOperationListResultV2(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists all of the available consumption REST API operations. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public async Task> ListNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationListResultV2 value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = OperationListResultV2.DeserializeOperationListResultV2(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all of the available consumption REST API operations. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public Response ListNextPage(string nextLink, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationListResultV2 value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = OperationListResultV2.DeserializeOperationListResultV2(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/PriceSheetsRestOperations.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/PriceSheetsRestOperations.cs new file mode 100644 index 000000000000..5404484201c4 --- /dev/null +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/PriceSheetsRestOperations.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Consumption.Models; + +namespace Azure.ResourceManager.Consumption +{ + internal partial class PriceSheetsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of PriceSheetsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public PriceSheetsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2022-06-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string expand, string skiptoken, int? top) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Consumption/pricesheets/default", false); + if (expand != null) + { + uri.AppendQuery("$expand", expand, true); + } + if (skiptoken != null) + { + uri.AppendQuery("$skiptoken", skiptoken, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List the price sheet for a subscription. Price sheet is available via this API only for May 1, 2014 or later. + /// Azure Subscription ID. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateGetRequest(subscriptionId, expand, skiptoken, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PriceSheetResultV2 value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = PriceSheetResultV2.DeserializePriceSheetResultV2(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List the price sheet for a subscription. Price sheet is available via this API only for May 1, 2014 or later. + /// Azure Subscription ID. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateGetRequest(subscriptionId, expand, skiptoken, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PriceSheetResultV2 value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = PriceSheetResultV2.DeserializePriceSheetResultV2(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetByBillingPeriodRequest(string subscriptionId, string billingPeriodName, string expand, string skiptoken, int? top) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Billing/billingPeriods/", false); + uri.AppendPath(billingPeriodName, true); + uri.AppendPath("/providers/Microsoft.Consumption/pricesheets/default", false); + if (expand != null) + { + uri.AppendQuery("$expand", expand, true); + } + if (skiptoken != null) + { + uri.AppendQuery("$skiptoken", skiptoken, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + /// Azure Subscription ID. + /// Billing Period Name. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> GetByBillingPeriodAsync(string subscriptionId, string billingPeriodName, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(billingPeriodName, nameof(billingPeriodName)); + + using var message = CreateGetByBillingPeriodRequest(subscriptionId, billingPeriodName, expand, skiptoken, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PriceSheetResultV2 value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = PriceSheetResultV2.DeserializePriceSheetResultV2(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. + /// Azure Subscription ID. + /// Billing Period Name. + /// May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// May be used to limit the number of results to the top N results. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response GetByBillingPeriod(string subscriptionId, string billingPeriodName, string expand = null, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(billingPeriodName, nameof(billingPeriodName)); + + using var message = CreateGetByBillingPeriodRequest(subscriptionId, billingPeriodName, expand, skiptoken, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PriceSheetResultV2 value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = PriceSheetResultV2.DeserializePriceSheetResultV2(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/ReservationsDetailsRestOperations.cs b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/ReservationsDetailsRestOperations.cs index 7864ae5f415a..b38a9c421490 100644 --- a/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/ReservationsDetailsRestOperations.cs +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/Generated/RestOperations/ReservationsDetailsRestOperations.cs @@ -55,7 +55,7 @@ internal HttpMessage CreateListByReservationOrderRequest(string reservationOrder return message; } - /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// Order Id of the reservation. /// Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. /// The cancellation token to use. @@ -82,7 +82,7 @@ public async Task> ListByReservationOrder } } - /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// Order Id of the reservation. /// Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. /// The cancellation token to use. @@ -129,7 +129,7 @@ internal HttpMessage CreateListByReservationOrderAndReservationRequest(string re return message; } - /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// Order Id of the reservation. /// Id of the reservation. /// Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. @@ -158,7 +158,7 @@ public async Task> ListByReservationOrder } } - /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// Order Id of the reservation. /// Id of the reservation. /// Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. @@ -224,7 +224,7 @@ internal HttpMessage CreateListRequest(string resourceScope, string startDate, s return message; } - /// Lists the reservations details for the defined scope and provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for the defined scope and provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// The scope associated with reservations details operations. This includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope (legacy), and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope (modern). /// Start date. Only applicable when querying with billing profile. /// End date. Only applicable when querying with billing profile. @@ -253,7 +253,7 @@ public async Task> ListAsync(string resou } } - /// Lists the reservations details for the defined scope and provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for the defined scope and provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// The scope associated with reservations details operations. This includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope (legacy), and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope (modern). /// Start date. Only applicable when querying with billing profile. /// End date. Only applicable when querying with billing profile. @@ -296,7 +296,7 @@ internal HttpMessage CreateListByReservationOrderNextPageRequest(string nextLink return message; } - /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// The URL to the next page of results. /// Order Id of the reservation. /// Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. @@ -325,7 +325,7 @@ public async Task> ListByReservationOrder } } - /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// The URL to the next page of results. /// Order Id of the reservation. /// Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. @@ -368,7 +368,7 @@ internal HttpMessage CreateListByReservationOrderAndReservationNextPageRequest(s return message; } - /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// The URL to the next page of results. /// Order Id of the reservation. /// Id of the reservation. @@ -399,7 +399,7 @@ public async Task> ListByReservationOrder } } - /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// The URL to the next page of results. /// Order Id of the reservation. /// Id of the reservation. @@ -444,7 +444,7 @@ internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceS return message; } - /// Lists the reservations details for the defined scope and provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for the defined scope and provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// The URL to the next page of results. /// The scope associated with reservations details operations. This includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope (legacy), and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope (modern). /// Start date. Only applicable when querying with billing profile. @@ -475,7 +475,7 @@ public async Task> ListNextPageAsync(stri } } - /// Lists the reservations details for the defined scope and provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 502 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. + /// Lists the reservations details for the defined scope and provided date range. Note: ARM has a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made with smaller date ranges. /// The URL to the next page of results. /// The scope associated with reservations details operations. This includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope (legacy), and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope (modern). /// Start date. Only applicable when querying with billing profile. diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/src/autorest.md b/sdk/consumption/Azure.ResourceManager.Consumption/src/autorest.md index eae4bf3561b0..755a0c6573ad 100644 --- a/sdk/consumption/Azure.ResourceManager.Consumption/src/autorest.md +++ b/sdk/consumption/Azure.ResourceManager.Consumption/src/autorest.md @@ -9,7 +9,7 @@ generate-model-factory: false csharp: true library-name: Consumption namespace: Azure.ResourceManager.Consumption -require: https://github.com/Azure/azure-rest-api-specs/blob/6b08774c89877269e73e11ac3ecbd1bd4e14f5a0/specification/consumption/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/consumption/resource-manager/readme.md output-folder: $(this-folder)/Generated clear-output-folder: true skip-csproj: true