From 47235aced6a094f44006c995652c5b1e9f9c90b2 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 16 Aug 2023 19:59:19 +0000 Subject: [PATCH] CodeGen from PR 23990 in Azure/azure-rest-api-specs Merge 5755c0b658d10e0c372d52cfdee4ea511c85cffc into 1df6d6f671dc5059016fbc2c0a624e01f0b2972c --- .../src/Generated/ArmQuotaModelFactory.cs | 150 +++++ .../ManagementGroupResourceExtensionClient.cs | 308 ++++++++++ .../Generated/Extensions/QuotaExtensions.cs | 542 ++++++++++++++++++ .../Generated/GroupQuotaLimitCollection.cs | 349 +++++++++++ .../src/Generated/GroupQuotaLimitData.cs | 39 ++ .../src/Generated/GroupQuotaLimitResource.cs | 247 ++++++++ .../GroupQuotaSubscriptionCollection.cs | 336 +++++++++++ .../Generated/GroupQuotaSubscriptionIdData.cs | 39 ++ ...GroupQuotaSubscriptionRequestCollection.cs | 258 +++++++++ .../GroupQuotaSubscriptionRequestResource.cs | 153 +++++ .../GroupQuotaSubscriptionResource.cs | 289 ++++++++++ .../Generated/GroupQuotasEntityCollection.cs | 341 +++++++++++ .../src/Generated/GroupQuotasEntityData.cs | 39 ++ .../Generated/GroupQuotasEntityResource.cs | 406 +++++++++++++ .../GroupQuotaLimitOperationSource.cs | 40 ++ .../GroupQuotaSubscriptionOperationSource.cs | 40 ++ .../GroupQuotasEntityOperationSource.cs | 40 ++ .../LongRunningOperation/QuotaArmOperation.cs | 70 +++ ...scriptionQuotaAllocationOperationSource.cs | 40 ++ .../AdditionalAttributes.Serialization.cs | 56 ++ .../Generated/Models/AdditionalAttributes.cs | 40 ++ .../AssignedToSubscription.Serialization.cs | 43 ++ .../Models/AssignedToSubscription.cs | 32 ++ .../src/Generated/Models/EnvironmentType.cs | 51 ++ .../Models/GroupQuotaDetails.Serialization.cs | 116 ++++ .../src/Generated/Models/GroupQuotaDetails.cs | 56 ++ .../GroupQuotaDetailsName.Serialization.cs | 45 ++ .../Generated/Models/GroupQuotaDetailsName.cs | 32 ++ .../GroupQuotaLimitData.Serialization.cs | 78 +++ .../GroupQuotaLimitList.Serialization.cs | 50 ++ .../Generated/Models/GroupQuotaLimitList.cs | 37 ++ .../Models/GroupQuotaList.Serialization.cs | 50 ++ .../src/Generated/Models/GroupQuotaList.cs | 37 ++ ...upQuotaSubscriptionIdData.Serialization.cs | 78 +++ ...upQuotaSubscriptionIdList.Serialization.cs | 50 ++ .../Models/GroupQuotaSubscriptionIdList.cs | 37 ++ ...aSubscriptionIdProperties.Serialization.cs | 49 ++ .../GroupQuotaSubscriptionIdProperties.cs | 32 ++ .../GroupQuotasEntityBase.Serialization.cs | 69 +++ .../Generated/Models/GroupQuotasEntityBase.cs | 36 ++ .../GroupQuotasEntityData.Serialization.cs | 78 +++ .../Models/GroupingId.Serialization.cs | 59 ++ .../src/Generated/Models/GroupingId.cs | 32 ++ .../src/Generated/Models/GroupingIdType.cs | 51 ++ .../src/Generated/Models/RequestState.cs | 66 +++ .../ResourceBaseRequest.Serialization.cs | 49 ++ .../Generated/Models/ResourceBaseRequest.cs | 36 ++ ...ttedResourceRequestStatus.Serialization.cs | 47 ++ .../Models/SubmittedResourceRequestStatus.cs | 32 ++ ...ResourceRequestStatusList.Serialization.cs | 49 ++ .../SubmittedResourceRequestStatusList.cs | 36 ++ ...ptionGroupQuotaAssignment.Serialization.cs | 59 ++ .../SubscriptionGroupQuotaAssignment.cs | 32 ++ ...iptionQuotaAllocationData.Serialization.cs | 78 +++ ...ionQuotaAllocationRequest.Serialization.cs | 37 ++ .../SubscriptionQuotaAllocationRequest.cs | 28 + ...uotaAllocationRequestList.Serialization.cs | 49 ++ .../SubscriptionQuotaAllocationRequestList.cs | 36 ++ ...locationRequestProperties.Serialization.cs | 47 ++ ...riptionQuotaAllocationRequestProperties.cs | 32 ++ ...ptionQuotaAllocationsList.Serialization.cs | 50 ++ .../SubscriptionQuotaAllocationsList.cs | 37 ++ .../SubscriptionQuotaDetails.Serialization.cs | 89 +++ .../Models/SubscriptionQuotaDetails.cs | 44 ++ .../GroupQuotaLimitsRequestsRestOperations.cs | 279 +++++++++ .../GroupQuotaLimitsRestOperations.cs | 451 +++++++++++++++ ...onQuotaAllocationRequestsRestOperations.cs | 295 ++++++++++ ...bscriptionQuotaAllocationRestOperations.cs | 479 ++++++++++++++++ .../GroupQuotaSubscriptionsRestOperations.cs | 477 +++++++++++++++ .../GroupQuotasRestOperations.cs | 465 +++++++++++++++ .../SubscriptionRequestsRestOperations.cs | 267 +++++++++ .../SubscriptionQuotaAllocationCollection.cs | 352 ++++++++++++ .../SubscriptionQuotaAllocationData.cs | 39 ++ .../SubscriptionQuotaAllocationResource.cs | 247 ++++++++ .../src/autorest.md | 2 +- 75 files changed, 9305 insertions(+), 1 deletion(-) create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Extensions/ManagementGroupResourceExtensionClient.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitCollection.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitData.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitResource.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionCollection.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionIdData.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionRequestCollection.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionRequestResource.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionResource.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityCollection.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityData.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityResource.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotaLimitOperationSource.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotaSubscriptionOperationSource.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotasEntityOperationSource.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/QuotaArmOperation.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/SubscriptionQuotaAllocationOperationSource.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AdditionalAttributes.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AdditionalAttributes.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AssignedToSubscription.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AssignedToSubscription.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/EnvironmentType.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetails.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetails.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetailsName.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetailsName.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitData.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitList.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitList.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaList.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaList.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdData.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdList.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdList.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdProperties.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdProperties.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityBase.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityBase.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityData.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingId.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingId.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingIdType.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/RequestState.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/ResourceBaseRequest.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/ResourceBaseRequest.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatus.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatus.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatusList.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatusList.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionGroupQuotaAssignment.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionGroupQuotaAssignment.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationData.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequest.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequest.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestList.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestList.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestProperties.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestProperties.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationsList.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationsList.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaDetails.Serialization.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaDetails.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaLimitsRequestsRestOperations.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaLimitsRestOperations.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionQuotaAllocationRestOperations.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionsRestOperations.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotasRestOperations.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/SubscriptionRequestsRestOperations.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationCollection.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationData.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationResource.cs diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/ArmQuotaModelFactory.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/ArmQuotaModelFactory.cs index 4f3b1cde9231..a920cb88abc9 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/ArmQuotaModelFactory.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/ArmQuotaModelFactory.cs @@ -17,6 +17,156 @@ namespace Azure.ResourceManager.Quota.Models /// Model factory for models. public static partial class ArmQuotaModelFactory { + /// Initializes a new instance of GroupQuotasEntityData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Properties and filters for ShareQuota. The request parameter is optional, if there are no filters specified. + /// A new instance for mocking. + public static GroupQuotasEntityData GroupQuotasEntityData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, GroupQuotasEntityBase properties = null) + { + return new GroupQuotasEntityData(id, name, resourceType, systemData, properties); + } + + /// Initializes a new instance of GroupQuotasEntityBase. + /// Display name of the GroupQuota entity. + /// Additional attributes to allow subscription, which can be added to the subscriptionIds. + /// Provisioning state of the operation. + /// A new instance for mocking. + public static GroupQuotasEntityBase GroupQuotasEntityBase(string displayName = null, AdditionalAttributes additionalAttributes = null, RequestState? provisioningState = null) + { + return new GroupQuotasEntityBase(displayName, additionalAttributes, provisioningState); + } + + /// Initializes a new instance of GroupQuotaSubscriptionIdData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// + /// A new instance for mocking. + public static GroupQuotaSubscriptionIdData GroupQuotaSubscriptionIdData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, GroupQuotaSubscriptionIdProperties properties = null) + { + return new GroupQuotaSubscriptionIdData(id, name, resourceType, systemData, properties); + } + + /// Initializes a new instance of GroupQuotaSubscriptionIdProperties. + /// An Azure subscriptionId. + /// Status of this subscriptionId being associated with the GroupQuotasEntity. + /// A new instance for mocking. + public static GroupQuotaSubscriptionIdProperties GroupQuotaSubscriptionIdProperties(string subscriptionId = null, RequestState? provisioningState = null) + { + return new GroupQuotaSubscriptionIdProperties(subscriptionId, provisioningState); + } + + /// Initializes a new instance of GroupQuotaLimitData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Group Quota properties for the specified resource. + /// A new instance for mocking. + public static GroupQuotaLimitData GroupQuotaLimitData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, GroupQuotaDetails properties = null) + { + return new GroupQuotaLimitData(id, name, resourceType, systemData, properties); + } + + /// Initializes a new instance of GroupQuotaDetails. + /// The current Group Quota Limit at the parentId level. + /// Any comment related to quota request. + /// Name of the resource provided by the resource Provider. This property is already included in the request URI, so it is a readonly property returned in the response. + /// The usages units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. + /// The available Group Quota Limit at the MG level. This Group quota can be assigned to subscription(s). + /// Assigned Group Quota to subscriptions. + /// Request status. + /// A new instance for mocking. + public static GroupQuotaDetails GroupQuotaDetails(long? limit = null, string comment = null, GroupQuotaDetailsName name = null, string unit = null, long? availableLimit = null, IEnumerable assignedToSubscriptions = null, RequestState? provisioningState = null) + { + assignedToSubscriptions ??= new List(); + + return new GroupQuotaDetails(limit, comment, name, unit, availableLimit, assignedToSubscriptions?.ToList(), provisioningState); + } + + /// Initializes a new instance of GroupQuotaDetailsName. + /// Resource name. + /// Resource display name. + /// A new instance for mocking. + public static GroupQuotaDetailsName GroupQuotaDetailsName(string value = null, string localizedValue = null) + { + return new GroupQuotaDetailsName(value, localizedValue); + } + + /// Initializes a new instance of AssignedToSubscription. + /// An Azure subscriptionId. + /// The amount of quota allocated to this subscriptionId from the GroupQuotasEntity. + /// A new instance for mocking. + public static AssignedToSubscription AssignedToSubscription(string subscriptionId = null, long? quotaAllocated = null) + { + return new AssignedToSubscription(subscriptionId, quotaAllocated); + } + + /// Initializes a new instance of SubmittedResourceRequestStatus. + /// Requested Resource. + /// Request status. + /// A new instance for mocking. + public static SubmittedResourceRequestStatus SubmittedResourceRequestStatus(ResourceBaseRequest requestedResource = null, RequestState? status = null) + { + return new SubmittedResourceRequestStatus(requestedResource, status); + } + + /// Initializes a new instance of ResourceBaseRequest. + /// The resource name, such as SKU name. + /// Quota requested for the resource. + /// Representing the units of the usage quota. Possible values are: Count, Bytes, Seconds, Percent, CountPerSecond, BytesPerSecond. Based on - https://armwiki.azurewebsites.net/api_contracts/UsagesAPIContract.html?q=usages . Different RPs may have different units, Count, type as int64 should work for most of the integer values. + /// A new instance for mocking. + public static ResourceBaseRequest ResourceBaseRequest(string resourceName = null, long? limits = null, string unit = null) + { + return new ResourceBaseRequest(resourceName, limits, unit); + } + + /// Initializes a new instance of SubscriptionQuotaAllocationData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Quota properties for the specified resource. + /// A new instance for mocking. + public static SubscriptionQuotaAllocationData SubscriptionQuotaAllocationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, SubscriptionQuotaDetails properties = null) + { + return new SubscriptionQuotaAllocationData(id, name, resourceType, systemData, properties); + } + + /// Initializes a new instance of SubscriptionQuotaDetails. + /// The total quota limit for the subscription. + /// The non shareable quota for the subscription. + /// Request status. + /// Assigned Group Quota to subscriptions. + /// A new instance for mocking. + public static SubscriptionQuotaDetails SubscriptionQuotaDetails(long? limit = null, long? nonShareableQuota = null, RequestState? provisioningState = null, IEnumerable quotaSources = null) + { + quotaSources ??= new List(); + + return new SubscriptionQuotaDetails(limit, nonShareableQuota, provisioningState, quotaSources?.ToList()); + } + + /// Initializes a new instance of SubscriptionQuotaAllocationRequest. + /// + /// A new instance for mocking. + public static SubscriptionQuotaAllocationRequest SubscriptionQuotaAllocationRequest(SubscriptionQuotaAllocationRequestProperties properties = null) + { + return new SubscriptionQuotaAllocationRequest(properties); + } + + /// Initializes a new instance of SubscriptionQuotaAllocationRequestProperties. + /// Request status. + /// The new quota limit for the subscription. The incremental quota will be assigned from pre-approved groupQuota. + /// A new instance for mocking. + public static SubscriptionQuotaAllocationRequestProperties SubscriptionQuotaAllocationRequestProperties(RequestState? provisioningState = null, long? limit = null) + { + return new SubscriptionQuotaAllocationRequestProperties(provisioningState, limit); + } + /// Initializes a new instance of CurrentUsagesBaseData. /// The id. /// The name. diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Extensions/ManagementGroupResourceExtensionClient.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Extensions/ManagementGroupResourceExtensionClient.cs new file mode 100644 index 000000000000..b14286276b72 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Extensions/ManagementGroupResourceExtensionClient.cs @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + /// A class to add extension methods to ManagementGroupResource. + internal partial class ManagementGroupResourceExtensionClient : ArmResource + { + private ClientDiagnostics _groupQuotaLimitsRequestsClientDiagnostics; + private GroupQuotaLimitsRequestsRestOperations _groupQuotaLimitsRequestsRestClient; + private ClientDiagnostics _groupQuotaSubscriptionQuotaAllocationRequestsClientDiagnostics; + private GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations _groupQuotaSubscriptionQuotaAllocationRequestsRestClient; + + /// Initializes a new instance of the class for mocking. + protected ManagementGroupResourceExtensionClient() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ManagementGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics GroupQuotaLimitsRequestsClientDiagnostics => _groupQuotaLimitsRequestsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Quota", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private GroupQuotaLimitsRequestsRestOperations GroupQuotaLimitsRequestsRestClient => _groupQuotaLimitsRequestsRestClient ??= new GroupQuotaLimitsRequestsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics GroupQuotaSubscriptionQuotaAllocationRequestsClientDiagnostics => _groupQuotaSubscriptionQuotaAllocationRequestsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Quota", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations GroupQuotaSubscriptionQuotaAllocationRequestsRestClient => _groupQuotaSubscriptionQuotaAllocationRequestsRestClient ??= new GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of GroupQuotasEntityResources in the ManagementGroupResource. + /// An object representing collection of GroupQuotasEntityResources and their operations over a GroupQuotasEntityResource. + public virtual GroupQuotasEntityCollection GetGroupQuotasEntities() + { + return GetCachedClient(Client => new GroupQuotasEntityCollection(Client, Id)); + } + + /// Gets a collection of GroupQuotaLimitResources in the ManagementGroupResource. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// An object representing collection of GroupQuotaLimitResources and their operations over a GroupQuotaLimitResource. + public virtual GroupQuotaLimitCollection GetGroupQuotaLimits(string resourceProviderScope, string groupQuotaName) + { + return new GroupQuotaLimitCollection(Client, Id, resourceProviderScope, groupQuotaName); + } + + /// Gets a collection of SubscriptionQuotaAllocationResources in the ManagementGroupResource. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// An object representing collection of SubscriptionQuotaAllocationResources and their operations over a SubscriptionQuotaAllocationResource. + public virtual SubscriptionQuotaAllocationCollection GetSubscriptionQuotaAllocations(string subscriptionId, string resourceProviderScope, string groupQuotaName) + { + return new SubscriptionQuotaAllocationCollection(Client, Id, subscriptionId, resourceProviderScope, groupQuotaName); + } + + /// + /// List API to check the status of a GroupQuota requests by requestId. The groupQuotaRequest history is maintained for 1 year. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaRequests + /// + /// + /// Operation Id + /// GroupQuotaLimitsRequests_List + /// + /// + /// + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetGroupQuotaLimitsRequestsAsync(string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => GroupQuotaLimitsRequestsRestClient.CreateListRequest(Id.Name, resourceProviderScope, groupQuotaName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => GroupQuotaLimitsRequestsRestClient.CreateListNextPageRequest(nextLink, Id.Name, resourceProviderScope, groupQuotaName); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, SubmittedResourceRequestStatus.DeserializeSubmittedResourceRequestStatus, GroupQuotaLimitsRequestsClientDiagnostics, Pipeline, "ManagementGroupResourceExtensionClient.GetGroupQuotaLimitsRequests", "value", "nextLink", cancellationToken); + } + + /// + /// List API to check the status of a GroupQuota requests by requestId. The groupQuotaRequest history is maintained for 1 year. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaRequests + /// + /// + /// Operation Id + /// GroupQuotaLimitsRequests_List + /// + /// + /// + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetGroupQuotaLimitsRequests(string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => GroupQuotaLimitsRequestsRestClient.CreateListRequest(Id.Name, resourceProviderScope, groupQuotaName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => GroupQuotaLimitsRequestsRestClient.CreateListNextPageRequest(nextLink, Id.Name, resourceProviderScope, groupQuotaName); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, SubmittedResourceRequestStatus.DeserializeSubmittedResourceRequestStatus, GroupQuotaLimitsRequestsClientDiagnostics, Pipeline, "ManagementGroupResourceExtensionClient.GetGroupQuotaLimitsRequests", "value", "nextLink", cancellationToken); + } + + /// + /// Get API to check the status of a GroupQuota request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaRequests/{requestId} + /// + /// + /// Operation Id + /// GroupQuotaLimitsRequests_Get + /// + /// + /// + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Request Id. + /// The cancellation token to use. + public virtual async Task> GetGroupQuotaLimitsRequestAsync(string resourceProviderScope, string groupQuotaName, string requestId, CancellationToken cancellationToken = default) + { + using var scope = GroupQuotaLimitsRequestsClientDiagnostics.CreateScope("ManagementGroupResourceExtensionClient.GetGroupQuotaLimitsRequest"); + scope.Start(); + try + { + var response = await GroupQuotaLimitsRequestsRestClient.GetAsync(Id.Name, resourceProviderScope, groupQuotaName, requestId, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get API to check the status of a GroupQuota request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaRequests/{requestId} + /// + /// + /// Operation Id + /// GroupQuotaLimitsRequests_Get + /// + /// + /// + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Request Id. + /// The cancellation token to use. + public virtual Response GetGroupQuotaLimitsRequest(string resourceProviderScope, string groupQuotaName, string requestId, CancellationToken cancellationToken = default) + { + using var scope = GroupQuotaLimitsRequestsClientDiagnostics.CreateScope("ManagementGroupResourceExtensionClient.GetGroupQuotaLimitsRequest"); + scope.Start(); + try + { + var response = GroupQuotaLimitsRequestsRestClient.Get(Id.Name, resourceProviderScope, groupQuotaName, requestId, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the quota allocation request status for the subscriptionId by allocationId. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocationRequests/{allocationId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocationRequests_Get + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource allocation Id. + /// The cancellation token to use. + public virtual async Task> GetGroupQuotaSubscriptionQuotaAllocationRequestAsync(string subscriptionId, string resourceProviderScope, string groupQuotaName, string allocationId, CancellationToken cancellationToken = default) + { + using var scope = GroupQuotaSubscriptionQuotaAllocationRequestsClientDiagnostics.CreateScope("ManagementGroupResourceExtensionClient.GetGroupQuotaSubscriptionQuotaAllocationRequest"); + scope.Start(); + try + { + var response = await GroupQuotaSubscriptionQuotaAllocationRequestsRestClient.GetAsync(Id.Name, subscriptionId, resourceProviderScope, groupQuotaName, allocationId, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the quota allocation request status for the subscriptionId by allocationId. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocationRequests/{allocationId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocationRequests_Get + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource allocation Id. + /// The cancellation token to use. + public virtual Response GetGroupQuotaSubscriptionQuotaAllocationRequest(string subscriptionId, string resourceProviderScope, string groupQuotaName, string allocationId, CancellationToken cancellationToken = default) + { + using var scope = GroupQuotaSubscriptionQuotaAllocationRequestsClientDiagnostics.CreateScope("ManagementGroupResourceExtensionClient.GetGroupQuotaSubscriptionQuotaAllocationRequest"); + scope.Start(); + try + { + var response = GroupQuotaSubscriptionQuotaAllocationRequestsRestClient.Get(Id.Name, subscriptionId, resourceProviderScope, groupQuotaName, allocationId, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all the allocation requests. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocationRequests + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocationRequests_List + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetGroupQuotaSubscriptionQuotaAllocationRequestsAsync(string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => GroupQuotaSubscriptionQuotaAllocationRequestsRestClient.CreateListRequest(Id.Name, subscriptionId, resourceProviderScope, groupQuotaName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => GroupQuotaSubscriptionQuotaAllocationRequestsRestClient.CreateListNextPageRequest(nextLink, Id.Name, subscriptionId, resourceProviderScope, groupQuotaName); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, SubscriptionQuotaAllocationRequest.DeserializeSubscriptionQuotaAllocationRequest, GroupQuotaSubscriptionQuotaAllocationRequestsClientDiagnostics, Pipeline, "ManagementGroupResourceExtensionClient.GetGroupQuotaSubscriptionQuotaAllocationRequests", "value", "nextLink", cancellationToken); + } + + /// + /// Lists all the allocation requests. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocationRequests + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocationRequests_List + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetGroupQuotaSubscriptionQuotaAllocationRequests(string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => GroupQuotaSubscriptionQuotaAllocationRequestsRestClient.CreateListRequest(Id.Name, subscriptionId, resourceProviderScope, groupQuotaName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => GroupQuotaSubscriptionQuotaAllocationRequestsRestClient.CreateListNextPageRequest(nextLink, Id.Name, subscriptionId, resourceProviderScope, groupQuotaName); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, SubscriptionQuotaAllocationRequest.DeserializeSubscriptionQuotaAllocationRequest, GroupQuotaSubscriptionQuotaAllocationRequestsClientDiagnostics, Pipeline, "ManagementGroupResourceExtensionClient.GetGroupQuotaSubscriptionQuotaAllocationRequests", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Extensions/QuotaExtensions.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Extensions/QuotaExtensions.cs index 41dda3945133..c2504050f1db 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Extensions/QuotaExtensions.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Extensions/QuotaExtensions.cs @@ -11,6 +11,7 @@ using Azure; using Azure.Core; using Azure.ResourceManager; +using Azure.ResourceManager.ManagementGroups; using Azure.ResourceManager.Quota.Models; using Azure.ResourceManager.Resources; @@ -35,6 +36,22 @@ private static ArmResourceExtensionClient GetArmResourceExtensionClient(ArmClien }); } + private static ManagementGroupResourceExtensionClient GetManagementGroupResourceExtensionClient(ArmResource resource) + { + return resource.GetCachedClient(client => + { + return new ManagementGroupResourceExtensionClient(client, resource.Id); + }); + } + + private static ManagementGroupResourceExtensionClient GetManagementGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + { + return client.GetResourceClient(() => + { + return new ManagementGroupResourceExtensionClient(client, scope); + }); + } + private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmResource resource) { return resource.GetCachedClient(client => @@ -50,6 +67,101 @@ private static TenantResourceExtensionClient GetTenantResourceExtensionClient(Ar return new TenantResourceExtensionClient(client, scope); }); } + #region GroupQuotasEntityResource + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static GroupQuotasEntityResource GetGroupQuotasEntityResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + GroupQuotasEntityResource.ValidateResourceId(id); + return new GroupQuotasEntityResource(client, id); + } + ); + } + #endregion + + #region GroupQuotaSubscriptionResource + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static GroupQuotaSubscriptionResource GetGroupQuotaSubscriptionResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + GroupQuotaSubscriptionResource.ValidateResourceId(id); + return new GroupQuotaSubscriptionResource(client, id); + } + ); + } + #endregion + + #region GroupQuotaSubscriptionRequestResource + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static GroupQuotaSubscriptionRequestResource GetGroupQuotaSubscriptionRequestResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + GroupQuotaSubscriptionRequestResource.ValidateResourceId(id); + return new GroupQuotaSubscriptionRequestResource(client, id); + } + ); + } + #endregion + + #region GroupQuotaLimitResource + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static GroupQuotaLimitResource GetGroupQuotaLimitResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + GroupQuotaLimitResource.ValidateResourceId(id); + return new GroupQuotaLimitResource(client, id); + } + ); + } + #endregion + + #region SubscriptionQuotaAllocationResource + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static SubscriptionQuotaAllocationResource GetSubscriptionQuotaAllocationResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + SubscriptionQuotaAllocationResource.ValidateResourceId(id); + return new SubscriptionQuotaAllocationResource(client, id); + } + ); + } + #endregion + #region CurrentUsagesBaseResource /// /// Gets an object representing a along with the instance operations that can be performed on it but with no data. @@ -304,6 +416,436 @@ public static Response GetQuotaRequestDetail(this Ar return client.GetQuotaRequestDetails(scope).Get(id, cancellationToken); } + /// Gets a collection of GroupQuotasEntityResources in the ManagementGroupResource. + /// The instance the method will execute against. + /// An object representing collection of GroupQuotasEntityResources and their operations over a GroupQuotasEntityResource. + public static GroupQuotasEntityCollection GetGroupQuotasEntities(this ManagementGroupResource managementGroupResource) + { + return GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotasEntities(); + } + + /// + /// Gets the GroupQuotas for the name passed. It will return the GroupQuotas properties only. The details on groupQuota can be access from the groupQuota APIs. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Get + /// + /// + /// + /// The instance the method will execute against. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public static async Task> GetGroupQuotasEntityAsync(this ManagementGroupResource managementGroupResource, string groupQuotaName, CancellationToken cancellationToken = default) + { + return await managementGroupResource.GetGroupQuotasEntities().GetAsync(groupQuotaName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the GroupQuotas for the name passed. It will return the GroupQuotas properties only. The details on groupQuota can be access from the groupQuota APIs. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Get + /// + /// + /// + /// The instance the method will execute against. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public static Response GetGroupQuotasEntity(this ManagementGroupResource managementGroupResource, string groupQuotaName, CancellationToken cancellationToken = default) + { + return managementGroupResource.GetGroupQuotasEntities().Get(groupQuotaName, cancellationToken); + } + + /// Gets a collection of GroupQuotaLimitResources in the ManagementGroupResource. + /// The instance the method will execute against. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// An object representing collection of GroupQuotaLimitResources and their operations over a GroupQuotaLimitResource. + public static GroupQuotaLimitCollection GetGroupQuotaLimits(this ManagementGroupResource managementGroupResource, string resourceProviderScope, string groupQuotaName) + { + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + return GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotaLimits(resourceProviderScope, groupQuotaName); + } + + /// + /// Gets the resource groupQuotaLimits for the MGId. It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Get + /// + /// + /// + /// The instance the method will execute against. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The cancellation token to use. + /// , or is an empty string, and was expected to be non-empty. + /// , or is null. + [ForwardsClientCalls] + public static async Task> GetGroupQuotaLimitAsync(this ManagementGroupResource managementGroupResource, string resourceProviderScope, string groupQuotaName, string resourceName, CancellationToken cancellationToken = default) + { + return await managementGroupResource.GetGroupQuotaLimits(resourceProviderScope, groupQuotaName).GetAsync(resourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the resource groupQuotaLimits for the MGId. It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Get + /// + /// + /// + /// The instance the method will execute against. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The cancellation token to use. + /// , or is an empty string, and was expected to be non-empty. + /// , or is null. + [ForwardsClientCalls] + public static Response GetGroupQuotaLimit(this ManagementGroupResource managementGroupResource, string resourceProviderScope, string groupQuotaName, string resourceName, CancellationToken cancellationToken = default) + { + return managementGroupResource.GetGroupQuotaLimits(resourceProviderScope, groupQuotaName).Get(resourceName, cancellationToken); + } + + /// Gets a collection of SubscriptionQuotaAllocationResources in the ManagementGroupResource. + /// The instance the method will execute against. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// , or is an empty string, and was expected to be non-empty. + /// , or is null. + /// An object representing collection of SubscriptionQuotaAllocationResources and their operations over a SubscriptionQuotaAllocationResource. + public static SubscriptionQuotaAllocationCollection GetSubscriptionQuotaAllocations(this ManagementGroupResource managementGroupResource, string subscriptionId, string resourceProviderScope, string groupQuotaName) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + return GetManagementGroupResourceExtensionClient(managementGroupResource).GetSubscriptionQuotaAllocations(subscriptionId, resourceProviderScope, groupQuotaName); + } + + /// + /// Gets Quota assigned to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Get + /// + /// + /// + /// The instance the method will execute against. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The cancellation token to use. + /// , , or is an empty string, and was expected to be non-empty. + /// , , or is null. + [ForwardsClientCalls] + public static async Task> GetSubscriptionQuotaAllocationAsync(this ManagementGroupResource managementGroupResource, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, CancellationToken cancellationToken = default) + { + return await managementGroupResource.GetSubscriptionQuotaAllocations(subscriptionId, resourceProviderScope, groupQuotaName).GetAsync(resourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets Quota assigned to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Get + /// + /// + /// + /// The instance the method will execute against. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The cancellation token to use. + /// , , or is an empty string, and was expected to be non-empty. + /// , , or is null. + [ForwardsClientCalls] + public static Response GetSubscriptionQuotaAllocation(this ManagementGroupResource managementGroupResource, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, CancellationToken cancellationToken = default) + { + return managementGroupResource.GetSubscriptionQuotaAllocations(subscriptionId, resourceProviderScope, groupQuotaName).Get(resourceName, cancellationToken); + } + + /// + /// List API to check the status of a GroupQuota requests by requestId. The groupQuotaRequest history is maintained for 1 year. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaRequests + /// + /// + /// Operation Id + /// GroupQuotaLimitsRequests_List + /// + /// + /// + /// The instance the method will execute against. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetGroupQuotaLimitsRequestsAsync(this ManagementGroupResource managementGroupResource, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + return GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotaLimitsRequestsAsync(resourceProviderScope, groupQuotaName, cancellationToken); + } + + /// + /// List API to check the status of a GroupQuota requests by requestId. The groupQuotaRequest history is maintained for 1 year. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaRequests + /// + /// + /// Operation Id + /// GroupQuotaLimitsRequests_List + /// + /// + /// + /// The instance the method will execute against. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetGroupQuotaLimitsRequests(this ManagementGroupResource managementGroupResource, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + return GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotaLimitsRequests(resourceProviderScope, groupQuotaName, cancellationToken); + } + + /// + /// Get API to check the status of a GroupQuota request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaRequests/{requestId} + /// + /// + /// Operation Id + /// GroupQuotaLimitsRequests_Get + /// + /// + /// + /// The instance the method will execute against. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Request Id. + /// The cancellation token to use. + /// , or is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> GetGroupQuotaLimitsRequestAsync(this ManagementGroupResource managementGroupResource, string resourceProviderScope, string groupQuotaName, string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + return await GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotaLimitsRequestAsync(resourceProviderScope, groupQuotaName, requestId, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get API to check the status of a GroupQuota request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaRequests/{requestId} + /// + /// + /// Operation Id + /// GroupQuotaLimitsRequests_Get + /// + /// + /// + /// The instance the method will execute against. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Request Id. + /// The cancellation token to use. + /// , or is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response GetGroupQuotaLimitsRequest(this ManagementGroupResource managementGroupResource, string resourceProviderScope, string groupQuotaName, string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + return GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotaLimitsRequest(resourceProviderScope, groupQuotaName, requestId, cancellationToken); + } + + /// + /// Get the quota allocation request status for the subscriptionId by allocationId. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocationRequests/{allocationId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocationRequests_Get + /// + /// + /// + /// The instance the method will execute against. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource allocation Id. + /// The cancellation token to use. + /// , , or is an empty string, and was expected to be non-empty. + /// , , or is null. + public static async Task> GetGroupQuotaSubscriptionQuotaAllocationRequestAsync(this ManagementGroupResource managementGroupResource, string subscriptionId, string resourceProviderScope, string groupQuotaName, string allocationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(allocationId, nameof(allocationId)); + + return await GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotaSubscriptionQuotaAllocationRequestAsync(subscriptionId, resourceProviderScope, groupQuotaName, allocationId, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get the quota allocation request status for the subscriptionId by allocationId. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocationRequests/{allocationId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocationRequests_Get + /// + /// + /// + /// The instance the method will execute against. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource allocation Id. + /// The cancellation token to use. + /// , , or is an empty string, and was expected to be non-empty. + /// , , or is null. + public static Response GetGroupQuotaSubscriptionQuotaAllocationRequest(this ManagementGroupResource managementGroupResource, string subscriptionId, string resourceProviderScope, string groupQuotaName, string allocationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(allocationId, nameof(allocationId)); + + return GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotaSubscriptionQuotaAllocationRequest(subscriptionId, resourceProviderScope, groupQuotaName, allocationId, cancellationToken); + } + + /// + /// Lists all the allocation requests. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocationRequests + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocationRequests_List + /// + /// + /// + /// The instance the method will execute against. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is an empty string, and was expected to be non-empty. + /// , or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetGroupQuotaSubscriptionQuotaAllocationRequestsAsync(this ManagementGroupResource managementGroupResource, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + return GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotaSubscriptionQuotaAllocationRequestsAsync(subscriptionId, resourceProviderScope, groupQuotaName, cancellationToken); + } + + /// + /// Lists all the allocation requests. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocationRequests + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocationRequests_List + /// + /// + /// + /// The instance the method will execute against. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is an empty string, and was expected to be non-empty. + /// , or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetGroupQuotaSubscriptionQuotaAllocationRequests(this ManagementGroupResource managementGroupResource, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + return GetManagementGroupResourceExtensionClient(managementGroupResource).GetGroupQuotaSubscriptionQuotaAllocationRequests(subscriptionId, resourceProviderScope, groupQuotaName, cancellationToken); + } + /// /// List all the operations supported by the Microsoft.Quota resource provider. /// diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitCollection.cs new file mode 100644 index 000000000000..08a88ef80ea8 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitCollection.cs @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagementGroups; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetGroupQuotaLimits method from an instance of . + /// + public partial class GroupQuotaLimitCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _groupQuotaLimitClientDiagnostics; + private readonly GroupQuotaLimitsRestOperations _groupQuotaLimitRestClient; + private readonly string _resourceProviderScope; + private readonly string _groupQuotaName; + + /// Initializes a new instance of the class for mocking. + protected GroupQuotaLimitCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + internal GroupQuotaLimitCollection(ArmClient client, ResourceIdentifier id, string resourceProviderScope, string groupQuotaName) : base(client, id) + { + _resourceProviderScope = resourceProviderScope; + _groupQuotaName = groupQuotaName; + _groupQuotaLimitClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", GroupQuotaLimitResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(GroupQuotaLimitResource.ResourceType, out string groupQuotaLimitApiVersion); + _groupQuotaLimitRestClient = new GroupQuotaLimitsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, groupQuotaLimitApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ManagementGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagementGroupResource.ResourceType), nameof(id)); + } + + /// + /// Updates the GroupQuotaLimits for the specific resource under a Management Group. A groupQuotaLimitRequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_CreateOrUpdate + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource name. + /// The GroupQuotaLimit Request. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string resourceName, GroupQuotaLimitData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _groupQuotaLimitRestClient.CreateOrUpdateAsync(Id.Name, _resourceProviderScope, _groupQuotaName, resourceName, data, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(new GroupQuotaLimitOperationSource(Client), _groupQuotaLimitClientDiagnostics, Pipeline, _groupQuotaLimitRestClient.CreateCreateOrUpdateRequest(Id.Name, _resourceProviderScope, _groupQuotaName, resourceName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates the GroupQuotaLimits for the specific resource under a Management Group. A groupQuotaLimitRequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_CreateOrUpdate + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource name. + /// The GroupQuotaLimit Request. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string resourceName, GroupQuotaLimitData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _groupQuotaLimitRestClient.CreateOrUpdate(Id.Name, _resourceProviderScope, _groupQuotaName, resourceName, data, cancellationToken); + var operation = new QuotaArmOperation(new GroupQuotaLimitOperationSource(Client), _groupQuotaLimitClientDiagnostics, Pipeline, _groupQuotaLimitRestClient.CreateCreateOrUpdateRequest(Id.Name, _resourceProviderScope, _groupQuotaName, resourceName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the resource groupQuotaLimits for the MGId. It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitCollection.Get"); + scope.Start(); + try + { + var response = await _groupQuotaLimitRestClient.GetAsync(Id.Name, _resourceProviderScope, _groupQuotaName, resourceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaLimitResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the resource groupQuotaLimits for the MGId. It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitCollection.Get"); + scope.Start(); + try + { + var response = _groupQuotaLimitRestClient.Get(Id.Name, _resourceProviderScope, _groupQuotaName, resourceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaLimitResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the List of resources groupQuotaLimits for the MGId, based on the scope. The scope can be - providers/Microsoft.Compute/locations/<eastus>. The list elements will be same as the Get API - It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits + /// + /// + /// Operation Id + /// GroupQuotaLimits_List + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _groupQuotaLimitRestClient.CreateListRequest(Id.Name, _resourceProviderScope, _groupQuotaName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _groupQuotaLimitRestClient.CreateListNextPageRequest(nextLink, Id.Name, _resourceProviderScope, _groupQuotaName); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new GroupQuotaLimitResource(Client, GroupQuotaLimitData.DeserializeGroupQuotaLimitData(e)), _groupQuotaLimitClientDiagnostics, Pipeline, "GroupQuotaLimitCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the List of resources groupQuotaLimits for the MGId, based on the scope. The scope can be - providers/Microsoft.Compute/locations/<eastus>. The list elements will be same as the Get API - It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits + /// + /// + /// Operation Id + /// GroupQuotaLimits_List + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _groupQuotaLimitRestClient.CreateListRequest(Id.Name, _resourceProviderScope, _groupQuotaName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _groupQuotaLimitRestClient.CreateListNextPageRequest(nextLink, Id.Name, _resourceProviderScope, _groupQuotaName); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new GroupQuotaLimitResource(Client, GroupQuotaLimitData.DeserializeGroupQuotaLimitData(e)), _groupQuotaLimitClientDiagnostics, Pipeline, "GroupQuotaLimitCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitCollection.Exists"); + scope.Start(); + try + { + var response = await _groupQuotaLimitRestClient.GetAsync(Id.Name, _resourceProviderScope, _groupQuotaName, resourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitCollection.Exists"); + scope.Start(); + try + { + var response = _groupQuotaLimitRestClient.Get(Id.Name, _resourceProviderScope, _groupQuotaName, resourceName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitData.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitData.cs new file mode 100644 index 000000000000..0e7b60888f4c --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitData.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A class representing the GroupQuotaLimit data model. + /// Group Quota limit. + /// + public partial class GroupQuotaLimitData : ResourceData + { + /// Initializes a new instance of GroupQuotaLimitData. + public GroupQuotaLimitData() + { + } + + /// Initializes a new instance of GroupQuotaLimitData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Group Quota properties for the specified resource. + internal GroupQuotaLimitData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, GroupQuotaDetails properties) : base(id, name, resourceType, systemData) + { + Properties = properties; + } + + /// Group Quota properties for the specified resource. + public GroupQuotaDetails Properties { get; set; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitResource.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitResource.cs new file mode 100644 index 000000000000..2182c66fe9fc --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaLimitResource.cs @@ -0,0 +1,247 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagementGroups; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A Class representing a GroupQuotaLimit along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetGroupQuotaLimitResource method. + /// Otherwise you can get one from its parent resource using the GetGroupQuotaLimit method. + /// + public partial class GroupQuotaLimitResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName) + { + var resourceId = $"/providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _groupQuotaLimitClientDiagnostics; + private readonly GroupQuotaLimitsRestOperations _groupQuotaLimitRestClient; + private readonly GroupQuotaLimitData _data; + + /// Initializes a new instance of the class for mocking. + protected GroupQuotaLimitResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal GroupQuotaLimitResource(ArmClient client, GroupQuotaLimitData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal GroupQuotaLimitResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _groupQuotaLimitClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string groupQuotaLimitApiVersion); + _groupQuotaLimitRestClient = new GroupQuotaLimitsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, groupQuotaLimitApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Quota/groupQuotas/groupQuotaLimits"; + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual GroupQuotaLimitData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Gets the resource groupQuotaLimits for the MGId. It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitResource.Get"); + scope.Start(); + try + { + var response = await _groupQuotaLimitRestClient.GetAsync(Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaLimitResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the resource groupQuotaLimits for the MGId. It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitResource.Get"); + scope.Start(); + try + { + var response = _groupQuotaLimitRestClient.Get(Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaLimitResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates the GroupQuotaLimits for the specific resource under a Management Group. A groupQuotaLimitRequestId will be returned by the Service. The status will be updated periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed,then the URI will change to Get URI and full details can be checked. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource name. + /// The GroupQuotaLimit Request. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, string resourceName, GroupQuotaLimitData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitResource.Update"); + scope.Start(); + try + { + var response = await _groupQuotaLimitRestClient.UpdateAsync(Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, data, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(new GroupQuotaLimitOperationSource(Client), _groupQuotaLimitClientDiagnostics, Pipeline, _groupQuotaLimitRestClient.CreateUpdateRequest(Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates the GroupQuotaLimits for the specific resource under a Management Group. A groupQuotaLimitRequestId will be returned by the Service. The status will be updated periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed,then the URI will change to Get URI and full details can be checked. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/groupQuotaLimits/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaLimits_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource name. + /// The GroupQuotaLimit Request. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation Update(WaitUntil waitUntil, string resourceName, GroupQuotaLimitData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _groupQuotaLimitClientDiagnostics.CreateScope("GroupQuotaLimitResource.Update"); + scope.Start(); + try + { + var response = _groupQuotaLimitRestClient.Update(Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, data, cancellationToken); + var operation = new QuotaArmOperation(new GroupQuotaLimitOperationSource(Client), _groupQuotaLimitClientDiagnostics, Pipeline, _groupQuotaLimitRestClient.CreateUpdateRequest(Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionCollection.cs new file mode 100644 index 000000000000..6e294db75b84 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionCollection.cs @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetGroupQuotaSubscriptions method from an instance of . + /// + public partial class GroupQuotaSubscriptionCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _groupQuotaSubscriptionClientDiagnostics; + private readonly GroupQuotaSubscriptionsRestOperations _groupQuotaSubscriptionRestClient; + + /// Initializes a new instance of the class for mocking. + protected GroupQuotaSubscriptionCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal GroupQuotaSubscriptionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _groupQuotaSubscriptionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", GroupQuotaSubscriptionResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(GroupQuotaSubscriptionResource.ResourceType, out string groupQuotaSubscriptionApiVersion); + _groupQuotaSubscriptionRestClient = new GroupQuotaSubscriptionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, groupQuotaSubscriptionApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != GroupQuotasEntityResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, GroupQuotasEntityResource.ResourceType), nameof(id)); + } + + /// + /// Adds a subscription to GroupQuotas. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_CreateOrUpdate + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _groupQuotaSubscriptionRestClient.CreateOrUpdateAsync(Id.Parent.Name, Id.Name, subscriptionId, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(new GroupQuotaSubscriptionOperationSource(Client), _groupQuotaSubscriptionClientDiagnostics, Pipeline, _groupQuotaSubscriptionRestClient.CreateCreateOrUpdateRequest(Id.Parent.Name, Id.Name, subscriptionId).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Adds a subscription to GroupQuotas. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_CreateOrUpdate + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _groupQuotaSubscriptionRestClient.CreateOrUpdate(Id.Parent.Name, Id.Name, subscriptionId, cancellationToken); + var operation = new QuotaArmOperation(new GroupQuotaSubscriptionOperationSource(Client), _groupQuotaSubscriptionClientDiagnostics, Pipeline, _groupQuotaSubscriptionRestClient.CreateCreateOrUpdateRequest(Id.Parent.Name, Id.Name, subscriptionId).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the subscriptionId along with its provisioning state for being associated with the GroupQuotasEntity. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Get + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionCollection.Get"); + scope.Start(); + try + { + var response = await _groupQuotaSubscriptionRestClient.GetAsync(Id.Parent.Name, Id.Name, subscriptionId, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaSubscriptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the subscriptionId along with its provisioning state for being associated with the GroupQuotasEntity. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Get + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionCollection.Get"); + scope.Start(); + try + { + var response = _groupQuotaSubscriptionRestClient.Get(Id.Parent.Name, Id.Name, subscriptionId, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaSubscriptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns a list of the subscriptionIds associated with the GroupQuotasEntity. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_List + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _groupQuotaSubscriptionRestClient.CreateListRequest(Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _groupQuotaSubscriptionRestClient.CreateListNextPageRequest(nextLink, Id.Parent.Name, Id.Name); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new GroupQuotaSubscriptionResource(Client, GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(e)), _groupQuotaSubscriptionClientDiagnostics, Pipeline, "GroupQuotaSubscriptionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Returns a list of the subscriptionIds associated with the GroupQuotasEntity. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_List + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _groupQuotaSubscriptionRestClient.CreateListRequest(Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _groupQuotaSubscriptionRestClient.CreateListNextPageRequest(nextLink, Id.Parent.Name, Id.Name); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new GroupQuotaSubscriptionResource(Client, GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(e)), _groupQuotaSubscriptionClientDiagnostics, Pipeline, "GroupQuotaSubscriptionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Get + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionCollection.Exists"); + scope.Start(); + try + { + var response = await _groupQuotaSubscriptionRestClient.GetAsync(Id.Parent.Name, Id.Name, subscriptionId, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Get + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionCollection.Exists"); + scope.Start(); + try + { + var response = _groupQuotaSubscriptionRestClient.Get(Id.Parent.Name, Id.Name, subscriptionId, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionIdData.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionIdData.cs new file mode 100644 index 000000000000..a927217f2386 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionIdData.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A class representing the GroupQuotaSubscriptionId data model. + /// This represents a Azure subscriptionId that is associated with a GroupQuotaSEntity. + /// + public partial class GroupQuotaSubscriptionIdData : ResourceData + { + /// Initializes a new instance of GroupQuotaSubscriptionIdData. + public GroupQuotaSubscriptionIdData() + { + } + + /// Initializes a new instance of GroupQuotaSubscriptionIdData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// + internal GroupQuotaSubscriptionIdData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, GroupQuotaSubscriptionIdProperties properties) : base(id, name, resourceType, systemData) + { + Properties = properties; + } + + /// Gets or sets the properties. + public GroupQuotaSubscriptionIdProperties Properties { get; set; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionRequestCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionRequestCollection.cs new file mode 100644 index 000000000000..29233b81e990 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionRequestCollection.cs @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetGroupQuotaSubscriptionRequests method from an instance of . + /// + public partial class GroupQuotaSubscriptionRequestCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics; + private readonly SubscriptionRequestsRestOperations _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient; + + /// Initializes a new instance of the class for mocking. + protected GroupQuotaSubscriptionRequestCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal GroupQuotaSubscriptionRequestCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", GroupQuotaSubscriptionRequestResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(GroupQuotaSubscriptionRequestResource.ResourceType, out string groupQuotaSubscriptionRequestSubscriptionRequestsApiVersion); + _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient = new SubscriptionRequestsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, groupQuotaSubscriptionRequestSubscriptionRequestsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != GroupQuotasEntityResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, GroupQuotasEntityResource.ResourceType), nameof(id)); + } + + /// + /// Get API to check the status of a subscriptionIds request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests/{requestId} + /// + /// + /// Operation Id + /// SubscriptionRequests_Get + /// + /// + /// + /// Request Id. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + using var scope = _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics.CreateScope("GroupQuotaSubscriptionRequestCollection.Get"); + scope.Start(); + try + { + var response = await _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.GetAsync(Id.Parent.Name, Id.Name, requestId, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaSubscriptionRequestResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get API to check the status of a subscriptionIds request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests/{requestId} + /// + /// + /// Operation Id + /// SubscriptionRequests_Get + /// + /// + /// + /// Request Id. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + using var scope = _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics.CreateScope("GroupQuotaSubscriptionRequestCollection.Get"); + scope.Start(); + try + { + var response = _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.Get(Id.Parent.Name, Id.Name, requestId, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaSubscriptionRequestResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List API to check the status of a subscriptionId requests by requestId. Request history is maintained for 1 year. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests + /// + /// + /// Operation Id + /// SubscriptionRequests_List + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.CreateListRequest(Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.CreateListNextPageRequest(nextLink, Id.Parent.Name, Id.Name); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new GroupQuotaSubscriptionRequestResource(Client, GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(e)), _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics, Pipeline, "GroupQuotaSubscriptionRequestCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List API to check the status of a subscriptionId requests by requestId. Request history is maintained for 1 year. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests + /// + /// + /// Operation Id + /// SubscriptionRequests_List + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.CreateListRequest(Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.CreateListNextPageRequest(nextLink, Id.Parent.Name, Id.Name); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new GroupQuotaSubscriptionRequestResource(Client, GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(e)), _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics, Pipeline, "GroupQuotaSubscriptionRequestCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests/{requestId} + /// + /// + /// Operation Id + /// SubscriptionRequests_Get + /// + /// + /// + /// Request Id. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + using var scope = _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics.CreateScope("GroupQuotaSubscriptionRequestCollection.Exists"); + scope.Start(); + try + { + var response = await _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.GetAsync(Id.Parent.Name, Id.Name, requestId, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests/{requestId} + /// + /// + /// Operation Id + /// SubscriptionRequests_Get + /// + /// + /// + /// Request Id. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + using var scope = _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics.CreateScope("GroupQuotaSubscriptionRequestCollection.Exists"); + scope.Start(); + try + { + var response = _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.Get(Id.Parent.Name, Id.Name, requestId, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionRequestResource.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionRequestResource.cs new file mode 100644 index 000000000000..3622077cc8bc --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionRequestResource.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A Class representing a GroupQuotaSubscriptionRequest along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetGroupQuotaSubscriptionRequestResource method. + /// Otherwise you can get one from its parent resource using the GetGroupQuotaSubscriptionRequest method. + /// + public partial class GroupQuotaSubscriptionRequestResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string mgId, string groupQuotaName, string requestId) + { + var resourceId = $"/providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests/{requestId}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics; + private readonly SubscriptionRequestsRestOperations _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient; + private readonly GroupQuotaSubscriptionIdData _data; + + /// Initializes a new instance of the class for mocking. + protected GroupQuotaSubscriptionRequestResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal GroupQuotaSubscriptionRequestResource(ArmClient client, GroupQuotaSubscriptionIdData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal GroupQuotaSubscriptionRequestResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string groupQuotaSubscriptionRequestSubscriptionRequestsApiVersion); + _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient = new SubscriptionRequestsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, groupQuotaSubscriptionRequestSubscriptionRequestsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Quota/groupQuotas/subscriptionRequests"; + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual GroupQuotaSubscriptionIdData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get API to check the status of a subscriptionIds request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests/{requestId} + /// + /// + /// Operation Id + /// SubscriptionRequests_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics.CreateScope("GroupQuotaSubscriptionRequestResource.Get"); + scope.Start(); + try + { + var response = await _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.GetAsync(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaSubscriptionRequestResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get API to check the status of a subscriptionIds request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests/{requestId} + /// + /// + /// Operation Id + /// SubscriptionRequests_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _groupQuotaSubscriptionRequestSubscriptionRequestsClientDiagnostics.CreateScope("GroupQuotaSubscriptionRequestResource.Get"); + scope.Start(); + try + { + var response = _groupQuotaSubscriptionRequestSubscriptionRequestsRestClient.Get(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaSubscriptionRequestResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionResource.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionResource.cs new file mode 100644 index 000000000000..e3b8e67328ab --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotaSubscriptionResource.cs @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A Class representing a GroupQuotaSubscription along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetGroupQuotaSubscriptionResource method. + /// Otherwise you can get one from its parent resource using the GetGroupQuotaSubscription method. + /// + public partial class GroupQuotaSubscriptionResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string mgId, string groupQuotaName, string subscriptionId) + { + var resourceId = $"/providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _groupQuotaSubscriptionClientDiagnostics; + private readonly GroupQuotaSubscriptionsRestOperations _groupQuotaSubscriptionRestClient; + private readonly GroupQuotaSubscriptionIdData _data; + + /// Initializes a new instance of the class for mocking. + protected GroupQuotaSubscriptionResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal GroupQuotaSubscriptionResource(ArmClient client, GroupQuotaSubscriptionIdData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal GroupQuotaSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _groupQuotaSubscriptionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string groupQuotaSubscriptionApiVersion); + _groupQuotaSubscriptionRestClient = new GroupQuotaSubscriptionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, groupQuotaSubscriptionApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Quota/groupQuotas/subscriptions"; + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual GroupQuotaSubscriptionIdData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Returns the subscriptionId along with its provisioning state for being associated with the GroupQuotasEntity. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionResource.Get"); + scope.Start(); + try + { + var response = await _groupQuotaSubscriptionRestClient.GetAsync(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaSubscriptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the subscriptionId along with its provisioning state for being associated with the GroupQuotasEntity. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionResource.Get"); + scope.Start(); + try + { + var response = _groupQuotaSubscriptionRestClient.Get(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotaSubscriptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes the subscription from GroupQuotas. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Delete + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionResource.Delete"); + scope.Start(); + try + { + var response = await _groupQuotaSubscriptionRestClient.DeleteAsync(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(response); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes the subscription from GroupQuotas. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Delete + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionResource.Delete"); + scope.Start(); + try + { + var response = _groupQuotaSubscriptionRestClient.Delete(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new QuotaArmOperation(response); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates the GroupQuotas with the subscription to add to the subscriptions list. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionResource.Update"); + scope.Start(); + try + { + var response = await _groupQuotaSubscriptionRestClient.UpdateAsync(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(new GroupQuotaSubscriptionOperationSource(Client), _groupQuotaSubscriptionClientDiagnostics, Pipeline, _groupQuotaSubscriptionRestClient.CreateUpdateRequest(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates the GroupQuotas with the subscription to add to the subscriptions list. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Update(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _groupQuotaSubscriptionClientDiagnostics.CreateScope("GroupQuotaSubscriptionResource.Update"); + scope.Start(); + try + { + var response = _groupQuotaSubscriptionRestClient.Update(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new QuotaArmOperation(new GroupQuotaSubscriptionOperationSource(Client), _groupQuotaSubscriptionClientDiagnostics, Pipeline, _groupQuotaSubscriptionRestClient.CreateUpdateRequest(Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityCollection.cs new file mode 100644 index 000000000000..a0bea717b6c5 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityCollection.cs @@ -0,0 +1,341 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagementGroups; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetGroupQuotasEntities method from an instance of . + /// + public partial class GroupQuotasEntityCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _groupQuotasEntityGroupQuotasClientDiagnostics; + private readonly GroupQuotasRestOperations _groupQuotasEntityGroupQuotasRestClient; + + /// Initializes a new instance of the class for mocking. + protected GroupQuotasEntityCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal GroupQuotasEntityCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _groupQuotasEntityGroupQuotasClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", GroupQuotasEntityResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(GroupQuotasEntityResource.ResourceType, out string groupQuotasEntityGroupQuotasApiVersion); + _groupQuotasEntityGroupQuotasRestClient = new GroupQuotasRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, groupQuotasEntityGroupQuotasApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ManagementGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagementGroupResource.ResourceType), nameof(id)); + } + + /// + /// Creates a new GroupQuota for the name passed. A RequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_CreateOrUpdate + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The GroupQuota body details for creation or update of a GroupQuota entity. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string groupQuotaName, GroupQuotasEntityData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _groupQuotasEntityGroupQuotasRestClient.CreateOrUpdateAsync(Id.Name, groupQuotaName, data, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(new GroupQuotasEntityOperationSource(Client), _groupQuotasEntityGroupQuotasClientDiagnostics, Pipeline, _groupQuotasEntityGroupQuotasRestClient.CreateCreateOrUpdateRequest(Id.Name, groupQuotaName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates a new GroupQuota for the name passed. A RequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_CreateOrUpdate + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The GroupQuota body details for creation or update of a GroupQuota entity. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string groupQuotaName, GroupQuotasEntityData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _groupQuotasEntityGroupQuotasRestClient.CreateOrUpdate(Id.Name, groupQuotaName, data, cancellationToken); + var operation = new QuotaArmOperation(new GroupQuotasEntityOperationSource(Client), _groupQuotasEntityGroupQuotasClientDiagnostics, Pipeline, _groupQuotasEntityGroupQuotasRestClient.CreateCreateOrUpdateRequest(Id.Name, groupQuotaName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the GroupQuotas for the name passed. It will return the GroupQuotas properties only. The details on groupQuota can be access from the groupQuota APIs. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Get + /// + /// + /// + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityCollection.Get"); + scope.Start(); + try + { + var response = await _groupQuotasEntityGroupQuotasRestClient.GetAsync(Id.Name, groupQuotaName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotasEntityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the GroupQuotas for the name passed. It will return the GroupQuotas properties only. The details on groupQuota can be access from the groupQuota APIs. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Get + /// + /// + /// + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityCollection.Get"); + scope.Start(); + try + { + var response = _groupQuotasEntityGroupQuotasRestClient.Get(Id.Name, groupQuotaName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotasEntityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists GroupQuotas for the scope passed. It will return the GroupQuotas QuotaEntity properties only.The details on groupQuota can be access from the groupQuota APIs. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas + /// + /// + /// Operation Id + /// GroupQuotas_List + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _groupQuotasEntityGroupQuotasRestClient.CreateListRequest(Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _groupQuotasEntityGroupQuotasRestClient.CreateListNextPageRequest(nextLink, Id.Name); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new GroupQuotasEntityResource(Client, GroupQuotasEntityData.DeserializeGroupQuotasEntityData(e)), _groupQuotasEntityGroupQuotasClientDiagnostics, Pipeline, "GroupQuotasEntityCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists GroupQuotas for the scope passed. It will return the GroupQuotas QuotaEntity properties only.The details on groupQuota can be access from the groupQuota APIs. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas + /// + /// + /// Operation Id + /// GroupQuotas_List + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _groupQuotasEntityGroupQuotasRestClient.CreateListRequest(Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _groupQuotasEntityGroupQuotasRestClient.CreateListNextPageRequest(nextLink, Id.Name); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new GroupQuotasEntityResource(Client, GroupQuotasEntityData.DeserializeGroupQuotasEntityData(e)), _groupQuotasEntityGroupQuotasClientDiagnostics, Pipeline, "GroupQuotasEntityCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Get + /// + /// + /// + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityCollection.Exists"); + scope.Start(); + try + { + var response = await _groupQuotasEntityGroupQuotasRestClient.GetAsync(Id.Name, groupQuotaName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Get + /// + /// + /// + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityCollection.Exists"); + scope.Start(); + try + { + var response = _groupQuotasEntityGroupQuotasRestClient.Get(Id.Name, groupQuotaName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityData.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityData.cs new file mode 100644 index 000000000000..c0c4bda9dde6 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityData.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A class representing the GroupQuotasEntity data model. + /// Properties and filters for ShareQuota. The request parameter is optional, if there are no filters specified. + /// + public partial class GroupQuotasEntityData : ResourceData + { + /// Initializes a new instance of GroupQuotasEntityData. + public GroupQuotasEntityData() + { + } + + /// Initializes a new instance of GroupQuotasEntityData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Properties and filters for ShareQuota. The request parameter is optional, if there are no filters specified. + internal GroupQuotasEntityData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, GroupQuotasEntityBase properties) : base(id, name, resourceType, systemData) + { + Properties = properties; + } + + /// Properties and filters for ShareQuota. The request parameter is optional, if there are no filters specified. + public GroupQuotasEntityBase Properties { get; set; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityResource.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityResource.cs new file mode 100644 index 000000000000..afdae9de5b5c --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/GroupQuotasEntityResource.cs @@ -0,0 +1,406 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagementGroups; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A Class representing a GroupQuotasEntity along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetGroupQuotasEntityResource method. + /// Otherwise you can get one from its parent resource using the GetGroupQuotasEntity method. + /// + public partial class GroupQuotasEntityResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string mgId, string groupQuotaName) + { + var resourceId = $"/providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _groupQuotasEntityGroupQuotasClientDiagnostics; + private readonly GroupQuotasRestOperations _groupQuotasEntityGroupQuotasRestClient; + private readonly GroupQuotasEntityData _data; + + /// Initializes a new instance of the class for mocking. + protected GroupQuotasEntityResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal GroupQuotasEntityResource(ArmClient client, GroupQuotasEntityData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal GroupQuotasEntityResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _groupQuotasEntityGroupQuotasClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string groupQuotasEntityGroupQuotasApiVersion); + _groupQuotasEntityGroupQuotasRestClient = new GroupQuotasRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, groupQuotasEntityGroupQuotasApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Quota/groupQuotas"; + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual GroupQuotasEntityData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of GroupQuotaSubscriptionResources in the GroupQuotasEntity. + /// An object representing collection of GroupQuotaSubscriptionResources and their operations over a GroupQuotaSubscriptionResource. + public virtual GroupQuotaSubscriptionCollection GetGroupQuotaSubscriptions() + { + return GetCachedClient(Client => new GroupQuotaSubscriptionCollection(Client, Id)); + } + + /// + /// Returns the subscriptionId along with its provisioning state for being associated with the GroupQuotasEntity. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Get + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetGroupQuotaSubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + return await GetGroupQuotaSubscriptions().GetAsync(subscriptionId, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns the subscriptionId along with its provisioning state for being associated with the GroupQuotasEntity. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptions/{subscriptionId} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptions_Get + /// + /// + /// + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetGroupQuotaSubscription(string subscriptionId, CancellationToken cancellationToken = default) + { + return GetGroupQuotaSubscriptions().Get(subscriptionId, cancellationToken); + } + + /// Gets a collection of GroupQuotaSubscriptionRequestResources in the GroupQuotasEntity. + /// An object representing collection of GroupQuotaSubscriptionRequestResources and their operations over a GroupQuotaSubscriptionRequestResource. + public virtual GroupQuotaSubscriptionRequestCollection GetGroupQuotaSubscriptionRequests() + { + return GetCachedClient(Client => new GroupQuotaSubscriptionRequestCollection(Client, Id)); + } + + /// + /// Get API to check the status of a subscriptionIds request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests/{requestId} + /// + /// + /// Operation Id + /// SubscriptionRequests_Get + /// + /// + /// + /// Request Id. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetGroupQuotaSubscriptionRequestAsync(string requestId, CancellationToken cancellationToken = default) + { + return await GetGroupQuotaSubscriptionRequests().GetAsync(requestId, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get API to check the status of a subscriptionIds request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/subscriptionRequests/{requestId} + /// + /// + /// Operation Id + /// SubscriptionRequests_Get + /// + /// + /// + /// Request Id. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetGroupQuotaSubscriptionRequest(string requestId, CancellationToken cancellationToken = default) + { + return GetGroupQuotaSubscriptionRequests().Get(requestId, cancellationToken); + } + + /// + /// Gets the GroupQuotas for the name passed. It will return the GroupQuotas properties only. The details on groupQuota can be access from the groupQuota APIs. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityResource.Get"); + scope.Start(); + try + { + var response = await _groupQuotasEntityGroupQuotasRestClient.GetAsync(Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotasEntityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the GroupQuotas for the name passed. It will return the GroupQuotas properties only. The details on groupQuota can be access from the groupQuota APIs. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityResource.Get"); + scope.Start(); + try + { + var response = _groupQuotasEntityGroupQuotasRestClient.Get(Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new GroupQuotasEntityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the GroupQuotas for the name passed. All the remaining shareQuota in the GroupQuotas will be lost. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Delete + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityResource.Delete"); + scope.Start(); + try + { + var response = await _groupQuotasEntityGroupQuotasRestClient.DeleteAsync(Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(response); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the GroupQuotas for the name passed. All the remaining shareQuota in the GroupQuotas will be lost. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Delete + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityResource.Delete"); + scope.Start(); + try + { + var response = _groupQuotasEntityGroupQuotasRestClient.Delete(Id.Parent.Name, Id.Name, cancellationToken); + var operation = new QuotaArmOperation(response); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates the GroupQuotas for the name passed. A GroupQuotas RequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// Any change in the filters will be applicable to the future quota assignments, existing quota assigned to subscriptions from the GroupQuotas remains unchanged. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The GroupQuotas Patch Request. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, GroupQuotasEntityData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityResource.Update"); + scope.Start(); + try + { + var response = await _groupQuotasEntityGroupQuotasRestClient.UpdateAsync(Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(new GroupQuotasEntityOperationSource(Client), _groupQuotasEntityGroupQuotasClientDiagnostics, Pipeline, _groupQuotasEntityGroupQuotasRestClient.CreateUpdateRequest(Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates the GroupQuotas for the name passed. A GroupQuotas RequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// Any change in the filters will be applicable to the future quota assignments, existing quota assigned to subscriptions from the GroupQuotas remains unchanged. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName} + /// + /// + /// Operation Id + /// GroupQuotas_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The GroupQuotas Patch Request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, GroupQuotasEntityData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _groupQuotasEntityGroupQuotasClientDiagnostics.CreateScope("GroupQuotasEntityResource.Update"); + scope.Start(); + try + { + var response = _groupQuotasEntityGroupQuotasRestClient.Update(Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new QuotaArmOperation(new GroupQuotasEntityOperationSource(Client), _groupQuotasEntityGroupQuotasClientDiagnostics, Pipeline, _groupQuotasEntityGroupQuotasRestClient.CreateUpdateRequest(Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotaLimitOperationSource.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotaLimitOperationSource.cs new file mode 100644 index 000000000000..4f709f7b2c02 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotaLimitOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Quota +{ + internal class GroupQuotaLimitOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal GroupQuotaLimitOperationSource(ArmClient client) + { + _client = client; + } + + GroupQuotaLimitResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = GroupQuotaLimitData.DeserializeGroupQuotaLimitData(document.RootElement); + return new GroupQuotaLimitResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = GroupQuotaLimitData.DeserializeGroupQuotaLimitData(document.RootElement); + return new GroupQuotaLimitResource(_client, data); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotaSubscriptionOperationSource.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotaSubscriptionOperationSource.cs new file mode 100644 index 000000000000..ff89d40d41cf --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotaSubscriptionOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Quota +{ + internal class GroupQuotaSubscriptionOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal GroupQuotaSubscriptionOperationSource(ArmClient client) + { + _client = client; + } + + GroupQuotaSubscriptionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(document.RootElement); + return new GroupQuotaSubscriptionResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(document.RootElement); + return new GroupQuotaSubscriptionResource(_client, data); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotasEntityOperationSource.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotasEntityOperationSource.cs new file mode 100644 index 000000000000..1e961482f032 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/GroupQuotasEntityOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Quota +{ + internal class GroupQuotasEntityOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal GroupQuotasEntityOperationSource(ArmClient client) + { + _client = client; + } + + GroupQuotasEntityResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = GroupQuotasEntityData.DeserializeGroupQuotasEntityData(document.RootElement); + return new GroupQuotasEntityResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = GroupQuotasEntityData.DeserializeGroupQuotasEntityData(document.RootElement); + return new GroupQuotasEntityResource(_client, data); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/QuotaArmOperation.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/QuotaArmOperation.cs new file mode 100644 index 000000000000..2ead8fb897da --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/QuotaArmOperation.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Quota +{ +#pragma warning disable SA1649 // File name should match first type name + internal class QuotaArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + + /// Initializes a new instance of QuotaArmOperation for mocking. + protected QuotaArmOperation() + { + } + + internal QuotaArmOperation(Response response) + { + _operation = OperationInternal.Succeeded(response); + } + + internal QuotaArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "QuotaArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + /// +#pragma warning disable CA1822 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public override string Id => throw new NotImplementedException(); +#pragma warning restore CA1822 + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/SubscriptionQuotaAllocationOperationSource.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/SubscriptionQuotaAllocationOperationSource.cs new file mode 100644 index 000000000000..b567f587113d --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/LongRunningOperation/SubscriptionQuotaAllocationOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Quota +{ + internal class SubscriptionQuotaAllocationOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal SubscriptionQuotaAllocationOperationSource(ArmClient client) + { + _client = client; + } + + SubscriptionQuotaAllocationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = SubscriptionQuotaAllocationData.DeserializeSubscriptionQuotaAllocationData(document.RootElement); + return new SubscriptionQuotaAllocationResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = SubscriptionQuotaAllocationData.DeserializeSubscriptionQuotaAllocationData(document.RootElement); + return new SubscriptionQuotaAllocationResource(_client, data); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AdditionalAttributes.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AdditionalAttributes.Serialization.cs new file mode 100644 index 000000000000..407dfa7a2a8c --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AdditionalAttributes.Serialization.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + public partial class AdditionalAttributes : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("groupId"u8); + writer.WriteObjectValue(GroupId); + if (Optional.IsDefined(Environment)) + { + writer.WritePropertyName("environment"u8); + writer.WriteStringValue(Environment.Value.ToString()); + } + writer.WriteEndObject(); + } + + internal static AdditionalAttributes DeserializeAdditionalAttributes(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GroupingId groupId = default; + Optional environment = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("groupId"u8)) + { + groupId = GroupingId.DeserializeGroupingId(property.Value); + continue; + } + if (property.NameEquals("environment"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + environment = new EnvironmentType(property.Value.GetString()); + continue; + } + } + return new AdditionalAttributes(groupId, Optional.ToNullable(environment)); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AdditionalAttributes.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AdditionalAttributes.cs new file mode 100644 index 000000000000..7004106a99de --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AdditionalAttributes.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + /// Additional attribute to allow subscriptions to be part of the GroupQuota. + public partial class AdditionalAttributes + { + /// Initializes a new instance of AdditionalAttributes. + /// The grouping Id for the group quota. It can be management Group Id or ServiceTreeId if applicable. + /// is null. + public AdditionalAttributes(GroupingId groupId) + { + Argument.AssertNotNull(groupId, nameof(groupId)); + + GroupId = groupId; + } + + /// Initializes a new instance of AdditionalAttributes. + /// The grouping Id for the group quota. It can be management Group Id or ServiceTreeId if applicable. + /// Environment name. + internal AdditionalAttributes(GroupingId groupId, EnvironmentType? environment) + { + GroupId = groupId; + Environment = environment; + } + + /// The grouping Id for the group quota. It can be management Group Id or ServiceTreeId if applicable. + public GroupingId GroupId { get; set; } + /// Environment name. + public EnvironmentType? Environment { get; set; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AssignedToSubscription.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AssignedToSubscription.Serialization.cs new file mode 100644 index 000000000000..df1496dbdcf4 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AssignedToSubscription.Serialization.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + public partial class AssignedToSubscription + { + internal static AssignedToSubscription DeserializeAssignedToSubscription(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional subscriptionId = default; + Optional quotaAllocated = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("subscriptionId"u8)) + { + subscriptionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("quotaAllocated"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + quotaAllocated = property.Value.GetInt64(); + continue; + } + } + return new AssignedToSubscription(subscriptionId.Value, Optional.ToNullable(quotaAllocated)); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AssignedToSubscription.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AssignedToSubscription.cs new file mode 100644 index 000000000000..2f713ed78b4b --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/AssignedToSubscription.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// SubscriptionIds and quota allocated to subscriptions from the GroupQuota. + public partial class AssignedToSubscription + { + /// Initializes a new instance of AssignedToSubscription. + internal AssignedToSubscription() + { + } + + /// Initializes a new instance of AssignedToSubscription. + /// An Azure subscriptionId. + /// The amount of quota allocated to this subscriptionId from the GroupQuotasEntity. + internal AssignedToSubscription(string subscriptionId, long? quotaAllocated) + { + SubscriptionId = subscriptionId; + QuotaAllocated = quotaAllocated; + } + + /// An Azure subscriptionId. + public string SubscriptionId { get; } + /// The amount of quota allocated to this subscriptionId from the GroupQuotasEntity. + public long? QuotaAllocated { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/EnvironmentType.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/EnvironmentType.cs new file mode 100644 index 000000000000..7063cc082acd --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/EnvironmentType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Quota.Models +{ + /// Environment name. + public readonly partial struct EnvironmentType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EnvironmentType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NonProductionValue = "NonProduction"; + private const string ProductionValue = "Production"; + + /// NonProduction. + public static EnvironmentType NonProduction { get; } = new EnvironmentType(NonProductionValue); + /// Production. + public static EnvironmentType Production { get; } = new EnvironmentType(ProductionValue); + /// Determines if two values are the same. + public static bool operator ==(EnvironmentType left, EnvironmentType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EnvironmentType left, EnvironmentType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator EnvironmentType(string value) => new EnvironmentType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EnvironmentType other && Equals(other); + /// + public bool Equals(EnvironmentType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetails.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetails.Serialization.cs new file mode 100644 index 000000000000..a697ccc565cf --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetails.Serialization.cs @@ -0,0 +1,116 @@ +// 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.Quota.Models +{ + public partial class GroupQuotaDetails : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Limit)) + { + writer.WritePropertyName("limit"u8); + writer.WriteNumberValue(Limit.Value); + } + if (Optional.IsDefined(Comment)) + { + writer.WritePropertyName("comment"u8); + writer.WriteStringValue(Comment); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteObjectValue(Name); + } + writer.WriteEndObject(); + } + + internal static GroupQuotaDetails DeserializeGroupQuotaDetails(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional limit = default; + Optional comment = default; + Optional name = default; + Optional unit = default; + Optional availableLimit = default; + Optional> assignedToSubscriptions = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("limit"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + limit = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("comment"u8)) + { + comment = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + name = GroupQuotaDetailsName.DeserializeGroupQuotaDetailsName(property.Value); + continue; + } + if (property.NameEquals("unit"u8)) + { + unit = property.Value.GetString(); + continue; + } + if (property.NameEquals("availableLimit"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + availableLimit = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("assignedToSubscriptions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AssignedToSubscription.DeserializeAssignedToSubscription(item)); + } + assignedToSubscriptions = array; + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new RequestState(property.Value.GetString()); + continue; + } + } + return new GroupQuotaDetails(Optional.ToNullable(limit), comment.Value, name.Value, unit.Value, Optional.ToNullable(availableLimit), Optional.ToList(assignedToSubscriptions), Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetails.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetails.cs new file mode 100644 index 000000000000..1d11caf79195 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetails.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + /// Group Quota details. + public partial class GroupQuotaDetails + { + /// Initializes a new instance of GroupQuotaDetails. + public GroupQuotaDetails() + { + AssignedToSubscriptions = new ChangeTrackingList(); + } + + /// Initializes a new instance of GroupQuotaDetails. + /// The current Group Quota Limit at the parentId level. + /// Any comment related to quota request. + /// Name of the resource provided by the resource Provider. This property is already included in the request URI, so it is a readonly property returned in the response. + /// The usages units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. + /// The available Group Quota Limit at the MG level. This Group quota can be assigned to subscription(s). + /// Assigned Group Quota to subscriptions. + /// Request status. + internal GroupQuotaDetails(long? limit, string comment, GroupQuotaDetailsName name, string unit, long? availableLimit, IReadOnlyList assignedToSubscriptions, RequestState? provisioningState) + { + Limit = limit; + Comment = comment; + Name = name; + Unit = unit; + AvailableLimit = availableLimit; + AssignedToSubscriptions = assignedToSubscriptions; + ProvisioningState = provisioningState; + } + + /// The current Group Quota Limit at the parentId level. + public long? Limit { get; set; } + /// Any comment related to quota request. + public string Comment { get; set; } + /// Name of the resource provided by the resource Provider. This property is already included in the request URI, so it is a readonly property returned in the response. + public GroupQuotaDetailsName Name { get; set; } + /// The usages units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. + public string Unit { get; } + /// The available Group Quota Limit at the MG level. This Group quota can be assigned to subscription(s). + public long? AvailableLimit { get; } + /// Assigned Group Quota to subscriptions. + public IReadOnlyList AssignedToSubscriptions { get; } + /// Request status. + public RequestState? ProvisioningState { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetailsName.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetailsName.Serialization.cs new file mode 100644 index 000000000000..08c91e3fcbf3 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetailsName.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + public partial class GroupQuotaDetailsName : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } + + internal static GroupQuotaDetailsName DeserializeGroupQuotaDetailsName(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional value = default; + Optional localizedValue = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("localizedValue"u8)) + { + localizedValue = property.Value.GetString(); + continue; + } + } + return new GroupQuotaDetailsName(value.Value, localizedValue.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetailsName.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetailsName.cs new file mode 100644 index 000000000000..31f320dc071b --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaDetailsName.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// Name of the resource provided by the resource Provider. This property is already included in the request URI, so it is a readonly property returned in the response. + public partial class GroupQuotaDetailsName + { + /// Initializes a new instance of GroupQuotaDetailsName. + public GroupQuotaDetailsName() + { + } + + /// Initializes a new instance of GroupQuotaDetailsName. + /// Resource name. + /// Resource display name. + internal GroupQuotaDetailsName(string value, string localizedValue) + { + Value = value; + LocalizedValue = localizedValue; + } + + /// Resource name. + public string Value { get; } + /// Resource display name. + public string LocalizedValue { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitData.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitData.Serialization.cs new file mode 100644 index 000000000000..02874e9c1f99 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitData.Serialization.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + public partial class GroupQuotaLimitData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties); + } + writer.WriteEndObject(); + } + + internal static GroupQuotaLimitData DeserializeGroupQuotaLimitData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = GroupQuotaDetails.DeserializeGroupQuotaDetails(property.Value); + 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) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + } + return new GroupQuotaLimitData(id, name, type, systemData.Value, properties.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitList.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitList.Serialization.cs new file mode 100644 index 000000000000..5cf872f3a9ab --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitList.Serialization.cs @@ -0,0 +1,50 @@ +// 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; +using Azure.ResourceManager.Quota; + +namespace Azure.ResourceManager.Quota.Models +{ + internal partial class GroupQuotaLimitList + { + internal static GroupQuotaLimitList DeserializeGroupQuotaLimitList(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(GroupQuotaLimitData.DeserializeGroupQuotaLimitData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new GroupQuotaLimitList(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitList.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitList.cs new file mode 100644 index 000000000000..1a6532f97aab --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaLimitList.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Quota; + +namespace Azure.ResourceManager.Quota.Models +{ + /// List of Group Quota Limit details. + internal partial class GroupQuotaLimitList + { + /// Initializes a new instance of GroupQuotaLimitList. + internal GroupQuotaLimitList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of GroupQuotaLimitList. + /// List of Group Quota Limit details. + /// The URL to use for getting the next set of results. + internal GroupQuotaLimitList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// List of Group Quota Limit details. + public IReadOnlyList Value { get; } + /// The URL to use for getting the next set of results. + public string NextLink { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaList.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaList.Serialization.cs new file mode 100644 index 000000000000..f43c614ed2cf --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaList.Serialization.cs @@ -0,0 +1,50 @@ +// 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; +using Azure.ResourceManager.Quota; + +namespace Azure.ResourceManager.Quota.Models +{ + internal partial class GroupQuotaList + { + internal static GroupQuotaList DeserializeGroupQuotaList(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(GroupQuotasEntityData.DeserializeGroupQuotasEntityData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new GroupQuotaList(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaList.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaList.cs new file mode 100644 index 000000000000..196918be18fa --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaList.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Quota; + +namespace Azure.ResourceManager.Quota.Models +{ + /// List of Group Quotas at MG level. + internal partial class GroupQuotaList + { + /// Initializes a new instance of GroupQuotaList. + internal GroupQuotaList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of GroupQuotaList. + /// List of Group Quotas at MG level. + /// The URL to use for getting the next set of results. + internal GroupQuotaList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// List of Group Quotas at MG level. + public IReadOnlyList Value { get; } + /// The URL to use for getting the next set of results. + public string NextLink { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdData.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdData.Serialization.cs new file mode 100644 index 000000000000..bb20969a3e41 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdData.Serialization.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + public partial class GroupQuotaSubscriptionIdData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties); + } + writer.WriteEndObject(); + } + + internal static GroupQuotaSubscriptionIdData DeserializeGroupQuotaSubscriptionIdData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = GroupQuotaSubscriptionIdProperties.DeserializeGroupQuotaSubscriptionIdProperties(property.Value); + 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) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + } + return new GroupQuotaSubscriptionIdData(id, name, type, systemData.Value, properties.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdList.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdList.Serialization.cs new file mode 100644 index 000000000000..aeabd6ec2d75 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdList.Serialization.cs @@ -0,0 +1,50 @@ +// 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; +using Azure.ResourceManager.Quota; + +namespace Azure.ResourceManager.Quota.Models +{ + internal partial class GroupQuotaSubscriptionIdList + { + internal static GroupQuotaSubscriptionIdList DeserializeGroupQuotaSubscriptionIdList(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new GroupQuotaSubscriptionIdList(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdList.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdList.cs new file mode 100644 index 000000000000..46b78af69a66 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdList.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Quota; + +namespace Azure.ResourceManager.Quota.Models +{ + /// List of GroupQuotaSubscriptionIds. + internal partial class GroupQuotaSubscriptionIdList + { + /// Initializes a new instance of GroupQuotaSubscriptionIdList. + internal GroupQuotaSubscriptionIdList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of GroupQuotaSubscriptionIdList. + /// List of GroupQuotaSubscriptionIds. + /// The URL to use for getting the next set of results. + internal GroupQuotaSubscriptionIdList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// List of GroupQuotaSubscriptionIds. + public IReadOnlyList Value { get; } + /// The URL to use for getting the next set of results. + public string NextLink { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdProperties.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdProperties.Serialization.cs new file mode 100644 index 000000000000..42b3c8fabf84 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdProperties.Serialization.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + public partial class GroupQuotaSubscriptionIdProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } + + internal static GroupQuotaSubscriptionIdProperties DeserializeGroupQuotaSubscriptionIdProperties(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional subscriptionId = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("subscriptionId"u8)) + { + subscriptionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new RequestState(property.Value.GetString()); + continue; + } + } + return new GroupQuotaSubscriptionIdProperties(subscriptionId.Value, Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdProperties.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdProperties.cs new file mode 100644 index 000000000000..422315a140f1 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotaSubscriptionIdProperties.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// The GroupQuotaSubscriptionIdProperties. + public partial class GroupQuotaSubscriptionIdProperties + { + /// Initializes a new instance of GroupQuotaSubscriptionIdProperties. + public GroupQuotaSubscriptionIdProperties() + { + } + + /// Initializes a new instance of GroupQuotaSubscriptionIdProperties. + /// An Azure subscriptionId. + /// Status of this subscriptionId being associated with the GroupQuotasEntity. + internal GroupQuotaSubscriptionIdProperties(string subscriptionId, RequestState? provisioningState) + { + SubscriptionId = subscriptionId; + ProvisioningState = provisioningState; + } + + /// An Azure subscriptionId. + public string SubscriptionId { get; } + /// Status of this subscriptionId being associated with the GroupQuotasEntity. + public RequestState? ProvisioningState { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityBase.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityBase.Serialization.cs new file mode 100644 index 000000000000..0ce791e985a4 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityBase.Serialization.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + public partial class GroupQuotasEntityBase : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(AdditionalAttributes)) + { + writer.WritePropertyName("additionalAttributes"u8); + writer.WriteObjectValue(AdditionalAttributes); + } + writer.WriteEndObject(); + } + + internal static GroupQuotasEntityBase DeserializeGroupQuotasEntityBase(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional displayName = default; + Optional additionalAttributes = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("additionalAttributes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + additionalAttributes = AdditionalAttributes.DeserializeAdditionalAttributes(property.Value); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new RequestState(property.Value.GetString()); + continue; + } + } + return new GroupQuotasEntityBase(displayName.Value, additionalAttributes.Value, Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityBase.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityBase.cs new file mode 100644 index 000000000000..7fc178a41868 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityBase.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// Properties and filters for ShareQuota. The request parameter is optional, if there are no filters specified. + public partial class GroupQuotasEntityBase + { + /// Initializes a new instance of GroupQuotasEntityBase. + public GroupQuotasEntityBase() + { + } + + /// Initializes a new instance of GroupQuotasEntityBase. + /// Display name of the GroupQuota entity. + /// Additional attributes to allow subscription, which can be added to the subscriptionIds. + /// Provisioning state of the operation. + internal GroupQuotasEntityBase(string displayName, AdditionalAttributes additionalAttributes, RequestState? provisioningState) + { + DisplayName = displayName; + AdditionalAttributes = additionalAttributes; + ProvisioningState = provisioningState; + } + + /// Display name of the GroupQuota entity. + public string DisplayName { get; set; } + /// Additional attributes to allow subscription, which can be added to the subscriptionIds. + public AdditionalAttributes AdditionalAttributes { get; set; } + /// Provisioning state of the operation. + public RequestState? ProvisioningState { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityData.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityData.Serialization.cs new file mode 100644 index 000000000000..ab110f095a56 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupQuotasEntityData.Serialization.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + public partial class GroupQuotasEntityData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties); + } + writer.WriteEndObject(); + } + + internal static GroupQuotasEntityData DeserializeGroupQuotasEntityData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = GroupQuotasEntityBase.DeserializeGroupQuotasEntityBase(property.Value); + 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) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + } + return new GroupQuotasEntityData(id, name, type, systemData.Value, properties.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingId.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingId.Serialization.cs new file mode 100644 index 000000000000..ddb009c849ba --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingId.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + public partial class GroupingId : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(GroupingIdType)) + { + writer.WritePropertyName("groupingIdType"u8); + writer.WriteStringValue(GroupingIdType.Value.ToString()); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + writer.WriteEndObject(); + } + + internal static GroupingId DeserializeGroupingId(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional groupingIdType = default; + Optional value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("groupingIdType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + groupingIdType = new GroupingIdType(property.Value.GetString()); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + } + return new GroupingId(Optional.ToNullable(groupingIdType), value.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingId.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingId.cs new file mode 100644 index 000000000000..62bc80b16314 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingId.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// The grouping Id for the group quota. It can be management Group Id or ServiceTreeId if applicable. + public partial class GroupingId + { + /// Initializes a new instance of GroupingId. + public GroupingId() + { + } + + /// Initializes a new instance of GroupingId. + /// GroupingId type. It is a required property. More types of groupIds can be supported in future. MGID is already in the URI, so it's not needed.'. + /// GroupId value based on the groupingType selected - management Group Id or ServiceTreeId. + internal GroupingId(GroupingIdType? groupingIdType, string value) + { + GroupingIdType = groupingIdType; + Value = value; + } + + /// GroupingId type. It is a required property. More types of groupIds can be supported in future. MGID is already in the URI, so it's not needed.'. + public GroupingIdType? GroupingIdType { get; set; } + /// GroupId value based on the groupingType selected - management Group Id or ServiceTreeId. + public string Value { get; set; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingIdType.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingIdType.cs new file mode 100644 index 000000000000..56a91c508744 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/GroupingIdType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Quota.Models +{ + /// GroupingId type. It is a required property. More types of groupIds can be supported in future. MGID is already in the URI, so it's not needed.'. + public readonly partial struct GroupingIdType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public GroupingIdType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ServiceTreeIdValue = "ServiceTreeId"; + private const string BillingIdValue = "BillingId"; + + /// ServiceTreeId. + public static GroupingIdType ServiceTreeId { get; } = new GroupingIdType(ServiceTreeIdValue); + /// BillingId. + public static GroupingIdType BillingId { get; } = new GroupingIdType(BillingIdValue); + /// Determines if two values are the same. + public static bool operator ==(GroupingIdType left, GroupingIdType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(GroupingIdType left, GroupingIdType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator GroupingIdType(string value) => new GroupingIdType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GroupingIdType other && Equals(other); + /// + public bool Equals(GroupingIdType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/RequestState.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/RequestState.cs new file mode 100644 index 000000000000..b96fdfce47c1 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/RequestState.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Quota.Models +{ + /// Request status. + public readonly partial struct RequestState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RequestState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AcceptedValue = "Accepted"; + private const string CreatedValue = "Created"; + private const string InvalidValue = "Invalid"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string InProgressValue = "InProgress"; + private const string CanceledValue = "Canceled"; + + /// Accepted. + public static RequestState Accepted { get; } = new RequestState(AcceptedValue); + /// Created. + public static RequestState Created { get; } = new RequestState(CreatedValue); + /// Invalid. + public static RequestState Invalid { get; } = new RequestState(InvalidValue); + /// Succeeded. + public static RequestState Succeeded { get; } = new RequestState(SucceededValue); + /// Failed. + public static RequestState Failed { get; } = new RequestState(FailedValue); + /// InProgress. + public static RequestState InProgress { get; } = new RequestState(InProgressValue); + /// Canceled. + public static RequestState Canceled { get; } = new RequestState(CanceledValue); + /// Determines if two values are the same. + public static bool operator ==(RequestState left, RequestState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RequestState left, RequestState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RequestState(string value) => new RequestState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RequestState other && Equals(other); + /// + public bool Equals(RequestState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/ResourceBaseRequest.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/ResourceBaseRequest.Serialization.cs new file mode 100644 index 000000000000..35527da41f9e --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/ResourceBaseRequest.Serialization.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + public partial class ResourceBaseRequest + { + internal static ResourceBaseRequest DeserializeResourceBaseRequest(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional resourceName = default; + Optional limits = default; + Optional unit = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceName"u8)) + { + resourceName = property.Value.GetString(); + continue; + } + if (property.NameEquals("limits"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + limits = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("unit"u8)) + { + unit = property.Value.GetString(); + continue; + } + } + return new ResourceBaseRequest(resourceName.Value, Optional.ToNullable(limits), unit.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/ResourceBaseRequest.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/ResourceBaseRequest.cs new file mode 100644 index 000000000000..b01341c4bcb0 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/ResourceBaseRequest.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// Resource definition with the requested quota. + public partial class ResourceBaseRequest + { + /// Initializes a new instance of ResourceBaseRequest. + internal ResourceBaseRequest() + { + } + + /// Initializes a new instance of ResourceBaseRequest. + /// The resource name, such as SKU name. + /// Quota requested for the resource. + /// Representing the units of the usage quota. Possible values are: Count, Bytes, Seconds, Percent, CountPerSecond, BytesPerSecond. Based on - https://armwiki.azurewebsites.net/api_contracts/UsagesAPIContract.html?q=usages . Different RPs may have different units, Count, type as int64 should work for most of the integer values. + internal ResourceBaseRequest(string resourceName, long? limits, string unit) + { + ResourceName = resourceName; + Limits = limits; + Unit = unit; + } + + /// The resource name, such as SKU name. + public string ResourceName { get; } + /// Quota requested for the resource. + public long? Limits { get; } + /// Representing the units of the usage quota. Possible values are: Count, Bytes, Seconds, Percent, CountPerSecond, BytesPerSecond. Based on - https://armwiki.azurewebsites.net/api_contracts/UsagesAPIContract.html?q=usages . Different RPs may have different units, Count, type as int64 should work for most of the integer values. + public string Unit { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatus.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatus.Serialization.cs new file mode 100644 index 000000000000..2f04dc191d04 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatus.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.Quota.Models +{ + public partial class SubmittedResourceRequestStatus + { + internal static SubmittedResourceRequestStatus DeserializeSubmittedResourceRequestStatus(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional requestedResource = default; + Optional status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("requestedResource"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + requestedResource = ResourceBaseRequest.DeserializeResourceBaseRequest(property.Value); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new RequestState(property.Value.GetString()); + continue; + } + } + return new SubmittedResourceRequestStatus(requestedResource.Value, Optional.ToNullable(status)); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatus.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatus.cs new file mode 100644 index 000000000000..3a6eff0a6374 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatus.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// Status of a single GroupQuota request. + public partial class SubmittedResourceRequestStatus + { + /// Initializes a new instance of SubmittedResourceRequestStatus. + internal SubmittedResourceRequestStatus() + { + } + + /// Initializes a new instance of SubmittedResourceRequestStatus. + /// Requested Resource. + /// Request status. + internal SubmittedResourceRequestStatus(ResourceBaseRequest requestedResource, RequestState? status) + { + RequestedResource = requestedResource; + Status = status; + } + + /// Requested Resource. + public ResourceBaseRequest RequestedResource { get; } + /// Request status. + public RequestState? Status { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatusList.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatusList.Serialization.cs new file mode 100644 index 000000000000..a175c0a3aa5a --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatusList.Serialization.cs @@ -0,0 +1,49 @@ +// 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.Quota.Models +{ + internal partial class SubmittedResourceRequestStatusList + { + internal static SubmittedResourceRequestStatusList DeserializeSubmittedResourceRequestStatusList(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SubmittedResourceRequestStatus.DeserializeSubmittedResourceRequestStatus(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new SubmittedResourceRequestStatusList(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatusList.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatusList.cs new file mode 100644 index 000000000000..984c258e89cb --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubmittedResourceRequestStatusList.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.Quota.Models +{ + /// Share Quota Entity list. + internal partial class SubmittedResourceRequestStatusList + { + /// Initializes a new instance of SubmittedResourceRequestStatusList. + internal SubmittedResourceRequestStatusList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of SubmittedResourceRequestStatusList. + /// Subscription groupQuotaRequests list. + /// The URL to use for getting the next set of results. + internal SubmittedResourceRequestStatusList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// Subscription groupQuotaRequests list. + public IReadOnlyList Value { get; } + /// The URL to use for getting the next set of results. + public string NextLink { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionGroupQuotaAssignment.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionGroupQuotaAssignment.Serialization.cs new file mode 100644 index 000000000000..c47787a8e188 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionGroupQuotaAssignment.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + public partial class SubscriptionGroupQuotaAssignment : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ManagementGroupId)) + { + writer.WritePropertyName("managementGroupId"u8); + writer.WriteStringValue(ManagementGroupId); + } + if (Optional.IsDefined(QuotaAllocated)) + { + writer.WritePropertyName("quotaAllocated"u8); + writer.WriteNumberValue(QuotaAllocated.Value); + } + writer.WriteEndObject(); + } + + internal static SubscriptionGroupQuotaAssignment DeserializeSubscriptionGroupQuotaAssignment(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional managementGroupId = default; + Optional quotaAllocated = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("managementGroupId"u8)) + { + managementGroupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("quotaAllocated"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + quotaAllocated = property.Value.GetInt64(); + continue; + } + } + return new SubscriptionGroupQuotaAssignment(managementGroupId.Value, Optional.ToNullable(quotaAllocated)); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionGroupQuotaAssignment.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionGroupQuotaAssignment.cs new file mode 100644 index 000000000000..5fa5df91c796 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionGroupQuotaAssignment.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// MGId the source of groupQuota. + public partial class SubscriptionGroupQuotaAssignment + { + /// Initializes a new instance of SubscriptionGroupQuotaAssignment. + public SubscriptionGroupQuotaAssignment() + { + } + + /// Initializes a new instance of SubscriptionGroupQuotaAssignment. + /// The management group id of the quota source. + /// The amount of quota allocated to this subscriptionId from the quota source. + internal SubscriptionGroupQuotaAssignment(string managementGroupId, long? quotaAllocated) + { + ManagementGroupId = managementGroupId; + QuotaAllocated = quotaAllocated; + } + + /// The management group id of the quota source. + public string ManagementGroupId { get; set; } + /// The amount of quota allocated to this subscriptionId from the quota source. + public long? QuotaAllocated { get; set; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationData.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationData.Serialization.cs new file mode 100644 index 000000000000..9ce107bc06ea --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationData.Serialization.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + public partial class SubscriptionQuotaAllocationData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties); + } + writer.WriteEndObject(); + } + + internal static SubscriptionQuotaAllocationData DeserializeSubscriptionQuotaAllocationData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = SubscriptionQuotaDetails.DeserializeSubscriptionQuotaDetails(property.Value); + 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) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + } + return new SubscriptionQuotaAllocationData(id, name, type, systemData.Value, properties.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequest.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequest.Serialization.cs new file mode 100644 index 000000000000..ff6b74b605f7 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequest.Serialization.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + public partial class SubscriptionQuotaAllocationRequest + { + internal static SubscriptionQuotaAllocationRequest DeserializeSubscriptionQuotaAllocationRequest(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional properties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = SubscriptionQuotaAllocationRequestProperties.DeserializeSubscriptionQuotaAllocationRequestProperties(property.Value); + continue; + } + } + return new SubscriptionQuotaAllocationRequest(properties.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequest.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequest.cs new file mode 100644 index 000000000000..7cf57d7bee32 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequest.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// The new quota limit for the subscription. + public partial class SubscriptionQuotaAllocationRequest + { + /// Initializes a new instance of SubscriptionQuotaAllocationRequest. + internal SubscriptionQuotaAllocationRequest() + { + } + + /// Initializes a new instance of SubscriptionQuotaAllocationRequest. + /// + internal SubscriptionQuotaAllocationRequest(SubscriptionQuotaAllocationRequestProperties properties) + { + Properties = properties; + } + + /// Gets the properties. + public SubscriptionQuotaAllocationRequestProperties Properties { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestList.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestList.Serialization.cs new file mode 100644 index 000000000000..f44a0c4a8761 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestList.Serialization.cs @@ -0,0 +1,49 @@ +// 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.Quota.Models +{ + internal partial class SubscriptionQuotaAllocationRequestList + { + internal static SubscriptionQuotaAllocationRequestList DeserializeSubscriptionQuotaAllocationRequestList(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SubscriptionQuotaAllocationRequest.DeserializeSubscriptionQuotaAllocationRequest(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new SubscriptionQuotaAllocationRequestList(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestList.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestList.cs new file mode 100644 index 000000000000..9ae86c1a6810 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestList.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.Quota.Models +{ + /// The SubscriptionQuotaAllocationRequestList. + internal partial class SubscriptionQuotaAllocationRequestList + { + /// Initializes a new instance of SubscriptionQuotaAllocationRequestList. + internal SubscriptionQuotaAllocationRequestList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of SubscriptionQuotaAllocationRequestList. + /// Assigned Group Quota to subscriptions. + /// The URL to use for getting the next set of results. + internal SubscriptionQuotaAllocationRequestList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// Assigned Group Quota to subscriptions. + public IReadOnlyList Value { get; } + /// The URL to use for getting the next set of results. + public string NextLink { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestProperties.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestProperties.Serialization.cs new file mode 100644 index 000000000000..f0780939ab54 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestProperties.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.Quota.Models +{ + public partial class SubscriptionQuotaAllocationRequestProperties + { + internal static SubscriptionQuotaAllocationRequestProperties DeserializeSubscriptionQuotaAllocationRequestProperties(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional provisioningState = default; + Optional limit = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new RequestState(property.Value.GetString()); + continue; + } + if (property.NameEquals("limit"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + limit = property.Value.GetInt64(); + continue; + } + } + return new SubscriptionQuotaAllocationRequestProperties(Optional.ToNullable(provisioningState), Optional.ToNullable(limit)); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestProperties.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestProperties.cs new file mode 100644 index 000000000000..79f1ac5add25 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationRequestProperties.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Quota.Models +{ + /// The SubscriptionQuotaAllocationRequestProperties. + public partial class SubscriptionQuotaAllocationRequestProperties + { + /// Initializes a new instance of SubscriptionQuotaAllocationRequestProperties. + internal SubscriptionQuotaAllocationRequestProperties() + { + } + + /// Initializes a new instance of SubscriptionQuotaAllocationRequestProperties. + /// Request status. + /// The new quota limit for the subscription. The incremental quota will be assigned from pre-approved groupQuota. + internal SubscriptionQuotaAllocationRequestProperties(RequestState? provisioningState, long? limit) + { + ProvisioningState = provisioningState; + Limit = limit; + } + + /// Request status. + public RequestState? ProvisioningState { get; } + /// The new quota limit for the subscription. The incremental quota will be assigned from pre-approved groupQuota. + public long? Limit { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationsList.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationsList.Serialization.cs new file mode 100644 index 000000000000..769b00ac97e4 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationsList.Serialization.cs @@ -0,0 +1,50 @@ +// 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; +using Azure.ResourceManager.Quota; + +namespace Azure.ResourceManager.Quota.Models +{ + internal partial class SubscriptionQuotaAllocationsList + { + internal static SubscriptionQuotaAllocationsList DeserializeSubscriptionQuotaAllocationsList(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SubscriptionQuotaAllocationData.DeserializeSubscriptionQuotaAllocationData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new SubscriptionQuotaAllocationsList(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationsList.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationsList.cs new file mode 100644 index 000000000000..0367350add18 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaAllocationsList.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Quota; + +namespace Azure.ResourceManager.Quota.Models +{ + /// Subscription quota list. + internal partial class SubscriptionQuotaAllocationsList + { + /// Initializes a new instance of SubscriptionQuotaAllocationsList. + internal SubscriptionQuotaAllocationsList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of SubscriptionQuotaAllocationsList. + /// Subscription quota list. + /// The URL to use for getting the next set of results. + internal SubscriptionQuotaAllocationsList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// Subscription quota list. + public IReadOnlyList Value { get; } + /// The URL to use for getting the next set of results. + public string NextLink { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaDetails.Serialization.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaDetails.Serialization.cs new file mode 100644 index 000000000000..47d8d0a7969d --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaDetails.Serialization.cs @@ -0,0 +1,89 @@ +// 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.Quota.Models +{ + public partial class SubscriptionQuotaDetails : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(QuotaSources)) + { + writer.WritePropertyName("quotaSources"u8); + writer.WriteStartArray(); + foreach (var item in QuotaSources) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + internal static SubscriptionQuotaDetails DeserializeSubscriptionQuotaDetails(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional limit = default; + Optional nonShareableQuota = default; + Optional provisioningState = default; + Optional> quotaSources = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("limit"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + limit = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("nonShareableQuota"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nonShareableQuota = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new RequestState(property.Value.GetString()); + continue; + } + if (property.NameEquals("quotaSources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SubscriptionGroupQuotaAssignment.DeserializeSubscriptionGroupQuotaAssignment(item)); + } + quotaSources = array; + continue; + } + } + return new SubscriptionQuotaDetails(Optional.ToNullable(limit), Optional.ToNullable(nonShareableQuota), Optional.ToNullable(provisioningState), Optional.ToList(quotaSources)); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaDetails.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaDetails.cs new file mode 100644 index 000000000000..6b638ec3d907 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/Models/SubscriptionQuotaDetails.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Quota.Models +{ + /// Subscription Quota details. + public partial class SubscriptionQuotaDetails + { + /// Initializes a new instance of SubscriptionQuotaDetails. + public SubscriptionQuotaDetails() + { + QuotaSources = new ChangeTrackingList(); + } + + /// Initializes a new instance of SubscriptionQuotaDetails. + /// The total quota limit for the subscription. + /// The non shareable quota for the subscription. + /// Request status. + /// Assigned Group Quota to subscriptions. + internal SubscriptionQuotaDetails(long? limit, long? nonShareableQuota, RequestState? provisioningState, IList quotaSources) + { + Limit = limit; + NonShareableQuota = nonShareableQuota; + ProvisioningState = provisioningState; + QuotaSources = quotaSources; + } + + /// The total quota limit for the subscription. + public long? Limit { get; } + /// The non shareable quota for the subscription. + public long? NonShareableQuota { get; } + /// Request status. + public RequestState? ProvisioningState { get; } + /// Assigned Group Quota to subscriptions. + public IList QuotaSources { get; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaLimitsRequestsRestOperations.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaLimitsRequestsRestOperations.cs new file mode 100644 index 000000000000..8a405e465b0e --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaLimitsRequestsRestOperations.cs @@ -0,0 +1,279 @@ +// 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.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + internal partial class GroupQuotaLimitsRequestsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of GroupQuotaLimitsRequestsRestOperations. + /// 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 GroupQuotaLimitsRequestsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri(""); + _apiVersion = apiVersion ?? "2023-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListRequest(string mgId, string resourceProviderScope, string groupQuotaName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/groupQuotaRequests", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List API to check the status of a GroupQuota requests by requestId. The groupQuotaRequest history is maintained for 1 year. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string mgId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, resourceProviderScope, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SubmittedResourceRequestStatusList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SubmittedResourceRequestStatusList.DeserializeSubmittedResourceRequestStatusList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List API to check the status of a GroupQuota requests by requestId. The groupQuotaRequest history is maintained for 1 year. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string mgId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, resourceProviderScope, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SubmittedResourceRequestStatusList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SubmittedResourceRequestStatusList.DeserializeSubmittedResourceRequestStatusList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string mgId, string resourceProviderScope, string groupQuotaName, string requestId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/groupQuotaRequests/", false); + uri.AppendPath(requestId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get API to check the status of a GroupQuota request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Request Id. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string mgId, string resourceProviderScope, string groupQuotaName, string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + using var message = CreateGetRequest(mgId, resourceProviderScope, groupQuotaName, requestId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SubmittedResourceRequestStatus value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SubmittedResourceRequestStatus.DeserializeSubmittedResourceRequestStatus(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get API to check the status of a GroupQuota request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Request Id. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string mgId, string resourceProviderScope, string groupQuotaName, string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + using var message = CreateGetRequest(mgId, resourceProviderScope, groupQuotaName, requestId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SubmittedResourceRequestStatus value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SubmittedResourceRequestStatus.DeserializeSubmittedResourceRequestStatus(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string mgId, string resourceProviderScope, string groupQuotaName) + { + 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; + } + + /// List API to check the status of a GroupQuota requests by requestId. The groupQuotaRequest history is maintained for 1 year. + /// The URL to the next page of results. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string mgId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, resourceProviderScope, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SubmittedResourceRequestStatusList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SubmittedResourceRequestStatusList.DeserializeSubmittedResourceRequestStatusList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List API to check the status of a GroupQuota requests by requestId. The groupQuotaRequest history is maintained for 1 year. + /// The URL to the next page of results. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string mgId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, resourceProviderScope, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SubmittedResourceRequestStatusList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SubmittedResourceRequestStatusList.DeserializeSubmittedResourceRequestStatusList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaLimitsRestOperations.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaLimitsRestOperations.cs new file mode 100644 index 000000000000..315ce6556c78 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaLimitsRestOperations.cs @@ -0,0 +1,451 @@ +// 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.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + internal partial class GroupQuotaLimitsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of GroupQuotaLimitsRestOperations. + /// 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 GroupQuotaLimitsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri(""); + _apiVersion = apiVersion ?? "2023-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateCreateOrUpdateRequest(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName, GroupQuotaLimitData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/groupQuotaLimits/", false); + uri.AppendPath(resourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Updates the GroupQuotaLimits for the specific resource under a Management Group. A groupQuotaLimitRequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The GroupQuotaLimit Request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName, GroupQuotaLimitData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(mgId, resourceProviderScope, groupQuotaName, resourceName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Updates the GroupQuotaLimits for the specific resource under a Management Group. A groupQuotaLimitRequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The GroupQuotaLimit Request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName, GroupQuotaLimitData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(mgId, resourceProviderScope, groupQuotaName, resourceName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName, GroupQuotaLimitData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/groupQuotaLimits/", false); + uri.AppendPath(resourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Updates the GroupQuotaLimits for the specific resource under a Management Group. A groupQuotaLimitRequestId will be returned by the Service. The status will be updated periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed,then the URI will change to Get URI and full details can be checked. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The GroupQuotaLimit Request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName, GroupQuotaLimitData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(mgId, resourceProviderScope, groupQuotaName, resourceName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Updates the GroupQuotaLimits for the specific resource under a Management Group. A groupQuotaLimitRequestId will be returned by the Service. The status will be updated periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed,then the URI will change to Get URI and full details can be checked. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The GroupQuotaLimit Request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Update(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName, GroupQuotaLimitData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(mgId, resourceProviderScope, groupQuotaName, resourceName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/groupQuotaLimits/", false); + uri.AppendPath(resourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the resource groupQuotaLimits for the MGId. It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var message = CreateGetRequest(mgId, resourceProviderScope, groupQuotaName, resourceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaLimitData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaLimitData.DeserializeGroupQuotaLimitData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((GroupQuotaLimitData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the resource groupQuotaLimits for the MGId. It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string mgId, string resourceProviderScope, string groupQuotaName, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var message = CreateGetRequest(mgId, resourceProviderScope, groupQuotaName, resourceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaLimitData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaLimitData.DeserializeGroupQuotaLimitData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((GroupQuotaLimitData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListRequest(string mgId, string resourceProviderScope, string groupQuotaName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/groupQuotaLimits", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the List of resources groupQuotaLimits for the MGId, based on the scope. The scope can be - providers/Microsoft.Compute/locations/<eastus>. The list elements will be same as the Get API - It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string mgId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, resourceProviderScope, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaLimitList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaLimitList.DeserializeGroupQuotaLimitList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the List of resources groupQuotaLimits for the MGId, based on the scope. The scope can be - providers/Microsoft.Compute/locations/<eastus>. The list elements will be same as the Get API - It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string mgId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, resourceProviderScope, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaLimitList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaLimitList.DeserializeGroupQuotaLimitList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string mgId, string resourceProviderScope, string groupQuotaName) + { + 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; + } + + /// Gets the List of resources groupQuotaLimits for the MGId, based on the scope. The scope can be - providers/Microsoft.Compute/locations/<eastus>. The list elements will be same as the Get API - It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// The URL to the next page of results. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string mgId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, resourceProviderScope, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaLimitList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaLimitList.DeserializeGroupQuotaLimitList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the List of resources groupQuotaLimits for the MGId, based on the scope. The scope can be - providers/Microsoft.Compute/locations/<eastus>. The list elements will be same as the Get API - It will include the limits, availableLimits, assignedToSubscriptions: Quotas assigned to subscriptions from the groupQuota. + /// The URL to the next page of results. + /// Management Group Id. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string mgId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, resourceProviderScope, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaLimitList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaLimitList.DeserializeGroupQuotaLimitList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations.cs new file mode 100644 index 000000000000..5573f9ce508c --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations.cs @@ -0,0 +1,295 @@ +// 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.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + internal partial class GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations. + /// 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 GroupQuotaSubscriptionQuotaAllocationRequestsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri(""); + _apiVersion = apiVersion ?? "2023-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateGetRequest(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string allocationId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/quotaAllocationRequests/", false); + uri.AppendPath(allocationId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get the quota allocation request status for the subscriptionId by allocationId. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource allocation Id. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string allocationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(allocationId, nameof(allocationId)); + + using var message = CreateGetRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName, allocationId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationRequest value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SubscriptionQuotaAllocationRequest.DeserializeSubscriptionQuotaAllocationRequest(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get the quota allocation request status for the subscriptionId by allocationId. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource allocation Id. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response Get(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string allocationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(allocationId, nameof(allocationId)); + + using var message = CreateGetRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName, allocationId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationRequest value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SubscriptionQuotaAllocationRequest.DeserializeSubscriptionQuotaAllocationRequest(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListRequest(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/quotaAllocationRequests", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists all the allocation requests. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationRequestList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SubscriptionQuotaAllocationRequestList.DeserializeSubscriptionQuotaAllocationRequestList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the allocation requests. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response List(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationRequestList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SubscriptionQuotaAllocationRequestList.DeserializeSubscriptionQuotaAllocationRequestList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName) + { + 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 the allocation requests. + /// The URL to the next page of results. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, subscriptionId, resourceProviderScope, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationRequestList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SubscriptionQuotaAllocationRequestList.DeserializeSubscriptionQuotaAllocationRequestList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the allocation requests. + /// The URL to the next page of results. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, subscriptionId, resourceProviderScope, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationRequestList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SubscriptionQuotaAllocationRequestList.DeserializeSubscriptionQuotaAllocationRequestList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionQuotaAllocationRestOperations.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionQuotaAllocationRestOperations.cs new file mode 100644 index 000000000000..c55783196a61 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionQuotaAllocationRestOperations.cs @@ -0,0 +1,479 @@ +// 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.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + internal partial class GroupQuotaSubscriptionQuotaAllocationRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of GroupQuotaSubscriptionQuotaAllocationRestOperations. + /// 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 GroupQuotaSubscriptionQuotaAllocationRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri(""); + _apiVersion = apiVersion ?? "2023-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListRequest(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/quotaAllocations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets all the quota assigned to a subscription for the specific Resource Provider, Location. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SubscriptionQuotaAllocationsList.DeserializeSubscriptionQuotaAllocationsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets all the quota assigned to a subscription for the specific Resource Provider, Location. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response List(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SubscriptionQuotaAllocationsList.DeserializeSubscriptionQuotaAllocationsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, SubscriptionQuotaAllocationData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/quotaAllocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Request to assign a specific resource quota from group quota to a specific Subscription. The subscriptions can also reduce the quota assigned to subscription to give back the group back to MG. The quota assignment back to MG groupQuota is limited by the GroupQuota assigned to subscription, which means the maximum unused quota assigned back to MG groupQuota will be the groupQuota assigned to the subscriptions. So, this API can used to assign Quota to subscriptions and assign back unused quota, which was previously assigned from MG groupQuota to subscription. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// Quota requests payload. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, SubscriptionQuotaAllocationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName, resourceName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Request to assign a specific resource quota from group quota to a specific Subscription. The subscriptions can also reduce the quota assigned to subscription to give back the group back to MG. The quota assignment back to MG groupQuota is limited by the GroupQuota assigned to subscription, which means the maximum unused quota assigned back to MG groupQuota will be the groupQuota assigned to the subscriptions. So, this API can used to assign Quota to subscriptions and assign back unused quota, which was previously assigned from MG groupQuota to subscription. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// Quota requests payload. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, SubscriptionQuotaAllocationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName, resourceName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, SubscriptionQuotaAllocationData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/quotaAllocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Request to assign quota from group quota to a specific Subscription. The subscriptions and reduce the quota assigned to subscription to give back the group back to MG. The quota assignment back to MG groupQuota is limited by the GroupQuota assigned to subscription, using this API. So, this API can used to assign Quota to subscriptions and assign back unused quota, which was previously assigned from MG groupQuota to subscription(s). + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// Quota requests payload. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, SubscriptionQuotaAllocationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName, resourceName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Request to assign quota from group quota to a specific Subscription. The subscriptions and reduce the quota assigned to subscription to give back the group back to MG. The quota assignment back to MG groupQuota is limited by the GroupQuota assigned to subscription, using this API. So, this API can used to assign Quota to subscriptions and assign back unused quota, which was previously assigned from MG groupQuota to subscription(s). + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// Quota requests payload. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response Update(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, SubscriptionQuotaAllocationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName, resourceName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/", false); + uri.AppendPath(resourceProviderScope, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/quotaAllocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets Quota assigned to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var message = CreateGetRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName, resourceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SubscriptionQuotaAllocationData.DeserializeSubscriptionQuotaAllocationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SubscriptionQuotaAllocationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets Quota assigned to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Resource name. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response Get(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var message = CreateGetRequest(mgId, subscriptionId, resourceProviderScope, groupQuotaName, resourceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SubscriptionQuotaAllocationData.DeserializeSubscriptionQuotaAllocationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SubscriptionQuotaAllocationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName) + { + 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; + } + + /// Gets all the quota assigned to a subscription for the specific Resource Provider, Location. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// The URL to the next page of results. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, subscriptionId, resourceProviderScope, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SubscriptionQuotaAllocationsList.DeserializeSubscriptionQuotaAllocationsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets all the quota assigned to a subscription for the specific Resource Provider, Location. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// The URL to the next page of results. + /// Management Group Id. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceProviderScope, nameof(resourceProviderScope)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, subscriptionId, resourceProviderScope, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SubscriptionQuotaAllocationsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SubscriptionQuotaAllocationsList.DeserializeSubscriptionQuotaAllocationsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionsRestOperations.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionsRestOperations.cs new file mode 100644 index 000000000000..d275743c4c28 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotaSubscriptionsRestOperations.cs @@ -0,0 +1,477 @@ +// 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.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + internal partial class GroupQuotaSubscriptionsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of GroupQuotaSubscriptionsRestOperations. + /// 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 GroupQuotaSubscriptionsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri(""); + _apiVersion = apiVersion ?? "2023-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateCreateOrUpdateRequest(string mgId, string groupQuotaName, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Adds a subscription to GroupQuotas. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string mgId, string groupQuotaName, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateCreateOrUpdateRequest(mgId, groupQuotaName, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Adds a subscription to GroupQuotas. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string mgId, string groupQuotaName, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateCreateOrUpdateRequest(mgId, groupQuotaName, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string mgId, string groupQuotaName, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Updates the GroupQuotas with the subscription to add to the subscriptions list. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string mgId, string groupQuotaName, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateUpdateRequest(mgId, groupQuotaName, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Updates the GroupQuotas with the subscription to add to the subscriptions list. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string mgId, string groupQuotaName, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateUpdateRequest(mgId, groupQuotaName, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string mgId, string groupQuotaName, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Removes the subscription from GroupQuotas. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string mgId, string groupQuotaName, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateDeleteRequest(mgId, groupQuotaName, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Removes the subscription from GroupQuotas. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Delete(string mgId, string groupQuotaName, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateDeleteRequest(mgId, groupQuotaName, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string mgId, string groupQuotaName, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Returns the subscriptionId along with its provisioning state for being associated with the GroupQuotasEntity. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string mgId, string groupQuotaName, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateGetRequest(mgId, groupQuotaName, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((GroupQuotaSubscriptionIdData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Returns the subscriptionId along with its provisioning state for being associated with the GroupQuotasEntity. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Get(string mgId, string groupQuotaName, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateGetRequest(mgId, groupQuotaName, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((GroupQuotaSubscriptionIdData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListRequest(string mgId, string groupQuotaName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/subscriptions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Returns a list of the subscriptionIds associated with the GroupQuotasEntity. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaSubscriptionIdList.DeserializeGroupQuotaSubscriptionIdList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Returns a list of the subscriptionIds associated with the GroupQuotasEntity. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response List(string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaSubscriptionIdList.DeserializeGroupQuotaSubscriptionIdList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string mgId, string groupQuotaName) + { + 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; + } + + /// Returns a list of the subscriptionIds associated with the GroupQuotasEntity. + /// The URL to the next page of results. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaSubscriptionIdList.DeserializeGroupQuotaSubscriptionIdList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Returns a list of the subscriptionIds associated with the GroupQuotasEntity. + /// The URL to the next page of results. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaSubscriptionIdList.DeserializeGroupQuotaSubscriptionIdList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotasRestOperations.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotasRestOperations.cs new file mode 100644 index 000000000000..d9ca0bd7292b --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/GroupQuotasRestOperations.cs @@ -0,0 +1,465 @@ +// 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.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + internal partial class GroupQuotasRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of GroupQuotasRestOperations. + /// 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 GroupQuotasRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri(""); + _apiVersion = apiVersion ?? "2023-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateCreateOrUpdateRequest(string mgId, string groupQuotaName, GroupQuotasEntityData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates a new GroupQuota for the name passed. A RequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The GroupQuota body details for creation or update of a GroupQuota entity. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string mgId, string groupQuotaName, GroupQuotasEntityData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(mgId, groupQuotaName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates a new GroupQuota for the name passed. A RequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The GroupQuota body details for creation or update of a GroupQuota entity. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string mgId, string groupQuotaName, GroupQuotasEntityData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(mgId, groupQuotaName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string mgId, string groupQuotaName, GroupQuotasEntityData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// + /// Updates the GroupQuotas for the name passed. A GroupQuotas RequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// Any change in the filters will be applicable to the future quota assignments, existing quota assigned to subscriptions from the GroupQuotas remains unchanged. + /// + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The GroupQuotas Patch Request. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string mgId, string groupQuotaName, GroupQuotasEntityData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(mgId, groupQuotaName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Updates the GroupQuotas for the name passed. A GroupQuotas RequestId will be returned by the Service. The status can be polled periodically. The status Async polling is using standards defined at - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. Use the OperationsStatus URI provided in Azure-AsyncOperation header, the duration will be specified in retry-after header. Once the operation gets to terminal state - Succeeded | Failed, then the URI will change to Get URI and full details can be checked. + /// Any change in the filters will be applicable to the future quota assignments, existing quota assigned to subscriptions from the GroupQuotas remains unchanged. + /// + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The GroupQuotas Patch Request. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response Update(string mgId, string groupQuotaName, GroupQuotasEntityData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(mgId, groupQuotaName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string mgId, string groupQuotaName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the GroupQuotas for the name passed. It will return the GroupQuotas properties only. The details on groupQuota can be access from the groupQuota APIs. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateGetRequest(mgId, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotasEntityData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotasEntityData.DeserializeGroupQuotasEntityData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((GroupQuotasEntityData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the GroupQuotas for the name passed. It will return the GroupQuotas properties only. The details on groupQuota can be access from the groupQuota APIs. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response Get(string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateGetRequest(mgId, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotasEntityData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotasEntityData.DeserializeGroupQuotasEntityData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((GroupQuotasEntityData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string mgId, string groupQuotaName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the GroupQuotas for the name passed. All the remaining shareQuota in the GroupQuotas will be lost. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateDeleteRequest(mgId, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the GroupQuotas for the name passed. All the remaining shareQuota in the GroupQuotas will be lost. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response Delete(string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateDeleteRequest(mgId, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListRequest(string mgId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists GroupQuotas for the scope passed. It will return the GroupQuotas QuotaEntity properties only.The details on groupQuota can be access from the groupQuota APIs. + /// Management Group Id. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string mgId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + + using var message = CreateListRequest(mgId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaList.DeserializeGroupQuotaList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists GroupQuotas for the scope passed. It will return the GroupQuotas QuotaEntity properties only.The details on groupQuota can be access from the groupQuota APIs. + /// Management Group Id. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response List(string mgId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + + using var message = CreateListRequest(mgId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaList.DeserializeGroupQuotaList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string mgId) + { + 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 GroupQuotas for the scope passed. It will return the GroupQuotas QuotaEntity properties only.The details on groupQuota can be access from the groupQuota APIs. + /// The URL to the next page of results. + /// Management Group Id. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string mgId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + + using var message = CreateListNextPageRequest(nextLink, mgId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaList.DeserializeGroupQuotaList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists GroupQuotas for the scope passed. It will return the GroupQuotas QuotaEntity properties only.The details on groupQuota can be access from the groupQuota APIs. + /// The URL to the next page of results. + /// Management Group Id. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string mgId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + + using var message = CreateListNextPageRequest(nextLink, mgId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaList.DeserializeGroupQuotaList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/SubscriptionRequestsRestOperations.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/SubscriptionRequestsRestOperations.cs new file mode 100644 index 000000000000..85f00876a6ea --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/RestOperations/SubscriptionRequestsRestOperations.cs @@ -0,0 +1,267 @@ +// 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.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + internal partial class SubscriptionRequestsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of SubscriptionRequestsRestOperations. + /// 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 SubscriptionRequestsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri(""); + _apiVersion = apiVersion ?? "2023-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListRequest(string mgId, string groupQuotaName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/subscriptionRequests", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List API to check the status of a subscriptionId requests by requestId. Request history is maintained for 1 year. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaSubscriptionIdList.DeserializeGroupQuotaSubscriptionIdList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List API to check the status of a subscriptionId requests by requestId. Request history is maintained for 1 year. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response List(string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListRequest(mgId, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaSubscriptionIdList.DeserializeGroupQuotaSubscriptionIdList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string mgId, string groupQuotaName, string requestId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); + uri.AppendPath(mgId, true); + uri.AppendPath("/providers/Microsoft.Quota/groupQuotas/", false); + uri.AppendPath(groupQuotaName, true); + uri.AppendPath("/subscriptionRequests/", false); + uri.AppendPath(requestId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get API to check the status of a subscriptionIds request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Request Id. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string mgId, string groupQuotaName, string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + using var message = CreateGetRequest(mgId, groupQuotaName, requestId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((GroupQuotaSubscriptionIdData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get API to check the status of a subscriptionIds request by requestId. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// Request Id. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Get(string mgId, string groupQuotaName, string requestId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + Argument.AssertNotNullOrEmpty(requestId, nameof(requestId)); + + using var message = CreateGetRequest(mgId, groupQuotaName, requestId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaSubscriptionIdData.DeserializeGroupQuotaSubscriptionIdData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((GroupQuotaSubscriptionIdData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string mgId, string groupQuotaName) + { + 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; + } + + /// List API to check the status of a subscriptionId requests by requestId. Request history is maintained for 1 year. + /// The URL to the next page of results. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, groupQuotaName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupQuotaSubscriptionIdList.DeserializeGroupQuotaSubscriptionIdList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List API to check the status of a subscriptionId requests by requestId. Request history is maintained for 1 year. + /// The URL to the next page of results. + /// Management Group Id. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string mgId, string groupQuotaName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(mgId, nameof(mgId)); + Argument.AssertNotNullOrEmpty(groupQuotaName, nameof(groupQuotaName)); + + using var message = CreateListNextPageRequest(nextLink, mgId, groupQuotaName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupQuotaSubscriptionIdList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupQuotaSubscriptionIdList.DeserializeGroupQuotaSubscriptionIdList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationCollection.cs new file mode 100644 index 000000000000..981a8398e822 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationCollection.cs @@ -0,0 +1,352 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagementGroups; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetSubscriptionQuotaAllocations method from an instance of . + /// + public partial class SubscriptionQuotaAllocationCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics; + private readonly GroupQuotaSubscriptionQuotaAllocationRestOperations _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient; + private readonly string _subscriptionId; + private readonly string _resourceProviderScope; + private readonly string _groupQuotaName; + + /// Initializes a new instance of the class for mocking. + protected SubscriptionQuotaAllocationCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + /// The ID of the target subscription. The value must be an UUID. + /// Scope for the resource. Some resources do not require location parameter, such as CosmosDb, so can be skipped in scope. For most of the resources require - providers/Microsoft.Compute/locations/{locationName}. Some Rps such as Batch requires batchAccountName - providers/Microsoft.Batch/locations/{locationName}/accountName/{batchAccountName}. This extension enables to specify resources for any all the RPs. + /// The GroupQuota name. The name should be unique for the provided context tenantId/MgId. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + internal SubscriptionQuotaAllocationCollection(ArmClient client, ResourceIdentifier id, string subscriptionId, string resourceProviderScope, string groupQuotaName) : base(client, id) + { + _subscriptionId = subscriptionId; + _resourceProviderScope = resourceProviderScope; + _groupQuotaName = groupQuotaName; + _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", SubscriptionQuotaAllocationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(SubscriptionQuotaAllocationResource.ResourceType, out string subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationApiVersion); + _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient = new GroupQuotaSubscriptionQuotaAllocationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ManagementGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagementGroupResource.ResourceType), nameof(id)); + } + + /// + /// Request to assign a specific resource quota from group quota to a specific Subscription. The subscriptions can also reduce the quota assigned to subscription to give back the group back to MG. The quota assignment back to MG groupQuota is limited by the GroupQuota assigned to subscription, which means the maximum unused quota assigned back to MG groupQuota will be the groupQuota assigned to the subscriptions. So, this API can used to assign Quota to subscriptions and assign back unused quota, which was previously assigned from MG groupQuota to subscription. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_CreateOrUpdate + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource name. + /// Quota requests payload. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string resourceName, SubscriptionQuotaAllocationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateOrUpdateAsync(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName, resourceName, data, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(new SubscriptionQuotaAllocationOperationSource(Client), _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics, Pipeline, _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateCreateOrUpdateRequest(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName, resourceName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Request to assign a specific resource quota from group quota to a specific Subscription. The subscriptions can also reduce the quota assigned to subscription to give back the group back to MG. The quota assignment back to MG groupQuota is limited by the GroupQuota assigned to subscription, which means the maximum unused quota assigned back to MG groupQuota will be the groupQuota assigned to the subscriptions. So, this API can used to assign Quota to subscriptions and assign back unused quota, which was previously assigned from MG groupQuota to subscription. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_CreateOrUpdate + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource name. + /// Quota requests payload. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string resourceName, SubscriptionQuotaAllocationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateOrUpdate(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName, resourceName, data, cancellationToken); + var operation = new QuotaArmOperation(new SubscriptionQuotaAllocationOperationSource(Client), _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics, Pipeline, _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateCreateOrUpdateRequest(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName, resourceName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets Quota assigned to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationCollection.Get"); + scope.Start(); + try + { + var response = await _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.GetAsync(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName, resourceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SubscriptionQuotaAllocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets Quota assigned to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationCollection.Get"); + scope.Start(); + try + { + var response = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.Get(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName, resourceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SubscriptionQuotaAllocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets all the quota assigned to a subscription for the specific Resource Provider, Location. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_List + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateListRequest(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateListNextPageRequest(nextLink, Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new SubscriptionQuotaAllocationResource(Client, SubscriptionQuotaAllocationData.DeserializeSubscriptionQuotaAllocationData(e)), _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics, Pipeline, "SubscriptionQuotaAllocationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets all the quota assigned to a subscription for the specific Resource Provider, Location. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_List + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateListRequest(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateListNextPageRequest(nextLink, Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new SubscriptionQuotaAllocationResource(Client, SubscriptionQuotaAllocationData.DeserializeSubscriptionQuotaAllocationData(e)), _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics, Pipeline, "SubscriptionQuotaAllocationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationCollection.Exists"); + scope.Start(); + try + { + var response = await _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.GetAsync(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName, resourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationCollection.Exists"); + scope.Start(); + try + { + var response = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.Get(Id.Name, _subscriptionId, _resourceProviderScope, _groupQuotaName, resourceName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationData.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationData.cs new file mode 100644 index 000000000000..838184c0b96b --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationData.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Quota.Models; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A class representing the SubscriptionQuotaAllocation data model. + /// Quota assigned to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// + public partial class SubscriptionQuotaAllocationData : ResourceData + { + /// Initializes a new instance of SubscriptionQuotaAllocationData. + public SubscriptionQuotaAllocationData() + { + } + + /// Initializes a new instance of SubscriptionQuotaAllocationData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Quota properties for the specified resource. + internal SubscriptionQuotaAllocationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, SubscriptionQuotaDetails properties) : base(id, name, resourceType, systemData) + { + Properties = properties; + } + + /// Quota properties for the specified resource. + public SubscriptionQuotaDetails Properties { get; set; } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationResource.cs b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationResource.cs new file mode 100644 index 000000000000..c83935815516 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/src/Generated/SubscriptionQuotaAllocationResource.cs @@ -0,0 +1,247 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagementGroups; + +namespace Azure.ResourceManager.Quota +{ + /// + /// A Class representing a SubscriptionQuotaAllocation along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetSubscriptionQuotaAllocationResource method. + /// Otherwise you can get one from its parent resource using the GetSubscriptionQuotaAllocation method. + /// + public partial class SubscriptionQuotaAllocationResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string mgId, string subscriptionId, string resourceProviderScope, string groupQuotaName, string resourceName) + { + var resourceId = $"/providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics; + private readonly GroupQuotaSubscriptionQuotaAllocationRestOperations _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient; + private readonly SubscriptionQuotaAllocationData _data; + + /// Initializes a new instance of the class for mocking. + protected SubscriptionQuotaAllocationResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal SubscriptionQuotaAllocationResource(ArmClient client, SubscriptionQuotaAllocationData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal SubscriptionQuotaAllocationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Quota", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationApiVersion); + _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient = new GroupQuotaSubscriptionQuotaAllocationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Quota/groupQuotas/quotaAllocations"; + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual SubscriptionQuotaAllocationData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Gets Quota assigned to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationResource.Get"); + scope.Start(); + try + { + var response = await _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.GetAsync(Id.Parent.Parent.Parent.Parent.Name, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SubscriptionQuotaAllocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets Quota assigned to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota assigned to the subscription. Only the Group quota assigned to the subscription can be assigned back to the MG Group Quota. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Get + /// + /// + /// + /// Resource name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationResource.Get"); + scope.Start(); + try + { + var response = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.Get(Id.Parent.Parent.Parent.Parent.Name, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SubscriptionQuotaAllocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Request to assign quota from group quota to a specific Subscription. The subscriptions and reduce the quota assigned to subscription to give back the group back to MG. The quota assignment back to MG groupQuota is limited by the GroupQuota assigned to subscription, using this API. So, this API can used to assign Quota to subscriptions and assign back unused quota, which was previously assigned from MG groupQuota to subscription(s). + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource name. + /// Quota requests payload. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, string resourceName, SubscriptionQuotaAllocationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationResource.Update"); + scope.Start(); + try + { + var response = await _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.UpdateAsync(Id.Parent.Parent.Parent.Parent.Name, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, data, cancellationToken).ConfigureAwait(false); + var operation = new QuotaArmOperation(new SubscriptionQuotaAllocationOperationSource(Client), _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics, Pipeline, _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateUpdateRequest(Id.Parent.Parent.Parent.Parent.Name, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Request to assign quota from group quota to a specific Subscription. The subscriptions and reduce the quota assigned to subscription to give back the group back to MG. The quota assignment back to MG groupQuota is limited by the GroupQuota assigned to subscription, using this API. So, this API can used to assign Quota to subscriptions and assign back unused quota, which was previously assigned from MG groupQuota to subscription(s). + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{mgId}/subscriptions/{subscriptionId}/{resourceProviderScope}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName} + /// + /// + /// Operation Id + /// GroupQuotaSubscriptionQuotaAllocation_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource name. + /// Quota requests payload. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation Update(WaitUntil waitUntil, string resourceName, SubscriptionQuotaAllocationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics.CreateScope("SubscriptionQuotaAllocationResource.Update"); + scope.Start(); + try + { + var response = _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.Update(Id.Parent.Parent.Parent.Parent.Name, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, data, cancellationToken); + var operation = new QuotaArmOperation(new SubscriptionQuotaAllocationOperationSource(Client), _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationClientDiagnostics, Pipeline, _subscriptionQuotaAllocationGroupQuotaSubscriptionQuotaAllocationRestClient.CreateUpdateRequest(Id.Parent.Parent.Parent.Parent.Name, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.ResourceType.GetLastType(), _groupQuotaName, resourceName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/src/autorest.md b/sdk/quota/Azure.ResourceManager.Quota/src/autorest.md index 964658f0183d..0403199c94ee 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/src/autorest.md +++ b/sdk/quota/Azure.ResourceManager.Quota/src/autorest.md @@ -9,7 +9,7 @@ csharp: true library-name: Quota namespace: Azure.ResourceManager.Quota # default tag is a preview version -require: https://github.com/Azure/azure-rest-api-specs/blob/57e0f495d521002e883f5357db0dfdfdaaff0208/specification/quota/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/quota/resource-manager/readme.md output-folder: $(this-folder)/Generated clear-output-folder: true skip-csproj: true