diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 76b5494320cea..e6c175396062a 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -314,6 +314,7 @@ com.azure.resourcemanager:azure-resourcemanager-security;1.0.0-beta.1;1.0.0-beta com.azure.resourcemanager:azure-resourcemanager-azurearcdata;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-hybridnetwork;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-purview;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-quota;1.0.0-beta.1;1.0.0-beta.1 # Unreleased dependencies: Copy the entry from above, prepend "unreleased_" and remove the current # version. Unreleased dependencies are only valid for dependency versions. diff --git a/pom.xml b/pom.xml index b8c5905f6920c..bf6cc1742b36b 100644 --- a/pom.xml +++ b/pom.xml @@ -800,6 +800,7 @@ sdk/powerbidedicated sdk/purview sdk/quantum + sdk/quota sdk/recoveryservices sdk/recoveryservicesbackup sdk/redisenterprise diff --git a/sdk/quota/azure-resourcemanager-quota/CHANGELOG.md b/sdk/quota/azure-resourcemanager-quota/CHANGELOG.md new file mode 100644 index 0000000000000..c7328cfc055a7 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2021-08-31) + +- Azure Resource Manager quota client library for Java. This package contains Microsoft Azure SDK for quota Management SDK. Microsoft Azure Quota Resource Provider. Package tag package-2021-03-15-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). diff --git a/sdk/quota/azure-resourcemanager-quota/README.md b/sdk/quota/azure-resourcemanager-quota/README.md new file mode 100644 index 0000000000000..222a59978e47d --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/README.md @@ -0,0 +1,101 @@ +# Azure Resource Manager quota client library for Java + +Azure Resource Manager quota client library for Java. + +This package contains Microsoft Azure SDK for quota Management SDK. Microsoft Azure Quota Resource Provider. Package tag package-2021-03-15-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-quota;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-quota + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation. + +### Authentication + +By default, Azure Active Directory token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, `azure` client can be authenticated by following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +QuotaManager manager = QuotaManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md diff --git a/sdk/quota/azure-resourcemanager-quota/pom.xml b/sdk/quota/azure-resourcemanager-quota/pom.xml new file mode 100644 index 0000000000000..813ea6c52899e --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/pom.xml @@ -0,0 +1,86 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-quota + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for quota Management + This package contains Microsoft Azure SDK for quota Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Microsoft Azure Quota Resource Provider. Package tag package-2021-03-15-preview. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + + com.azure + azure-core + 1.19.0 + + + com.azure + azure-core-management + 1.4.0 + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + true + + + + org.revapi + revapi-maven-plugin + 0.11.2 + + + + + java.method.addedToInterface + + + true + .* + com\.azure\.resourcemanager(\.[^.]+)+\.fluent(\.[^.]+)* + + + + + + + + diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/QuotaManager.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/QuotaManager.java new file mode 100644 index 0000000000000..0b1cc233d431f --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/QuotaManager.java @@ -0,0 +1,262 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.AzureQuotaExtensionApi; +import com.azure.resourcemanager.quota.implementation.AzureQuotaExtensionApiBuilder; +import com.azure.resourcemanager.quota.implementation.OperationsImpl; +import com.azure.resourcemanager.quota.implementation.QuotaRequestStatusImpl; +import com.azure.resourcemanager.quota.implementation.QuotasImpl; +import com.azure.resourcemanager.quota.implementation.UsagesImpl; +import com.azure.resourcemanager.quota.models.Operations; +import com.azure.resourcemanager.quota.models.QuotaRequestStatus; +import com.azure.resourcemanager.quota.models.Quotas; +import com.azure.resourcemanager.quota.models.Usages; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Entry point to QuotaManager. Microsoft Azure Quota Resource Provider. */ +public final class QuotaManager { + private Usages usages; + + private Quotas quotas; + + private QuotaRequestStatus quotaRequestStatus; + + private Operations operations; + + private final AzureQuotaExtensionApi clientObject; + + private QuotaManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new AzureQuotaExtensionApiBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of quota service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the quota service API instance. + */ + public static QuotaManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Gets a Configurable instance that can be used to create QuotaManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new QuotaManager.Configurable(); + } + + /** The Configurable allowing configurations to be set. */ + public static final class Configurable { + private final ClientLogger logger = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = Objects.requireNonNull(defaultPollInterval, "'retryPolicy' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw logger.logExceptionAsError(new IllegalArgumentException("'httpPipeline' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of quota service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the quota service API instance. + */ + public QuotaManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder + .append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.quota") + .append("/") + .append("1.0.0-beta.1"); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder + .append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new RequestIdPolicy()); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new QuotaManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of Usages. */ + public Usages usages() { + if (this.usages == null) { + this.usages = new UsagesImpl(clientObject.getUsages(), this); + } + return usages; + } + + /** @return Resource collection API of Quotas. */ + public Quotas quotas() { + if (this.quotas == null) { + this.quotas = new QuotasImpl(clientObject.getQuotas(), this); + } + return quotas; + } + + /** @return Resource collection API of QuotaRequestStatus. */ + public QuotaRequestStatus quotaRequestStatus() { + if (this.quotaRequestStatus == null) { + this.quotaRequestStatus = new QuotaRequestStatusImpl(clientObject.getQuotaRequestStatus(), this); + } + return quotaRequestStatus; + } + + /** @return Resource collection API of Operations. */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * @return Wrapped service client AzureQuotaExtensionApi providing direct access to the underlying auto-generated + * API implementation, based on Azure REST API. + */ + public AzureQuotaExtensionApi serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/AzureQuotaExtensionApi.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/AzureQuotaExtensionApi.java new file mode 100644 index 0000000000000..c411077f0237e --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/AzureQuotaExtensionApi.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for AzureQuotaExtensionApi class. */ +public interface AzureQuotaExtensionApi { + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the UsagesClient object to access its operations. + * + * @return the UsagesClient object. + */ + UsagesClient getUsages(); + + /** + * Gets the QuotasClient object to access its operations. + * + * @return the QuotasClient object. + */ + QuotasClient getQuotas(); + + /** + * Gets the QuotaRequestStatusClient object to access its operations. + * + * @return the QuotaRequestStatusClient object. + */ + QuotaRequestStatusClient getQuotaRequestStatus(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/OperationsClient.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/OperationsClient.java new file mode 100644 index 0000000000000..b873c1e774aa0 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/OperationsClient.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.resourcemanager.quota.fluent.models.OperationResponseInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/QuotaRequestStatusClient.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/QuotaRequestStatusClient.java new file mode 100644 index 0000000000000..1c1eb6e5d869d --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/QuotaRequestStatusClient.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.quota.fluent.models.QuotaRequestDetailsInner; + +/** An instance of this class provides access to all the operations defined in QuotaRequestStatusClient. */ +public interface QuotaRequestStatusClient { + /** + * Get the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. The quota request ID **id** is returned in the response of the PUT operation. + * + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + QuotaRequestDetailsInner get(String id, String scope); + + /** + * Get the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. The quota request ID **id** is returned in the response of the PUT operation. + * + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String id, String scope, Context context); + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope); + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param filter | Field | Supported operators |---------------------|------------------------ + *

|requestSubmitTime | ge, le, eq, gt, lt |provisioningState eq {QuotaRequestState} |resourceName eq + * {resourceName}. + * @param top Number of records to return. + * @param skiptoken The **Skiptoken** parameter is used only if a previous operation returned a partial result. If a + * previous response contains a **nextLink** element, its value includes a **skiptoken** parameter that + * specifies a starting point to use for subsequent calls. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list( + String scope, String filter, Integer top, String skiptoken, Context context); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/QuotasClient.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/QuotasClient.java new file mode 100644 index 0000000000000..034a676241b99 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/QuotasClient.java @@ -0,0 +1,282 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.quota.fluent.models.CurrentQuotaLimitBaseInner; +import com.azure.resourcemanager.quota.models.QuotasGetResponse; + +/** An instance of this class provides access to all the operations defined in QuotasClient. */ +public interface QuotasClient { + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CurrentQuotaLimitBaseInner get(String resourceName, String scope); + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + QuotasGetResponse getWithResponse(String resourceName, String scope, Context context); + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SyncPoller, CurrentQuotaLimitBaseInner> beginCreateOrUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest); + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SyncPoller, CurrentQuotaLimitBaseInner> beginCreateOrUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context); + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CurrentQuotaLimitBaseInner createOrUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest); + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CurrentQuotaLimitBaseInner createOrUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context); + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SyncPoller, CurrentQuotaLimitBaseInner> beginUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest); + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SyncPoller, CurrentQuotaLimitBaseInner> beginUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context); + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CurrentQuotaLimitBaseInner update(String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest); + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CurrentQuotaLimitBaseInner update( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context); + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope); + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope, Context context); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/UsagesClient.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/UsagesClient.java new file mode 100644 index 0000000000000..d310edd06f01a --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/UsagesClient.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.resourcemanager.quota.fluent.models.CurrentUsagesBaseInner; +import com.azure.resourcemanager.quota.models.UsagesGetResponse; + +/** An instance of this class provides access to all the operations defined in UsagesClient. */ +public interface UsagesClient { + /** + * Get the current usage of a resource. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the current usage of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CurrentUsagesBaseInner get(String resourceName, String scope); + + /** + * Get the current usage of a resource. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the current usage of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + UsagesGetResponse getWithResponse(String resourceName, String scope, Context context); + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope); + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope, Context context); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/CurrentQuotaLimitBaseInner.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/CurrentQuotaLimitBaseInner.java new file mode 100644 index 0000000000000..f745135c494f4 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/CurrentQuotaLimitBaseInner.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.models.QuotaProperties; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Quota limit. */ +@Fluent +public final class CurrentQuotaLimitBaseInner extends ProxyResource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(CurrentQuotaLimitBaseInner.class); + + /* + * Quota properties for the specified resource, based on the API called, + * Quotas or Usages. + */ + @JsonProperty(value = "properties") + private QuotaProperties properties; + + /** + * Get the properties property: Quota properties for the specified resource, based on the API called, Quotas or + * Usages. + * + * @return the properties value. + */ + public QuotaProperties properties() { + return this.properties; + } + + /** + * Set the properties property: Quota properties for the specified resource, based on the API called, Quotas or + * Usages. + * + * @param properties the properties value to set. + * @return the CurrentQuotaLimitBaseInner object itself. + */ + public CurrentQuotaLimitBaseInner withProperties(QuotaProperties properties) { + this.properties = properties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/CurrentUsagesBaseInner.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/CurrentUsagesBaseInner.java new file mode 100644 index 0000000000000..95f30df1b0b41 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/CurrentUsagesBaseInner.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.models.UsagesProperties; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Resource usage. */ +@Fluent +public final class CurrentUsagesBaseInner extends ProxyResource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(CurrentUsagesBaseInner.class); + + /* + * Usage properties for the specified resource. + */ + @JsonProperty(value = "properties") + private UsagesProperties properties; + + /** + * Get the properties property: Usage properties for the specified resource. + * + * @return the properties value. + */ + public UsagesProperties properties() { + return this.properties; + } + + /** + * Set the properties property: Usage properties for the specified resource. + * + * @param properties the properties value to set. + * @return the CurrentUsagesBaseInner object itself. + */ + public CurrentUsagesBaseInner withProperties(UsagesProperties properties) { + this.properties = properties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/OperationResponseInner.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/OperationResponseInner.java new file mode 100644 index 0000000000000..68486082b5cd6 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/OperationResponseInner.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.models.OperationDisplay; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The OperationResponse model. */ +@Fluent +public final class OperationResponseInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationResponseInner.class); + + /* + * The name property. + */ + @JsonProperty(value = "name") + private String name; + + /* + * The display property. + */ + @JsonProperty(value = "display") + private OperationDisplay display; + + /* + * The origin property. + */ + @JsonProperty(value = "origin") + private String origin; + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name property. + * + * @param name the name value to set. + * @return the OperationResponseInner object itself. + */ + public OperationResponseInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the display property: The display property. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the display property: The display property. + * + * @param display the display value to set. + * @return the OperationResponseInner object itself. + */ + public OperationResponseInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + + /** + * Get the origin property: The origin property. + * + * @return the origin value. + */ + public String origin() { + return this.origin; + } + + /** + * Set the origin property: The origin property. + * + * @param origin the origin value to set. + * @return the OperationResponseInner object itself. + */ + public OperationResponseInner withOrigin(String origin) { + this.origin = origin; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/QuotaRequestDetailsInner.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/QuotaRequestDetailsInner.java new file mode 100644 index 0000000000000..0a556291bcea5 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/QuotaRequestDetailsInner.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.JsonFlatten; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.models.QuotaRequestState; +import com.azure.resourcemanager.quota.models.ServiceErrorDetail; +import com.azure.resourcemanager.quota.models.SubRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.List; + +/** List of quota requests with details. */ +@JsonFlatten +@Fluent +public class QuotaRequestDetailsInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QuotaRequestDetailsInner.class); + + /* + * Quota request ID. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /* + * Quota request name. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * Resource type. "Microsoft.Quota/quotas". + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /* + * The quota request status. + */ + @JsonProperty(value = "properties.provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private QuotaRequestState provisioningState; + + /* + * User-friendly status message. + */ + @JsonProperty(value = "properties.message", access = JsonProperty.Access.WRITE_ONLY) + private String message; + + /* + * Error details of the quota request. + */ + @JsonProperty(value = "properties.error") + private ServiceErrorDetail error; + + /* + * The quota request submission time. The date conforms to the following + * format specified by the ISO 8601 standard: yyyy-MM-ddTHH:mm:ssZ + */ + @JsonProperty(value = "properties.requestSubmitTime", access = JsonProperty.Access.WRITE_ONLY) + private OffsetDateTime requestSubmitTime; + + /* + * Quota request details. + */ + @JsonProperty(value = "properties.value") + private List value; + + /** + * Get the id property: Quota request ID. + * + * @return the id value. + */ + public String id() { + return this.id; + } + + /** + * Get the name property: Quota request name. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the type property: Resource type. "Microsoft.Quota/quotas". + * + * @return the type value. + */ + public String type() { + return this.type; + } + + /** + * Get the provisioningState property: The quota request status. + * + * @return the provisioningState value. + */ + public QuotaRequestState provisioningState() { + return this.provisioningState; + } + + /** + * Get the message property: User-friendly status message. + * + * @return the message value. + */ + public String message() { + return this.message; + } + + /** + * Get the error property: Error details of the quota request. + * + * @return the error value. + */ + public ServiceErrorDetail error() { + return this.error; + } + + /** + * Set the error property: Error details of the quota request. + * + * @param error the error value to set. + * @return the QuotaRequestDetailsInner object itself. + */ + public QuotaRequestDetailsInner withError(ServiceErrorDetail error) { + this.error = error; + return this; + } + + /** + * Get the requestSubmitTime property: The quota request submission time. The date conforms to the following format + * specified by the ISO 8601 standard: yyyy-MM-ddTHH:mm:ssZ. + * + * @return the requestSubmitTime value. + */ + public OffsetDateTime requestSubmitTime() { + return this.requestSubmitTime; + } + + /** + * Get the value property: Quota request details. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: Quota request details. + * + * @param value the value value to set. + * @return the QuotaRequestDetailsInner object itself. + */ + public QuotaRequestDetailsInner withValue(List value) { + this.value = value; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (error() != null) { + error().validate(); + } + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/package-info.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/package-info.java new file mode 100644 index 0000000000000..674fb9e78bb06 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/models/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the inner data models for AzureQuotaExtensionApi. Microsoft Azure Quota Resource Provider. */ +package com.azure.resourcemanager.quota.fluent.models; diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/package-info.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/package-info.java new file mode 100644 index 0000000000000..f9b7490e09e3a --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/fluent/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the service clients for AzureQuotaExtensionApi. Microsoft Azure Quota Resource Provider. */ +package com.azure.resourcemanager.quota.fluent; diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/AzureQuotaExtensionApiBuilder.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/AzureQuotaExtensionApiBuilder.java new file mode 100644 index 0000000000000..3b8210d620475 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/AzureQuotaExtensionApiBuilder.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** A builder for creating a new instance of the AzureQuotaExtensionApiImpl type. */ +@ServiceClientBuilder(serviceClients = {AzureQuotaExtensionApiImpl.class}) +public final class AzureQuotaExtensionApiBuilder { + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the AzureQuotaExtensionApiBuilder. + */ + public AzureQuotaExtensionApiBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the AzureQuotaExtensionApiBuilder. + */ + public AzureQuotaExtensionApiBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the AzureQuotaExtensionApiBuilder. + */ + public AzureQuotaExtensionApiBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the AzureQuotaExtensionApiBuilder. + */ + public AzureQuotaExtensionApiBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the AzureQuotaExtensionApiBuilder. + */ + public AzureQuotaExtensionApiBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of AzureQuotaExtensionApiImpl with the provided parameters. + * + * @return an instance of AzureQuotaExtensionApiImpl. + */ + public AzureQuotaExtensionApiImpl buildClient() { + if (endpoint == null) { + this.endpoint = "https://management.azure.com"; + } + if (environment == null) { + this.environment = AzureEnvironment.AZURE; + } + if (defaultPollInterval == null) { + this.defaultPollInterval = Duration.ofSeconds(30); + } + if (pipeline == null) { + this.pipeline = + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(); + } + if (serializerAdapter == null) { + this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter(); + } + AzureQuotaExtensionApiImpl client = + new AzureQuotaExtensionApiImpl(pipeline, serializerAdapter, defaultPollInterval, environment, endpoint); + return client; + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/AzureQuotaExtensionApiImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/AzureQuotaExtensionApiImpl.java new file mode 100644 index 0000000000000..9c2ea5b836547 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/AzureQuotaExtensionApiImpl.java @@ -0,0 +1,320 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.quota.fluent.AzureQuotaExtensionApi; +import com.azure.resourcemanager.quota.fluent.OperationsClient; +import com.azure.resourcemanager.quota.fluent.QuotaRequestStatusClient; +import com.azure.resourcemanager.quota.fluent.QuotasClient; +import com.azure.resourcemanager.quota.fluent.UsagesClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.Map; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the AzureQuotaExtensionApiImpl type. */ +@ServiceClient(builder = AzureQuotaExtensionApiBuilder.class) +public final class AzureQuotaExtensionApiImpl implements AzureQuotaExtensionApi { + private final ClientLogger logger = new ClientLogger(AzureQuotaExtensionApiImpl.class); + + /** server parameter. */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Api Version. */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** The default poll interval for long-running operation. */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** The UsagesClient object to access its operations. */ + private final UsagesClient usages; + + /** + * Gets the UsagesClient object to access its operations. + * + * @return the UsagesClient object. + */ + public UsagesClient getUsages() { + return this.usages; + } + + /** The QuotasClient object to access its operations. */ + private final QuotasClient quotas; + + /** + * Gets the QuotasClient object to access its operations. + * + * @return the QuotasClient object. + */ + public QuotasClient getQuotas() { + return this.quotas; + } + + /** The QuotaRequestStatusClient object to access its operations. */ + private final QuotaRequestStatusClient quotaRequestStatus; + + /** + * Gets the QuotaRequestStatusClient object to access its operations. + * + * @return the QuotaRequestStatusClient object. + */ + public QuotaRequestStatusClient getQuotaRequestStatus() { + return this.quotaRequestStatus; + } + + /** The OperationsClient object to access its operations. */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * Initializes an instance of AzureQuotaExtensionApi client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint server parameter. + */ + AzureQuotaExtensionApiImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + Duration defaultPollInterval, + AzureEnvironment environment, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.apiVersion = "2021-03-15-preview"; + this.usages = new UsagesClientImpl(this); + this.quotas = new QuotasClientImpl(this); + this.quotaRequestStatus = new QuotaRequestStatusClientImpl(this); + this.operations = new OperationsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + for (Map.Entry entry : this.getContext().getValues().entrySet()) { + context = context.addData(entry.getKey(), entry.getValue()); + } + return context; + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult( + Mono>> activationResponse, + HttpPipeline httpPipeline, + Type pollResultType, + Type finalResultType, + Context context) { + return PollerFactory + .create( + serializerAdapter, + httpPipeline, + pollResultType, + finalResultType, + defaultPollInterval, + activationResponse, + context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = + new HttpResponseImpl( + lroError.getResponseStatusCode(), lroError.getResponseHeaders(), lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = + this + .getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + logger.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(s); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/CurrentQuotaLimitBaseImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/CurrentQuotaLimitBaseImpl.java new file mode 100644 index 0000000000000..689dec0359d01 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/CurrentQuotaLimitBaseImpl.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.quota.fluent.models.CurrentQuotaLimitBaseInner; +import com.azure.resourcemanager.quota.models.CurrentQuotaLimitBase; +import com.azure.resourcemanager.quota.models.QuotaProperties; + +public final class CurrentQuotaLimitBaseImpl + implements CurrentQuotaLimitBase, CurrentQuotaLimitBase.Definition, CurrentQuotaLimitBase.Update { + private CurrentQuotaLimitBaseInner innerObject; + + private final com.azure.resourcemanager.quota.QuotaManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public QuotaProperties properties() { + return this.innerModel().properties(); + } + + public CurrentQuotaLimitBaseInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.quota.QuotaManager manager() { + return this.serviceManager; + } + + private String resourceName; + + private String scope; + + public CurrentQuotaLimitBaseImpl withExistingScope(String scope) { + this.scope = scope; + return this; + } + + public CurrentQuotaLimitBase create() { + this.innerObject = + serviceManager + .serviceClient() + .getQuotas() + .createOrUpdate(resourceName, scope, this.innerModel(), Context.NONE); + return this; + } + + public CurrentQuotaLimitBase create(Context context) { + this.innerObject = + serviceManager.serviceClient().getQuotas().createOrUpdate(resourceName, scope, this.innerModel(), context); + return this; + } + + CurrentQuotaLimitBaseImpl(String name, com.azure.resourcemanager.quota.QuotaManager serviceManager) { + this.innerObject = new CurrentQuotaLimitBaseInner(); + this.serviceManager = serviceManager; + this.resourceName = name; + } + + public CurrentQuotaLimitBaseImpl update() { + return this; + } + + public CurrentQuotaLimitBase apply() { + this.innerObject = + serviceManager.serviceClient().getQuotas().update(resourceName, scope, this.innerModel(), Context.NONE); + return this; + } + + public CurrentQuotaLimitBase apply(Context context) { + this.innerObject = + serviceManager.serviceClient().getQuotas().update(resourceName, scope, this.innerModel(), context); + return this; + } + + CurrentQuotaLimitBaseImpl( + CurrentQuotaLimitBaseInner innerObject, com.azure.resourcemanager.quota.QuotaManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceName = + Utils + .getValueFromIdByParameterName( + innerObject.id(), "/{scope}/providers/Microsoft.Quota/quotas/{resourceName}", "resourceName"); + this.scope = + Utils + .getValueFromIdByParameterName( + innerObject.id(), "/{scope}/providers/Microsoft.Quota/quotas/{resourceName}", "scope"); + } + + public CurrentQuotaLimitBase refresh() { + this.innerObject = + serviceManager.serviceClient().getQuotas().getWithResponse(resourceName, scope, Context.NONE).getValue(); + return this; + } + + public CurrentQuotaLimitBase refresh(Context context) { + this.innerObject = + serviceManager.serviceClient().getQuotas().getWithResponse(resourceName, scope, context).getValue(); + return this; + } + + public CurrentQuotaLimitBaseImpl withProperties(QuotaProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/CurrentUsagesBaseImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/CurrentUsagesBaseImpl.java new file mode 100644 index 0000000000000..1a1fb6f75eba7 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/CurrentUsagesBaseImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.resourcemanager.quota.fluent.models.CurrentUsagesBaseInner; +import com.azure.resourcemanager.quota.models.CurrentUsagesBase; +import com.azure.resourcemanager.quota.models.UsagesProperties; + +public final class CurrentUsagesBaseImpl implements CurrentUsagesBase { + private CurrentUsagesBaseInner innerObject; + + private final com.azure.resourcemanager.quota.QuotaManager serviceManager; + + CurrentUsagesBaseImpl( + CurrentUsagesBaseInner innerObject, com.azure.resourcemanager.quota.QuotaManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public UsagesProperties properties() { + return this.innerModel().properties(); + } + + public CurrentUsagesBaseInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.quota.QuotaManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/OperationResponseImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/OperationResponseImpl.java new file mode 100644 index 0000000000000..a175ac88897d2 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/OperationResponseImpl.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.resourcemanager.quota.fluent.models.OperationResponseInner; +import com.azure.resourcemanager.quota.models.OperationDisplay; +import com.azure.resourcemanager.quota.models.OperationResponse; + +public final class OperationResponseImpl implements OperationResponse { + private OperationResponseInner innerObject; + + private final com.azure.resourcemanager.quota.QuotaManager serviceManager; + + OperationResponseImpl( + OperationResponseInner innerObject, com.azure.resourcemanager.quota.QuotaManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public String origin() { + return this.innerModel().origin(); + } + + public OperationResponseInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.quota.QuotaManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/OperationsClientImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/OperationsClientImpl.java new file mode 100644 index 0000000000000..0f1e4152c6426 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/OperationsClientImpl.java @@ -0,0 +1,269 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.OperationsClient; +import com.azure.resourcemanager.quota.fluent.models.OperationResponseInner; +import com.azure.resourcemanager.quota.models.OperationList; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public final class OperationsClientImpl implements OperationsClient { + private final ClientLogger logger = new ClientLogger(OperationsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final OperationsService service; + + /** The service client containing this operation class. */ + private final AzureQuotaExtensionApiImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(AzureQuotaExtensionApiImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureQuotaExtensionApiOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureQuotaExtensionA") + private interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.Quota/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/OperationsImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/OperationsImpl.java new file mode 100644 index 0000000000000..bfe495bd8e2cc --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.OperationsClient; +import com.azure.resourcemanager.quota.fluent.models.OperationResponseInner; +import com.azure.resourcemanager.quota.models.OperationResponse; +import com.azure.resourcemanager.quota.models.Operations; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class OperationsImpl implements Operations { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.quota.QuotaManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, com.azure.resourcemanager.quota.QuotaManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new OperationResponseImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new OperationResponseImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.quota.QuotaManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotaRequestDetailsImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotaRequestDetailsImpl.java new file mode 100644 index 0000000000000..0f716c8e90b31 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotaRequestDetailsImpl.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.resourcemanager.quota.fluent.models.QuotaRequestDetailsInner; +import com.azure.resourcemanager.quota.models.QuotaRequestDetails; +import com.azure.resourcemanager.quota.models.QuotaRequestState; +import com.azure.resourcemanager.quota.models.ServiceErrorDetail; +import com.azure.resourcemanager.quota.models.SubRequest; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.List; + +public final class QuotaRequestDetailsImpl implements QuotaRequestDetails { + private QuotaRequestDetailsInner innerObject; + + private final com.azure.resourcemanager.quota.QuotaManager serviceManager; + + QuotaRequestDetailsImpl( + QuotaRequestDetailsInner innerObject, com.azure.resourcemanager.quota.QuotaManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public QuotaRequestState provisioningState() { + return this.innerModel().provisioningState(); + } + + public String message() { + return this.innerModel().message(); + } + + public ServiceErrorDetail error() { + return this.innerModel().error(); + } + + public OffsetDateTime requestSubmitTime() { + return this.innerModel().requestSubmitTime(); + } + + public List value() { + List inner = this.innerModel().value(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public QuotaRequestDetailsInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.quota.QuotaManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotaRequestStatusClientImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotaRequestStatusClientImpl.java new file mode 100644 index 0000000000000..cb58b7953fab6 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotaRequestStatusClientImpl.java @@ -0,0 +1,542 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.QuotaRequestStatusClient; +import com.azure.resourcemanager.quota.fluent.models.QuotaRequestDetailsInner; +import com.azure.resourcemanager.quota.models.QuotaRequestDetailsList; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in QuotaRequestStatusClient. */ +public final class QuotaRequestStatusClientImpl implements QuotaRequestStatusClient { + private final ClientLogger logger = new ClientLogger(QuotaRequestStatusClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final QuotaRequestStatusService service; + + /** The service client containing this operation class. */ + private final AzureQuotaExtensionApiImpl client; + + /** + * Initializes an instance of QuotaRequestStatusClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QuotaRequestStatusClientImpl(AzureQuotaExtensionApiImpl client) { + this.service = + RestProxy.create(QuotaRequestStatusService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureQuotaExtensionApiQuotaRequestStatus to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureQuotaExtensionA") + private interface QuotaRequestStatusService { + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.Quota/quotaRequests/{id}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get( + @HostParam("$host") String endpoint, + @PathParam("id") String id, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "scope", encoded = true) String scope, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.Quota/quotaRequests") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "scope", encoded = true) String scope, + @QueryParam("$filter") String filter, + @QueryParam("$top") Integer top, + @QueryParam("$skiptoken") String skiptoken, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Get the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. The quota request ID **id** is returned in the response of the PUT operation. + * + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String id, String scope) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (id == null) { + return Mono.error(new IllegalArgumentException("Parameter id is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service.get(this.client.getEndpoint(), id, this.client.getApiVersion(), scope, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. The quota request ID **id** is returned in the response of the PUT operation. + * + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String id, String scope, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (id == null) { + return Mono.error(new IllegalArgumentException("Parameter id is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), id, this.client.getApiVersion(), scope, accept, context); + } + + /** + * Get the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. The quota request ID **id** is returned in the response of the PUT operation. + * + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String id, String scope) { + return getWithResponseAsync(id, scope) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. The quota request ID **id** is returned in the response of the PUT operation. + * + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public QuotaRequestDetailsInner get(String id, String scope) { + return getAsync(id, scope).block(); + } + + /** + * Get the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. The quota request ID **id** is returned in the response of the PUT operation. + * + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String id, String scope, Context context) { + return getWithResponseAsync(id, scope, context).block(); + } + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param filter | Field | Supported operators |---------------------|------------------------ + *

|requestSubmitTime | ge, le, eq, gt, lt |provisioningState eq {QuotaRequestState} |resourceName eq + * {resourceName}. + * @param top Number of records to return. + * @param skiptoken The **Skiptoken** parameter is used only if a previous operation returned a partial result. If a + * previous response contains a **nextLink** element, its value includes a **skiptoken** parameter that + * specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync( + String scope, String filter, Integer top, String skiptoken) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .list( + this.client.getEndpoint(), + this.client.getApiVersion(), + scope, + filter, + top, + skiptoken, + accept, + context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param filter | Field | Supported operators |---------------------|------------------------ + *

|requestSubmitTime | ge, le, eq, gt, lt |provisioningState eq {QuotaRequestState} |resourceName eq + * {resourceName}. + * @param top Number of records to return. + * @param skiptoken The **Skiptoken** parameter is used only if a previous operation returned a partial result. If a + * previous response contains a **nextLink** element, its value includes a **skiptoken** parameter that + * specifies a starting point to use for subsequent calls. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync( + String scope, String filter, Integer top, String skiptoken, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list( + this.client.getEndpoint(), this.client.getApiVersion(), scope, filter, top, skiptoken, accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param filter | Field | Supported operators |---------------------|------------------------ + *

|requestSubmitTime | ge, le, eq, gt, lt |provisioningState eq {QuotaRequestState} |resourceName eq + * {resourceName}. + * @param top Number of records to return. + * @param skiptoken The **Skiptoken** parameter is used only if a previous operation returned a partial result. If a + * previous response contains a **nextLink** element, its value includes a **skiptoken** parameter that + * specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope, String filter, Integer top, String skiptoken) { + return new PagedFlux<>( + () -> listSinglePageAsync(scope, filter, top, skiptoken), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope) { + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return new PagedFlux<>( + () -> listSinglePageAsync(scope, filter, top, skiptoken), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param filter | Field | Supported operators |---------------------|------------------------ + *

|requestSubmitTime | ge, le, eq, gt, lt |provisioningState eq {QuotaRequestState} |resourceName eq + * {resourceName}. + * @param top Number of records to return. + * @param skiptoken The **Skiptoken** parameter is used only if a previous operation returned a partial result. If a + * previous response contains a **nextLink** element, its value includes a **skiptoken** parameter that + * specifies a starting point to use for subsequent calls. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync( + String scope, String filter, Integer top, String skiptoken, Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(scope, filter, top, skiptoken, context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope) { + final String filter = null; + final Integer top = null; + final String skiptoken = null; + return new PagedIterable<>(listAsync(scope, filter, top, skiptoken)); + } + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param filter | Field | Supported operators |---------------------|------------------------ + *

|requestSubmitTime | ge, le, eq, gt, lt |provisioningState eq {QuotaRequestState} |resourceName eq + * {resourceName}. + * @param top Number of records to return. + * @param skiptoken The **Skiptoken** parameter is used only if a previous operation returned a partial result. If a + * previous response contains a **nextLink** element, its value includes a **skiptoken** parameter that + * specifies a starting point to use for subsequent calls. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list( + String scope, String filter, Integer top, String skiptoken, Context context) { + return new PagedIterable<>(listAsync(scope, filter, top, skiptoken, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotaRequestStatusImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotaRequestStatusImpl.java new file mode 100644 index 0000000000000..6b25090f3197c --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotaRequestStatusImpl.java @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.QuotaRequestStatusClient; +import com.azure.resourcemanager.quota.fluent.models.QuotaRequestDetailsInner; +import com.azure.resourcemanager.quota.models.QuotaRequestDetails; +import com.azure.resourcemanager.quota.models.QuotaRequestStatus; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class QuotaRequestStatusImpl implements QuotaRequestStatus { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QuotaRequestStatusImpl.class); + + private final QuotaRequestStatusClient innerClient; + + private final com.azure.resourcemanager.quota.QuotaManager serviceManager; + + public QuotaRequestStatusImpl( + QuotaRequestStatusClient innerClient, com.azure.resourcemanager.quota.QuotaManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public QuotaRequestDetails get(String id, String scope) { + QuotaRequestDetailsInner inner = this.serviceClient().get(id, scope); + if (inner != null) { + return new QuotaRequestDetailsImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getWithResponse(String id, String scope, Context context) { + Response inner = this.serviceClient().getWithResponse(id, scope, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new QuotaRequestDetailsImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public PagedIterable list(String scope) { + PagedIterable inner = this.serviceClient().list(scope); + return Utils.mapPage(inner, inner1 -> new QuotaRequestDetailsImpl(inner1, this.manager())); + } + + public PagedIterable list( + String scope, String filter, Integer top, String skiptoken, Context context) { + PagedIterable inner = + this.serviceClient().list(scope, filter, top, skiptoken, context); + return Utils.mapPage(inner, inner1 -> new QuotaRequestDetailsImpl(inner1, this.manager())); + } + + private QuotaRequestStatusClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.quota.QuotaManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotasClientImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotasClientImpl.java new file mode 100644 index 0000000000000..6c064b48185da --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotasClientImpl.java @@ -0,0 +1,1198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.quota.fluent.QuotasClient; +import com.azure.resourcemanager.quota.fluent.models.CurrentQuotaLimitBaseInner; +import com.azure.resourcemanager.quota.models.QuotasGetResponse; +import com.azure.resourcemanager.quota.models.QuotasListNextResponse; +import com.azure.resourcemanager.quota.models.QuotasListResponse; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in QuotasClient. */ +public final class QuotasClientImpl implements QuotasClient { + private final ClientLogger logger = new ClientLogger(QuotasClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final QuotasService service; + + /** The service client containing this operation class. */ + private final AzureQuotaExtensionApiImpl client; + + /** + * Initializes an instance of QuotasClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QuotasClientImpl(AzureQuotaExtensionApiImpl client) { + this.service = RestProxy.create(QuotasService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureQuotaExtensionApiQuotas to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureQuotaExtensionA") + private interface QuotasService { + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.Quota/quotas/{resourceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono get( + @HostParam("$host") String endpoint, + @PathParam("resourceName") String resourceName, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "scope", encoded = true) String scope, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put("/{scope}/providers/Microsoft.Quota/quotas/{resourceName}") + @ExpectedResponses({200, 202}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate( + @HostParam("$host") String endpoint, + @PathParam("resourceName") String resourceName, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "scope", encoded = true) String scope, + @BodyParam("application/json") CurrentQuotaLimitBaseInner createQuotaRequest, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch("/{scope}/providers/Microsoft.Quota/quotas/{resourceName}") + @ExpectedResponses({200, 202}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> update( + @HostParam("$host") String endpoint, + @PathParam("resourceName") String resourceName, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "scope", encoded = true) String scope, + @BodyParam("application/json") CurrentQuotaLimitBaseInner createQuotaRequest, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.Quota/quotas") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "scope", encoded = true) String scope, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getWithResponseAsync(String resourceName, String scope) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .get( + this.client.getEndpoint(), + resourceName, + this.client.getApiVersion(), + scope, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getWithResponseAsync(String resourceName, String scope, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .get(this.client.getEndpoint(), resourceName, this.client.getApiVersion(), scope, accept, context); + } + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceName, String scope) { + return getWithResponseAsync(resourceName, scope) + .flatMap( + (QuotasGetResponse res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CurrentQuotaLimitBaseInner get(String resourceName, String scope) { + return getAsync(resourceName, scope).block(); + } + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public QuotasGetResponse getWithResponse(String resourceName, String scope, Context context) { + return getWithResponseAsync(resourceName, scope, context).block(); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + if (createQuotaRequest == null) { + return Mono + .error(new IllegalArgumentException("Parameter createQuotaRequest is required and cannot be null.")); + } else { + createQuotaRequest.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createOrUpdate( + this.client.getEndpoint(), + resourceName, + this.client.getApiVersion(), + scope, + createQuotaRequest, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + if (createQuotaRequest == null) { + return Mono + .error(new IllegalArgumentException("Parameter createQuotaRequest is required and cannot be null.")); + } else { + createQuotaRequest.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createOrUpdate( + this.client.getEndpoint(), + resourceName, + this.client.getApiVersion(), + scope, + createQuotaRequest, + accept, + context); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PollerFlux, CurrentQuotaLimitBaseInner> beginCreateOrUpdateAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + Mono>> mono = + createOrUpdateWithResponseAsync(resourceName, scope, createQuotaRequest); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + CurrentQuotaLimitBaseInner.class, + CurrentQuotaLimitBaseInner.class, + Context.NONE); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PollerFlux, CurrentQuotaLimitBaseInner> beginCreateOrUpdateAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = + createOrUpdateWithResponseAsync(resourceName, scope, createQuotaRequest, context); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + CurrentQuotaLimitBaseInner.class, + CurrentQuotaLimitBaseInner.class, + context); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SyncPoller, CurrentQuotaLimitBaseInner> beginCreateOrUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + return beginCreateOrUpdateAsync(resourceName, scope, createQuotaRequest).getSyncPoller(); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SyncPoller, CurrentQuotaLimitBaseInner> beginCreateOrUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + return beginCreateOrUpdateAsync(resourceName, scope, createQuotaRequest, context).getSyncPoller(); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + return beginCreateOrUpdateAsync(resourceName, scope, createQuotaRequest) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + return beginCreateOrUpdateAsync(resourceName, scope, createQuotaRequest, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CurrentQuotaLimitBaseInner createOrUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + return createOrUpdateAsync(resourceName, scope, createQuotaRequest).block(); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the quota, follow + * these steps: 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota request payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CurrentQuotaLimitBaseInner createOrUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + return createOrUpdateAsync(resourceName, scope, createQuotaRequest, context).block(); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + if (createQuotaRequest == null) { + return Mono + .error(new IllegalArgumentException("Parameter createQuotaRequest is required and cannot be null.")); + } else { + createQuotaRequest.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + resourceName, + this.client.getApiVersion(), + scope, + createQuotaRequest, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + if (createQuotaRequest == null) { + return Mono + .error(new IllegalArgumentException("Parameter createQuotaRequest is required and cannot be null.")); + } else { + createQuotaRequest.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + resourceName, + this.client.getApiVersion(), + scope, + createQuotaRequest, + accept, + context); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PollerFlux, CurrentQuotaLimitBaseInner> beginUpdateAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + Mono>> mono = updateWithResponseAsync(resourceName, scope, createQuotaRequest); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + CurrentQuotaLimitBaseInner.class, + CurrentQuotaLimitBaseInner.class, + Context.NONE); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PollerFlux, CurrentQuotaLimitBaseInner> beginUpdateAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = + updateWithResponseAsync(resourceName, scope, createQuotaRequest, context); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + CurrentQuotaLimitBaseInner.class, + CurrentQuotaLimitBaseInner.class, + context); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SyncPoller, CurrentQuotaLimitBaseInner> beginUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + return beginUpdateAsync(resourceName, scope, createQuotaRequest).getSyncPoller(); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SyncPoller, CurrentQuotaLimitBaseInner> beginUpdate( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + return beginUpdateAsync(resourceName, scope, createQuotaRequest, context).getSyncPoller(); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + return beginUpdateAsync(resourceName, scope, createQuotaRequest) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + return beginUpdateAsync(resourceName, scope, createQuotaRequest, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CurrentQuotaLimitBaseInner update( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest) { + return updateAsync(resourceName, scope, createQuotaRequest).block(); + } + + /** + * Update the quota limit for a specific resource to the specified value: 1. Use the Usages-GET and Quota-GET + * operations to determine the remaining quota for the specific resource and to calculate the new quota limit. These + * steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the detailed + * status of the request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param createQuotaRequest Quota requests payload. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CurrentQuotaLimitBaseInner update( + String resourceName, String scope, CurrentQuotaLimitBaseInner createQuotaRequest, Context context) { + return updateAsync(resourceName, scope, createQuotaRequest, context).block(); + } + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String scope) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), scope, accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + res.getDeserializedHeaders())) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String scope, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), scope, accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + res.getDeserializedHeaders())); + } + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope) { + return new PagedFlux<>(() -> listSinglePageAsync(scope), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope, Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(scope, context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope) { + return new PagedIterable<>(listAsync(scope)); + } + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope, Context context) { + return new PagedIterable<>(listAsync(scope, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limits. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + res.getDeserializedHeaders())) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limits. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + res.getDeserializedHeaders())); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotasImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotasImpl.java new file mode 100644 index 0000000000000..9eeeaeebd3c76 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/QuotasImpl.java @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.QuotasClient; +import com.azure.resourcemanager.quota.fluent.models.CurrentQuotaLimitBaseInner; +import com.azure.resourcemanager.quota.models.CurrentQuotaLimitBase; +import com.azure.resourcemanager.quota.models.Quotas; +import com.azure.resourcemanager.quota.models.QuotasGetResponse; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class QuotasImpl implements Quotas { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QuotasImpl.class); + + private final QuotasClient innerClient; + + private final com.azure.resourcemanager.quota.QuotaManager serviceManager; + + public QuotasImpl(QuotasClient innerClient, com.azure.resourcemanager.quota.QuotaManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public CurrentQuotaLimitBase get(String resourceName, String scope) { + CurrentQuotaLimitBaseInner inner = this.serviceClient().get(resourceName, scope); + if (inner != null) { + return new CurrentQuotaLimitBaseImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getWithResponse(String resourceName, String scope, Context context) { + QuotasGetResponse inner = this.serviceClient().getWithResponse(resourceName, scope, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new CurrentQuotaLimitBaseImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public PagedIterable list(String scope) { + PagedIterable inner = this.serviceClient().list(scope); + return Utils.mapPage(inner, inner1 -> new CurrentQuotaLimitBaseImpl(inner1, this.manager())); + } + + public PagedIterable list(String scope, Context context) { + PagedIterable inner = this.serviceClient().list(scope, context); + return Utils.mapPage(inner, inner1 -> new CurrentQuotaLimitBaseImpl(inner1, this.manager())); + } + + public CurrentQuotaLimitBase getById(String id) { + String resourceName = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.Quota/quotas/{resourceName}", "resourceName"); + if (resourceName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'quotas'.", id))); + } + String scope = + Utils + .getValueFromIdByParameterName(id, "/{scope}/providers/Microsoft.Quota/quotas/{resourceName}", "scope"); + if (scope == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id))); + } + return this.getWithResponse(resourceName, scope, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceName = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.Quota/quotas/{resourceName}", "resourceName"); + if (resourceName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'quotas'.", id))); + } + String scope = + Utils + .getValueFromIdByParameterName(id, "/{scope}/providers/Microsoft.Quota/quotas/{resourceName}", "scope"); + if (scope == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id))); + } + return this.getWithResponse(resourceName, scope, context); + } + + private QuotasClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.quota.QuotaManager manager() { + return this.serviceManager; + } + + public CurrentQuotaLimitBaseImpl define(String name) { + return new CurrentQuotaLimitBaseImpl(name, this.manager()); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/UsagesClientImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/UsagesClientImpl.java new file mode 100644 index 0000000000000..08061c51e22b1 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/UsagesClientImpl.java @@ -0,0 +1,459 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.UsagesClient; +import com.azure.resourcemanager.quota.fluent.models.CurrentUsagesBaseInner; +import com.azure.resourcemanager.quota.models.UsagesGetResponse; +import com.azure.resourcemanager.quota.models.UsagesListNextResponse; +import com.azure.resourcemanager.quota.models.UsagesListResponse; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in UsagesClient. */ +public final class UsagesClientImpl implements UsagesClient { + private final ClientLogger logger = new ClientLogger(UsagesClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final UsagesService service; + + /** The service client containing this operation class. */ + private final AzureQuotaExtensionApiImpl client; + + /** + * Initializes an instance of UsagesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UsagesClientImpl(AzureQuotaExtensionApiImpl client) { + this.service = RestProxy.create(UsagesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureQuotaExtensionApiUsages to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureQuotaExtensionA") + private interface UsagesService { + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.Quota/usages/{resourceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono get( + @HostParam("$host") String endpoint, + @PathParam("resourceName") String resourceName, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "scope", encoded = true) String scope, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.Quota/usages") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "scope", encoded = true) String scope, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Get the current usage of a resource. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the current usage of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getWithResponseAsync(String resourceName, String scope) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .get( + this.client.getEndpoint(), + resourceName, + this.client.getApiVersion(), + scope, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the current usage of a resource. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the current usage of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getWithResponseAsync(String resourceName, String scope, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .get(this.client.getEndpoint(), resourceName, this.client.getApiVersion(), scope, accept, context); + } + + /** + * Get the current usage of a resource. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the current usage of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceName, String scope) { + return getWithResponseAsync(resourceName, scope) + .flatMap( + (UsagesGetResponse res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get the current usage of a resource. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the current usage of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CurrentUsagesBaseInner get(String resourceName, String scope) { + return getAsync(resourceName, scope).block(); + } + + /** + * Get the current usage of a resource. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the current usage of a resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public UsagesGetResponse getWithResponse(String resourceName, String scope, Context context) { + return getWithResponseAsync(resourceName, scope, context).block(); + } + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String scope) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), scope, accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + res.getDeserializedHeaders())) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String scope, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (scope == null) { + return Mono.error(new IllegalArgumentException("Parameter scope is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), scope, accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + res.getDeserializedHeaders())); + } + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope) { + return new PagedFlux<>(() -> listSinglePageAsync(scope), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope, Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(scope, context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope) { + return new PagedIterable<>(listAsync(scope)); + } + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope, Context context) { + return new PagedIterable<>(listAsync(scope, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limits. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + res.getDeserializedHeaders())) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota limits. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + res.getDeserializedHeaders())); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/UsagesImpl.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/UsagesImpl.java new file mode 100644 index 0000000000000..9d6cc6a56f76e --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/UsagesImpl.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.UsagesClient; +import com.azure.resourcemanager.quota.fluent.models.CurrentUsagesBaseInner; +import com.azure.resourcemanager.quota.models.CurrentUsagesBase; +import com.azure.resourcemanager.quota.models.Usages; +import com.azure.resourcemanager.quota.models.UsagesGetResponse; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class UsagesImpl implements Usages { + @JsonIgnore private final ClientLogger logger = new ClientLogger(UsagesImpl.class); + + private final UsagesClient innerClient; + + private final com.azure.resourcemanager.quota.QuotaManager serviceManager; + + public UsagesImpl(UsagesClient innerClient, com.azure.resourcemanager.quota.QuotaManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public CurrentUsagesBase get(String resourceName, String scope) { + CurrentUsagesBaseInner inner = this.serviceClient().get(resourceName, scope); + if (inner != null) { + return new CurrentUsagesBaseImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getWithResponse(String resourceName, String scope, Context context) { + UsagesGetResponse inner = this.serviceClient().getWithResponse(resourceName, scope, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new CurrentUsagesBaseImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public PagedIterable list(String scope) { + PagedIterable inner = this.serviceClient().list(scope); + return Utils.mapPage(inner, inner1 -> new CurrentUsagesBaseImpl(inner1, this.manager())); + } + + public PagedIterable list(String scope, Context context) { + PagedIterable inner = this.serviceClient().list(scope, context); + return Utils.mapPage(inner, inner1 -> new CurrentUsagesBaseImpl(inner1, this.manager())); + } + + private UsagesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.quota.QuotaManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/Utils.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/Utils.java new file mode 100644 index 0000000000000..b893884d3edad --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/Utils.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class Utils { + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (segments.size() > 0 && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super( + PagedFlux + .create( + () -> + (continuationToken, pageSize) -> + Flux.fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> + new PagedResponseBase( + page.getRequest(), + page.getStatusCode(), + page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), + page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl, PagedResponse>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/package-info.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/package-info.java new file mode 100644 index 0000000000000..84f250ba9a927 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/implementation/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the implementations for AzureQuotaExtensionApi. Microsoft Azure Quota Resource Provider. */ +package com.azure.resourcemanager.quota.implementation; diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/CurrentQuotaLimitBase.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/CurrentQuotaLimitBase.java new file mode 100644 index 0000000000000..e17b2c44c1285 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/CurrentQuotaLimitBase.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.quota.fluent.models.CurrentQuotaLimitBaseInner; + +/** An immutable client-side representation of CurrentQuotaLimitBase. */ +public interface CurrentQuotaLimitBase { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: Quota properties for the specified resource, based on the API called, Quotas or + * Usages. + * + * @return the properties value. + */ + QuotaProperties properties(); + + /** + * Gets the inner com.azure.resourcemanager.quota.fluent.models.CurrentQuotaLimitBaseInner object. + * + * @return the inner object. + */ + CurrentQuotaLimitBaseInner innerModel(); + + /** The entirety of the CurrentQuotaLimitBase definition. */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithScope, DefinitionStages.WithCreate { + } + /** The CurrentQuotaLimitBase definition stages. */ + interface DefinitionStages { + /** The first stage of the CurrentQuotaLimitBase definition. */ + interface Blank extends WithScope { + } + /** The stage of the CurrentQuotaLimitBase definition allowing to specify parent resource. */ + interface WithScope { + /** + * Specifies scope. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @return the next definition stage. + */ + WithCreate withExistingScope(String scope); + } + /** + * The stage of the CurrentQuotaLimitBase definition which contains all the minimum required properties for the + * resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + CurrentQuotaLimitBase create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + CurrentQuotaLimitBase create(Context context); + } + /** The stage of the CurrentQuotaLimitBase definition allowing to specify properties. */ + interface WithProperties { + /** + * Specifies the properties property: Quota properties for the specified resource, based on the API called, + * Quotas or Usages.. + * + * @param properties Quota properties for the specified resource, based on the API called, Quotas or Usages. + * @return the next definition stage. + */ + WithCreate withProperties(QuotaProperties properties); + } + } + /** + * Begins update for the CurrentQuotaLimitBase resource. + * + * @return the stage of resource update. + */ + CurrentQuotaLimitBase.Update update(); + + /** The template for CurrentQuotaLimitBase update. */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + CurrentQuotaLimitBase apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + CurrentQuotaLimitBase apply(Context context); + } + /** The CurrentQuotaLimitBase update stages. */ + interface UpdateStages { + /** The stage of the CurrentQuotaLimitBase update allowing to specify properties. */ + interface WithProperties { + /** + * Specifies the properties property: Quota properties for the specified resource, based on the API called, + * Quotas or Usages.. + * + * @param properties Quota properties for the specified resource, based on the API called, Quotas or Usages. + * @return the next definition stage. + */ + Update withProperties(QuotaProperties properties); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + CurrentQuotaLimitBase refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + CurrentQuotaLimitBase refresh(Context context); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/CurrentUsagesBase.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/CurrentUsagesBase.java new file mode 100644 index 0000000000000..e406afed5eb89 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/CurrentUsagesBase.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.resourcemanager.quota.fluent.models.CurrentUsagesBaseInner; + +/** An immutable client-side representation of CurrentUsagesBase. */ +public interface CurrentUsagesBase { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: Usage properties for the specified resource. + * + * @return the properties value. + */ + UsagesProperties properties(); + + /** + * Gets the inner com.azure.resourcemanager.quota.fluent.models.CurrentUsagesBaseInner object. + * + * @return the inner object. + */ + CurrentUsagesBaseInner innerModel(); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitJsonObject.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitJsonObject.java new file mode 100644 index 0000000000000..b47dca3f93e39 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitJsonObject.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** LimitJson abstract class. */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "limitObjectType", + defaultImpl = LimitJsonObject.class) +@JsonTypeName("LimitJsonObject") +@JsonSubTypes({@JsonSubTypes.Type(name = "LimitValue", value = LimitValue.class)}) +@Immutable +public class LimitJsonObject { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LimitJsonObject.class); + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitObject.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitObject.java new file mode 100644 index 0000000000000..2a4df7e2d4c85 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitObject.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The resource quota limit value. */ +@Fluent +public class LimitObject { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LimitObject.class); + + /* + * The quota/limit value + */ + @JsonProperty(value = "value", required = true) + private int value; + + /* + * The limit object type. + */ + @JsonProperty(value = "limitObjectType") + private LimitType limitObjectType; + + /* + * The quota or usages limit types. + */ + @JsonProperty(value = "limitType") + private QuotaLimitTypes limitType; + + /** + * Get the value property: The quota/limit value. + * + * @return the value value. + */ + public int value() { + return this.value; + } + + /** + * Set the value property: The quota/limit value. + * + * @param value the value value to set. + * @return the LimitObject object itself. + */ + public LimitObject withValue(int value) { + this.value = value; + return this; + } + + /** + * Get the limitObjectType property: The limit object type. + * + * @return the limitObjectType value. + */ + public LimitType limitObjectType() { + return this.limitObjectType; + } + + /** + * Set the limitObjectType property: The limit object type. + * + * @param limitObjectType the limitObjectType value to set. + * @return the LimitObject object itself. + */ + public LimitObject withLimitObjectType(LimitType limitObjectType) { + this.limitObjectType = limitObjectType; + return this; + } + + /** + * Get the limitType property: The quota or usages limit types. + * + * @return the limitType value. + */ + public QuotaLimitTypes limitType() { + return this.limitType; + } + + /** + * Set the limitType property: The quota or usages limit types. + * + * @param limitType the limitType value to set. + * @return the LimitObject object itself. + */ + public LimitObject withLimitType(QuotaLimitTypes limitType) { + this.limitType = limitType; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitType.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitType.java new file mode 100644 index 0000000000000..70e2b646137b4 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitType.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for LimitType. */ +public final class LimitType extends ExpandableStringEnum { + /** Static value LimitValue for LimitType. */ + public static final LimitType LIMIT_VALUE = fromString("LimitValue"); + + /** + * Creates or finds a LimitType from its string representation. + * + * @param name a name to look for. + * @return the corresponding LimitType. + */ + @JsonCreator + public static LimitType fromString(String name) { + return fromString(name, LimitType.class); + } + + /** @return known LimitType values. */ + public static Collection values() { + return values(LimitType.class); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitValue.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitValue.java new file mode 100644 index 0000000000000..f645f2a1f4a73 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/LimitValue.java @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** The resource quota limit. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "limitObjectType") +@JsonTypeName("LimitValue") +@Fluent +public final class LimitValue extends LimitJsonObject { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LimitValue.class); + + /* + * The quota/limit value + */ + @JsonProperty(value = "value", required = true) + private int value; + + /* + * The limit object type. + */ + @JsonProperty(value = "limitObjectType") + private LimitType limitObjectType; + + /* + * The quota or usages limit types. + */ + @JsonProperty(value = "limitType") + private QuotaLimitTypes limitType; + + /** + * Get the value property: The quota/limit value. + * + * @return the value value. + */ + public int value() { + return this.value; + } + + /** + * Set the value property: The quota/limit value. + * + * @param value the value value to set. + * @return the LimitValue object itself. + */ + public LimitValue withValue(int value) { + this.value = value; + return this; + } + + /** + * Get the limitObjectType property: The limit object type. + * + * @return the limitObjectType value. + */ + public LimitType limitObjectType() { + return this.limitObjectType; + } + + /** + * Set the limitObjectType property: The limit object type. + * + * @param limitObjectType the limitObjectType value to set. + * @return the LimitValue object itself. + */ + public LimitValue withLimitObjectType(LimitType limitObjectType) { + this.limitObjectType = limitObjectType; + return this; + } + + /** + * Get the limitType property: The quota or usages limit types. + * + * @return the limitType value. + */ + public QuotaLimitTypes limitType() { + return this.limitType; + } + + /** + * Set the limitType property: The quota or usages limit types. + * + * @param limitType the limitType value to set. + * @return the LimitValue object itself. + */ + public LimitValue withLimitType(QuotaLimitTypes limitType) { + this.limitType = limitType; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/OperationDisplay.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/OperationDisplay.java new file mode 100644 index 0000000000000..074bdfb75b4aa --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/OperationDisplay.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The OperationDisplay model. */ +@Fluent +public final class OperationDisplay { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationDisplay.class); + + /* + * Provider name. + */ + @JsonProperty(value = "provider") + private String provider; + + /* + * Resource name. + */ + @JsonProperty(value = "resource") + private String resource; + + /* + * Operation name. + */ + @JsonProperty(value = "operation") + private String operation; + + /* + * Operation description. + */ + @JsonProperty(value = "description") + private String description; + + /** + * Get the provider property: Provider name. + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider property: Provider name. + * + * @param provider the provider value to set. + * @return the OperationDisplay object itself. + */ + public OperationDisplay withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the resource property: Resource name. + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Set the resource property: Resource name. + * + * @param resource the resource value to set. + * @return the OperationDisplay object itself. + */ + public OperationDisplay withResource(String resource) { + this.resource = resource; + return this; + } + + /** + * Get the operation property: Operation name. + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Set the operation property: Operation name. + * + * @param operation the operation value to set. + * @return the OperationDisplay object itself. + */ + public OperationDisplay withOperation(String operation) { + this.operation = operation; + return this; + } + + /** + * Get the description property: Operation description. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: Operation description. + * + * @param description the description value to set. + * @return the OperationDisplay object itself. + */ + public OperationDisplay withDescription(String description) { + this.description = description; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/OperationList.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/OperationList.java new file mode 100644 index 0000000000000..7a398b8a9907a --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/OperationList.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.models.OperationResponseInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The OperationList model. */ +@Fluent +public final class OperationList { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationList.class); + + /* + * The value property. + */ + @JsonProperty(value = "value") + private List value; + + /* + * URL to get the next page of items. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The value property. + * + * @param value the value value to set. + * @return the OperationList object itself. + */ + public OperationList withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: URL to get the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: URL to get the next page of items. + * + * @param nextLink the nextLink value to set. + * @return the OperationList object itself. + */ + public OperationList withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/OperationResponse.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/OperationResponse.java new file mode 100644 index 0000000000000..ab1891ee80f67 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/OperationResponse.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.resourcemanager.quota.fluent.models.OperationResponseInner; + +/** An immutable client-side representation of OperationResponse. */ +public interface OperationResponse { + /** + * Gets the name property: The name property. + * + * @return the name value. + */ + String name(); + + /** + * Gets the display property: The display property. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The origin property. + * + * @return the origin value. + */ + String origin(); + + /** + * Gets the inner com.azure.resourcemanager.quota.fluent.models.OperationResponseInner object. + * + * @return the inner object. + */ + OperationResponseInner innerModel(); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/Operations.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/Operations.java new file mode 100644 index 0000000000000..04484ba486ce7 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/Operations.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + PagedIterable list(); + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + PagedIterable list(Context context); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaLimitTypes.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaLimitTypes.java new file mode 100644 index 0000000000000..a9d38803d6e17 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaLimitTypes.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for QuotaLimitTypes. */ +public final class QuotaLimitTypes extends ExpandableStringEnum { + /** Static value Independent for QuotaLimitTypes. */ + public static final QuotaLimitTypes INDEPENDENT = fromString("Independent"); + + /** Static value Shared for QuotaLimitTypes. */ + public static final QuotaLimitTypes SHARED = fromString("Shared"); + + /** + * Creates or finds a QuotaLimitTypes from its string representation. + * + * @param name a name to look for. + * @return the corresponding QuotaLimitTypes. + */ + @JsonCreator + public static QuotaLimitTypes fromString(String name) { + return fromString(name, QuotaLimitTypes.class); + } + + /** @return known QuotaLimitTypes values. */ + public static Collection values() { + return values(QuotaLimitTypes.class); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaLimits.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaLimits.java new file mode 100644 index 0000000000000..c16b48338768b --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaLimits.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.models.CurrentQuotaLimitBaseInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Quota limits. */ +@Fluent +public final class QuotaLimits { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QuotaLimits.class); + + /* + * List of quota limits. + */ + @JsonProperty(value = "value") + private List value; + + /* + * The URI used to fetch the next page of quota limits. When there are no + * more pages, this string is null. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: List of quota limits. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of quota limits. + * + * @param value the value value to set. + * @return the QuotaLimits object itself. + */ + public QuotaLimits withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The URI used to fetch the next page of quota limits. When there are no more pages, + * this string is null. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The URI used to fetch the next page of quota limits. When there are no more pages, + * this string is null. + * + * @param nextLink the nextLink value to set. + * @return the QuotaLimits object itself. + */ + public QuotaLimits withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaProperties.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaProperties.java new file mode 100644 index 0000000000000..6c3ea2dae22bd --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaProperties.java @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Quota properties for the specified resource. */ +@Fluent +public final class QuotaProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QuotaProperties.class); + + /* + * Resource quota limit properties. + */ + @JsonProperty(value = "limit") + private LimitJsonObject limit; + + /* + * The quota 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. + */ + @JsonProperty(value = "unit", access = JsonProperty.Access.WRITE_ONLY) + private String unit; + + /* + * Resource name provided by the resource provider. Use this property name + * when requesting quota. + */ + @JsonProperty(value = "name") + private ResourceName name; + + /* + * Resource type name. + */ + @JsonProperty(value = "resourceType") + private String resourceType; + + /* + * The time period over which the quota usage values are summarized. For + * example: + * *P1D (per one day) + * *PT1M (per one minute) + * *PT1S (per one second). + * This parameter is optional because, for some resources like compute, the + * period is irrelevant. + */ + @JsonProperty(value = "quotaPeriod", access = JsonProperty.Access.WRITE_ONLY) + private String quotaPeriod; + + /* + * States if quota can be requested for this resource. + */ + @JsonProperty(value = "isQuotaApplicable", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isQuotaApplicable; + + /* + * Additional properties for the specific resource provider. + */ + @JsonProperty(value = "properties") + private Object properties; + + /** + * Get the limit property: Resource quota limit properties. + * + * @return the limit value. + */ + public LimitJsonObject limit() { + return this.limit; + } + + /** + * Set the limit property: Resource quota limit properties. + * + * @param limit the limit value to set. + * @return the QuotaProperties object itself. + */ + public QuotaProperties withLimit(LimitJsonObject limit) { + this.limit = limit; + return this; + } + + /** + * Get the unit property: The quota 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. + * + * @return the unit value. + */ + public String unit() { + return this.unit; + } + + /** + * Get the name property: Resource name provided by the resource provider. Use this property name when requesting + * quota. + * + * @return the name value. + */ + public ResourceName name() { + return this.name; + } + + /** + * Set the name property: Resource name provided by the resource provider. Use this property name when requesting + * quota. + * + * @param name the name value to set. + * @return the QuotaProperties object itself. + */ + public QuotaProperties withName(ResourceName name) { + this.name = name; + return this; + } + + /** + * Get the resourceType property: Resource type name. + * + * @return the resourceType value. + */ + public String resourceType() { + return this.resourceType; + } + + /** + * Set the resourceType property: Resource type name. + * + * @param resourceType the resourceType value to set. + * @return the QuotaProperties object itself. + */ + public QuotaProperties withResourceType(String resourceType) { + this.resourceType = resourceType; + return this; + } + + /** + * Get the quotaPeriod property: The time period over which the quota usage values are summarized. For example: *P1D + * (per one day) *PT1M (per one minute) *PT1S (per one second). This parameter is optional because, for some + * resources like compute, the period is irrelevant. + * + * @return the quotaPeriod value. + */ + public String quotaPeriod() { + return this.quotaPeriod; + } + + /** + * Get the isQuotaApplicable property: States if quota can be requested for this resource. + * + * @return the isQuotaApplicable value. + */ + public Boolean isQuotaApplicable() { + return this.isQuotaApplicable; + } + + /** + * Get the properties property: Additional properties for the specific resource provider. + * + * @return the properties value. + */ + public Object properties() { + return this.properties; + } + + /** + * Set the properties property: Additional properties for the specific resource provider. + * + * @param properties the properties value to set. + * @return the QuotaProperties object itself. + */ + public QuotaProperties withProperties(Object properties) { + this.properties = properties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (limit() != null) { + limit().validate(); + } + if (name() != null) { + name().validate(); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestDetails.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestDetails.java new file mode 100644 index 0000000000000..53ac6d7c8e257 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestDetails.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.resourcemanager.quota.fluent.models.QuotaRequestDetailsInner; +import java.time.OffsetDateTime; +import java.util.List; + +/** An immutable client-side representation of QuotaRequestDetails. */ +public interface QuotaRequestDetails { + /** + * Gets the id property: Quota request ID. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: Quota request name. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: Resource type. "Microsoft.Quota/quotas". + * + * @return the type value. + */ + String type(); + + /** + * Gets the provisioningState property: The quota request status. + * + * @return the provisioningState value. + */ + QuotaRequestState provisioningState(); + + /** + * Gets the message property: User-friendly status message. + * + * @return the message value. + */ + String message(); + + /** + * Gets the error property: Error details of the quota request. + * + * @return the error value. + */ + ServiceErrorDetail error(); + + /** + * Gets the requestSubmitTime property: The quota request submission time. The date conforms to the following format + * specified by the ISO 8601 standard: yyyy-MM-ddTHH:mm:ssZ. + * + * @return the requestSubmitTime value. + */ + OffsetDateTime requestSubmitTime(); + + /** + * Gets the value property: Quota request details. + * + * @return the value value. + */ + List value(); + + /** + * Gets the inner com.azure.resourcemanager.quota.fluent.models.QuotaRequestDetailsInner object. + * + * @return the inner object. + */ + QuotaRequestDetailsInner innerModel(); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestDetailsList.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestDetailsList.java new file mode 100644 index 0000000000000..1ff93e8cef76b --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestDetailsList.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.models.QuotaRequestDetailsInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Quota request information. */ +@Fluent +public final class QuotaRequestDetailsList { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QuotaRequestDetailsList.class); + + /* + * Quota request details. + */ + @JsonProperty(value = "value") + private List value; + + /* + * The URI for fetching the next page of quota limits. When there are no + * more pages, this string is null. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: Quota request details. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: Quota request details. + * + * @param value the value value to set. + * @return the QuotaRequestDetailsList object itself. + */ + public QuotaRequestDetailsList withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The URI for fetching the next page of quota limits. When there are no more pages, this + * string is null. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The URI for fetching the next page of quota limits. When there are no more pages, this + * string is null. + * + * @param nextLink the nextLink value to set. + * @return the QuotaRequestDetailsList object itself. + */ + public QuotaRequestDetailsList withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestState.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestState.java new file mode 100644 index 0000000000000..32143beccd3d9 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestState.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for QuotaRequestState. */ +public final class QuotaRequestState extends ExpandableStringEnum { + /** Static value Accepted for QuotaRequestState. */ + public static final QuotaRequestState ACCEPTED = fromString("Accepted"); + + /** Static value Invalid for QuotaRequestState. */ + public static final QuotaRequestState INVALID = fromString("Invalid"); + + /** Static value Succeeded for QuotaRequestState. */ + public static final QuotaRequestState SUCCEEDED = fromString("Succeeded"); + + /** Static value Failed for QuotaRequestState. */ + public static final QuotaRequestState FAILED = fromString("Failed"); + + /** Static value InProgress for QuotaRequestState. */ + public static final QuotaRequestState IN_PROGRESS = fromString("InProgress"); + + /** + * Creates or finds a QuotaRequestState from its string representation. + * + * @param name a name to look for. + * @return the corresponding QuotaRequestState. + */ + @JsonCreator + public static QuotaRequestState fromString(String name) { + return fromString(name, QuotaRequestState.class); + } + + /** @return known QuotaRequestState values. */ + public static Collection values() { + return values(QuotaRequestState.class); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestStatus.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestStatus.java new file mode 100644 index 0000000000000..db676473c83ec --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotaRequestStatus.java @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of QuotaRequestStatus. */ +public interface QuotaRequestStatus { + /** + * Get the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. The quota request ID **id** is returned in the response of the PUT operation. + * + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. + */ + QuotaRequestDetails get(String id, String scope); + + /** + * Get the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. The quota request ID **id** is returned in the response of the PUT operation. + * + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota request details and status by quota request ID for the resources of the resource provider at a + * specific location. + */ + Response getWithResponse(String id, String scope, Context context); + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + PagedIterable list(String scope); + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the + * **oData** filter to select quota requests. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param filter | Field | Supported operators |---------------------|------------------------ + *

|requestSubmitTime | ge, le, eq, gt, lt |provisioningState eq {QuotaRequestState} |resourceName eq + * {resourceName}. + * @param top Number of records to return. + * @param skiptoken The **Skiptoken** parameter is used only if a previous operation returned a partial result. If a + * previous response contains a **nextLink** element, its value includes a **skiptoken** parameter that + * specifies a starting point to use for subsequent calls. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return quota request information. + */ + PagedIterable list( + String scope, String filter, Integer top, String skiptoken, Context context); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/Quotas.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/Quotas.java new file mode 100644 index 0000000000000..cbcbcb41a60fd --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/Quotas.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of Quotas. */ +public interface Quotas { + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + CurrentQuotaLimitBase get(String resourceName, String scope); + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + Response getWithResponse(String resourceName, String scope, Context context); + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + PagedIterable list(String scope); + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this GET operation + * can be leveraged to submit requests to update a quota. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current quota limits of all resources for the specified scope. + */ + PagedIterable list(String scope, Context context); + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + CurrentQuotaLimitBase getById(String id); + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new + * quota limit that can be submitted with a PUT request. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the quota limit of a resource. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new CurrentQuotaLimitBase resource. + * + * @param name resource name. + * @return the first stage of the new CurrentQuotaLimitBase definition. + */ + CurrentQuotaLimitBase.DefinitionStages.Blank define(String name); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasGetHeaders.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasGetHeaders.java new file mode 100644 index 0000000000000..ee95a9ffa07cd --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasGetHeaders.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The QuotasGetHeaders model. */ +@Fluent +public final class QuotasGetHeaders { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QuotasGetHeaders.class); + + /* + * The Etag property. + */ + @JsonProperty(value = "Etag") + private String etag; + + /** + * Get the etag property: The Etag property. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Set the etag property: The Etag property. + * + * @param etag the etag value to set. + * @return the QuotasGetHeaders object itself. + */ + public QuotasGetHeaders withEtag(String etag) { + this.etag = etag; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasGetResponse.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasGetResponse.java new file mode 100644 index 0000000000000..d5534923de5ad --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasGetResponse.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.ResponseBase; +import com.azure.resourcemanager.quota.fluent.models.CurrentQuotaLimitBaseInner; + +/** Contains all response data for the get operation. */ +public final class QuotasGetResponse extends ResponseBase { + /** + * Creates an instance of QuotasGetResponse. + * + * @param request the request which resulted in this QuotasGetResponse. + * @param statusCode the status code of the HTTP response. + * @param rawHeaders the raw headers of the HTTP response. + * @param value the deserialized value of the HTTP response. + * @param headers the deserialized headers of the HTTP response. + */ + public QuotasGetResponse( + HttpRequest request, + int statusCode, + HttpHeaders rawHeaders, + CurrentQuotaLimitBaseInner value, + QuotasGetHeaders headers) { + super(request, statusCode, rawHeaders, value, headers); + } + + /** @return the deserialized response body. */ + @Override + public CurrentQuotaLimitBaseInner getValue() { + return super.getValue(); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListHeaders.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListHeaders.java new file mode 100644 index 0000000000000..a73b3373e416e --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListHeaders.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The QuotasListHeaders model. */ +@Fluent +public final class QuotasListHeaders { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QuotasListHeaders.class); + + /* + * The Etag property. + */ + @JsonProperty(value = "Etag") + private String etag; + + /** + * Get the etag property: The Etag property. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Set the etag property: The Etag property. + * + * @param etag the etag value to set. + * @return the QuotasListHeaders object itself. + */ + public QuotasListHeaders withEtag(String etag) { + this.etag = etag; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListNextHeaders.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListNextHeaders.java new file mode 100644 index 0000000000000..018bb1bd9c1ec --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListNextHeaders.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The QuotasListNextHeaders model. */ +@Fluent +public final class QuotasListNextHeaders { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QuotasListNextHeaders.class); + + /* + * The Etag property. + */ + @JsonProperty(value = "Etag") + private String etag; + + /** + * Get the etag property: The Etag property. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Set the etag property: The Etag property. + * + * @param etag the etag value to set. + * @return the QuotasListNextHeaders object itself. + */ + public QuotasListNextHeaders withEtag(String etag) { + this.etag = etag; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListNextResponse.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListNextResponse.java new file mode 100644 index 0000000000000..b8fa7412221cb --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListNextResponse.java @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.ResponseBase; + +/** Contains all response data for the listNext operation. */ +public final class QuotasListNextResponse extends ResponseBase { + /** + * Creates an instance of QuotasListNextResponse. + * + * @param request the request which resulted in this QuotasListNextResponse. + * @param statusCode the status code of the HTTP response. + * @param rawHeaders the raw headers of the HTTP response. + * @param value the deserialized value of the HTTP response. + * @param headers the deserialized headers of the HTTP response. + */ + public QuotasListNextResponse( + HttpRequest request, int statusCode, HttpHeaders rawHeaders, QuotaLimits value, QuotasListNextHeaders headers) { + super(request, statusCode, rawHeaders, value, headers); + } + + /** @return the deserialized response body. */ + @Override + public QuotaLimits getValue() { + return super.getValue(); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListResponse.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListResponse.java new file mode 100644 index 0000000000000..b0437fb255897 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/QuotasListResponse.java @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.ResponseBase; + +/** Contains all response data for the list operation. */ +public final class QuotasListResponse extends ResponseBase { + /** + * Creates an instance of QuotasListResponse. + * + * @param request the request which resulted in this QuotasListResponse. + * @param statusCode the status code of the HTTP response. + * @param rawHeaders the raw headers of the HTTP response. + * @param value the deserialized value of the HTTP response. + * @param headers the deserialized headers of the HTTP response. + */ + public QuotasListResponse( + HttpRequest request, int statusCode, HttpHeaders rawHeaders, QuotaLimits value, QuotasListHeaders headers) { + super(request, statusCode, rawHeaders, value, headers); + } + + /** @return the deserialized response body. */ + @Override + public QuotaLimits getValue() { + return super.getValue(); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/ResourceName.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/ResourceName.java new file mode 100644 index 0000000000000..d3e34eec61459 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/ResourceName.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Name of the resource provided by the resource Provider. When requesting quota, use this property name. */ +@Fluent +public final class ResourceName { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceName.class); + + /* + * Resource name. + */ + @JsonProperty(value = "value") + private String value; + + /* + * Resource display name. + */ + @JsonProperty(value = "localizedValue", access = JsonProperty.Access.WRITE_ONLY) + private String localizedValue; + + /** + * Get the value property: Resource name. + * + * @return the value value. + */ + public String value() { + return this.value; + } + + /** + * Set the value property: Resource name. + * + * @param value the value value to set. + * @return the ResourceName object itself. + */ + public ResourceName withValue(String value) { + this.value = value; + return this; + } + + /** + * Get the localizedValue property: Resource display name. + * + * @return the localizedValue value. + */ + public String localizedValue() { + return this.localizedValue; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/ServiceErrorDetail.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/ServiceErrorDetail.java new file mode 100644 index 0000000000000..e2038ff844b49 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/ServiceErrorDetail.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Error details. */ +@Immutable +public final class ServiceErrorDetail { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ServiceErrorDetail.class); + + /* + * Error code. + */ + @JsonProperty(value = "code", access = JsonProperty.Access.WRITE_ONLY) + private String code; + + /* + * Error message. + */ + @JsonProperty(value = "message", access = JsonProperty.Access.WRITE_ONLY) + private String message; + + /** + * Get the code property: Error code. + * + * @return the code value. + */ + public String code() { + return this.code; + } + + /** + * Get the message property: Error message. + * + * @return the message value. + */ + public String message() { + return this.message; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/SubRequest.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/SubRequest.java new file mode 100644 index 0000000000000..01d50fe11b91d --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/SubRequest.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Request property. */ +@Fluent +public final class SubRequest { + @JsonIgnore private final ClientLogger logger = new ClientLogger(SubRequest.class); + + /* + * Resource name. + */ + @JsonProperty(value = "name") + private ResourceName name; + + /* + * Resource type for which the quota properties were requested. + */ + @JsonProperty(value = "resourceType", access = JsonProperty.Access.WRITE_ONLY) + private String resourceType; + + /* + * Quota limit 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. + */ + @JsonProperty(value = "unit") + private String unit; + + /* + * The quota request status. + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private QuotaRequestState provisioningState; + + /* + * User-friendly status message. + */ + @JsonProperty(value = "message", access = JsonProperty.Access.WRITE_ONLY) + private String message; + + /* + * Quota request ID. + */ + @JsonProperty(value = "subRequestId", access = JsonProperty.Access.WRITE_ONLY) + private String subRequestId; + + /* + * Resource quota limit properties. + */ + @JsonProperty(value = "limit") + private LimitJsonObject limit; + + /** + * Get the name property: Resource name. + * + * @return the name value. + */ + public ResourceName name() { + return this.name; + } + + /** + * Set the name property: Resource name. + * + * @param name the name value to set. + * @return the SubRequest object itself. + */ + public SubRequest withName(ResourceName name) { + this.name = name; + return this; + } + + /** + * Get the resourceType property: Resource type for which the quota properties were requested. + * + * @return the resourceType value. + */ + public String resourceType() { + return this.resourceType; + } + + /** + * Get the unit property: Quota limit 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. + * + * @return the unit value. + */ + public String unit() { + return this.unit; + } + + /** + * Set the unit property: Quota limit 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. + * + * @param unit the unit value to set. + * @return the SubRequest object itself. + */ + public SubRequest withUnit(String unit) { + this.unit = unit; + return this; + } + + /** + * Get the provisioningState property: The quota request status. + * + * @return the provisioningState value. + */ + public QuotaRequestState provisioningState() { + return this.provisioningState; + } + + /** + * Get the message property: User-friendly status message. + * + * @return the message value. + */ + public String message() { + return this.message; + } + + /** + * Get the subRequestId property: Quota request ID. + * + * @return the subRequestId value. + */ + public String subRequestId() { + return this.subRequestId; + } + + /** + * Get the limit property: Resource quota limit properties. + * + * @return the limit value. + */ + public LimitJsonObject limit() { + return this.limit; + } + + /** + * Set the limit property: Resource quota limit properties. + * + * @param limit the limit value to set. + * @return the SubRequest object itself. + */ + public SubRequest withLimit(LimitJsonObject limit) { + this.limit = limit; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() != null) { + name().validate(); + } + if (limit() != null) { + limit().validate(); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/Usages.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/Usages.java new file mode 100644 index 0000000000000..c54a52fb71c66 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/Usages.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of Usages. */ +public interface Usages { + /** + * Get the current usage of a resource. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the current usage of a resource. + */ + CurrentUsagesBase get(String resourceName, String scope); + + /** + * Get the current usage of a resource. + * + * @param resourceName Resource name for a given resource provider. For example: - SKU name for Microsoft.Compute - + * SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the current usage of a resource. + */ + Response getWithResponse(String resourceName, String scope, Context context); + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + PagedIterable list(String scope); + + /** + * Get a list of current usage for all resources for the scope specified. + * + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added after + * `/quotas`, then it's the target Azure resource URI in the GET operation for the specific resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of current usage for all resources for the scope specified. + */ + PagedIterable list(String scope, Context context); +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesGetHeaders.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesGetHeaders.java new file mode 100644 index 0000000000000..b5f5379a66c11 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesGetHeaders.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The UsagesGetHeaders model. */ +@Fluent +public final class UsagesGetHeaders { + @JsonIgnore private final ClientLogger logger = new ClientLogger(UsagesGetHeaders.class); + + /* + * The Etag property. + */ + @JsonProperty(value = "Etag") + private String etag; + + /** + * Get the etag property: The Etag property. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Set the etag property: The Etag property. + * + * @param etag the etag value to set. + * @return the UsagesGetHeaders object itself. + */ + public UsagesGetHeaders withEtag(String etag) { + this.etag = etag; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesGetResponse.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesGetResponse.java new file mode 100644 index 0000000000000..e827afcc47bd2 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesGetResponse.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.ResponseBase; +import com.azure.resourcemanager.quota.fluent.models.CurrentUsagesBaseInner; + +/** Contains all response data for the get operation. */ +public final class UsagesGetResponse extends ResponseBase { + /** + * Creates an instance of UsagesGetResponse. + * + * @param request the request which resulted in this UsagesGetResponse. + * @param statusCode the status code of the HTTP response. + * @param rawHeaders the raw headers of the HTTP response. + * @param value the deserialized value of the HTTP response. + * @param headers the deserialized headers of the HTTP response. + */ + public UsagesGetResponse( + HttpRequest request, + int statusCode, + HttpHeaders rawHeaders, + CurrentUsagesBaseInner value, + UsagesGetHeaders headers) { + super(request, statusCode, rawHeaders, value, headers); + } + + /** @return the deserialized response body. */ + @Override + public CurrentUsagesBaseInner getValue() { + return super.getValue(); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesLimits.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesLimits.java new file mode 100644 index 0000000000000..31fe3fb4dd3c2 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesLimits.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.quota.fluent.models.CurrentUsagesBaseInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Quota limits. */ +@Fluent +public final class UsagesLimits { + @JsonIgnore private final ClientLogger logger = new ClientLogger(UsagesLimits.class); + + /* + * List of quota limits. + */ + @JsonProperty(value = "value") + private List value; + + /* + * The URI used to fetch the next page of quota limits. When there are no + * more pages, this is null. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: List of quota limits. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of quota limits. + * + * @param value the value value to set. + * @return the UsagesLimits object itself. + */ + public UsagesLimits withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The URI used to fetch the next page of quota limits. When there are no more pages, + * this is null. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The URI used to fetch the next page of quota limits. When there are no more pages, + * this is null. + * + * @param nextLink the nextLink value to set. + * @return the UsagesLimits object itself. + */ + public UsagesLimits withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListHeaders.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListHeaders.java new file mode 100644 index 0000000000000..d8050885e947f --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListHeaders.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The UsagesListHeaders model. */ +@Fluent +public final class UsagesListHeaders { + @JsonIgnore private final ClientLogger logger = new ClientLogger(UsagesListHeaders.class); + + /* + * The Etag property. + */ + @JsonProperty(value = "Etag") + private String etag; + + /** + * Get the etag property: The Etag property. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Set the etag property: The Etag property. + * + * @param etag the etag value to set. + * @return the UsagesListHeaders object itself. + */ + public UsagesListHeaders withEtag(String etag) { + this.etag = etag; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListNextHeaders.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListNextHeaders.java new file mode 100644 index 0000000000000..9516de7ad7257 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListNextHeaders.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The UsagesListNextHeaders model. */ +@Fluent +public final class UsagesListNextHeaders { + @JsonIgnore private final ClientLogger logger = new ClientLogger(UsagesListNextHeaders.class); + + /* + * The Etag property. + */ + @JsonProperty(value = "Etag") + private String etag; + + /** + * Get the etag property: The Etag property. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Set the etag property: The Etag property. + * + * @param etag the etag value to set. + * @return the UsagesListNextHeaders object itself. + */ + public UsagesListNextHeaders withEtag(String etag) { + this.etag = etag; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListNextResponse.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListNextResponse.java new file mode 100644 index 0000000000000..7f7ef3b7cff1c --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListNextResponse.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.ResponseBase; + +/** Contains all response data for the listNext operation. */ +public final class UsagesListNextResponse extends ResponseBase { + /** + * Creates an instance of UsagesListNextResponse. + * + * @param request the request which resulted in this UsagesListNextResponse. + * @param statusCode the status code of the HTTP response. + * @param rawHeaders the raw headers of the HTTP response. + * @param value the deserialized value of the HTTP response. + * @param headers the deserialized headers of the HTTP response. + */ + public UsagesListNextResponse( + HttpRequest request, + int statusCode, + HttpHeaders rawHeaders, + UsagesLimits value, + UsagesListNextHeaders headers) { + super(request, statusCode, rawHeaders, value, headers); + } + + /** @return the deserialized response body. */ + @Override + public UsagesLimits getValue() { + return super.getValue(); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListResponse.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListResponse.java new file mode 100644 index 0000000000000..65c6d29e22ff5 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesListResponse.java @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.ResponseBase; + +/** Contains all response data for the list operation. */ +public final class UsagesListResponse extends ResponseBase { + /** + * Creates an instance of UsagesListResponse. + * + * @param request the request which resulted in this UsagesListResponse. + * @param statusCode the status code of the HTTP response. + * @param rawHeaders the raw headers of the HTTP response. + * @param value the deserialized value of the HTTP response. + * @param headers the deserialized headers of the HTTP response. + */ + public UsagesListResponse( + HttpRequest request, int statusCode, HttpHeaders rawHeaders, UsagesLimits value, UsagesListHeaders headers) { + super(request, statusCode, rawHeaders, value, headers); + } + + /** @return the deserialized response body. */ + @Override + public UsagesLimits getValue() { + return super.getValue(); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesObject.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesObject.java new file mode 100644 index 0000000000000..083ba5f69eb57 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesObject.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The resource usages value. */ +@Fluent +public final class UsagesObject { + @JsonIgnore private final ClientLogger logger = new ClientLogger(UsagesObject.class); + + /* + * The usages value. + */ + @JsonProperty(value = "value", required = true) + private int value; + + /* + * The quota or usages limit types. + */ + @JsonProperty(value = "usagesType") + private UsagesTypes usagesType; + + /** + * Get the value property: The usages value. + * + * @return the value value. + */ + public int value() { + return this.value; + } + + /** + * Set the value property: The usages value. + * + * @param value the value value to set. + * @return the UsagesObject object itself. + */ + public UsagesObject withValue(int value) { + this.value = value; + return this; + } + + /** + * Get the usagesType property: The quota or usages limit types. + * + * @return the usagesType value. + */ + public UsagesTypes usagesType() { + return this.usagesType; + } + + /** + * Set the usagesType property: The quota or usages limit types. + * + * @param usagesType the usagesType value to set. + * @return the UsagesObject object itself. + */ + public UsagesObject withUsagesType(UsagesTypes usagesType) { + this.usagesType = usagesType; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesProperties.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesProperties.java new file mode 100644 index 0000000000000..bbc087af5139d --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesProperties.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Usage properties for the specified resource. */ +@Fluent +public final class UsagesProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(UsagesProperties.class); + + /* + * The quota limit properties for this resource. + */ + @JsonProperty(value = "usages") + private UsagesObject usages; + + /* + * The units for the quota usage, 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. + */ + @JsonProperty(value = "unit", access = JsonProperty.Access.WRITE_ONLY) + private String unit; + + /* + * Resource name provided by the resource provider. Use this property name + * when requesting quota. + */ + @JsonProperty(value = "name") + private ResourceName name; + + /* + * The name of the resource type. + */ + @JsonProperty(value = "resourceType") + private String resourceType; + + /* + * The time period for the summary of the quota usage values. For example: + * *P1D (per one day) + * *PT1M (per one minute) + * *PT1S (per one second). + * This parameter is optional because it is not relevant for all resources + * such as compute. + */ + @JsonProperty(value = "quotaPeriod", access = JsonProperty.Access.WRITE_ONLY) + private String quotaPeriod; + + /* + * States if quota can be requested for this resource. + */ + @JsonProperty(value = "isQuotaApplicable", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isQuotaApplicable; + + /* + * Additional properties for the specific resource provider. + */ + @JsonProperty(value = "properties") + private Object properties; + + /** + * Get the usages property: The quota limit properties for this resource. + * + * @return the usages value. + */ + public UsagesObject usages() { + return this.usages; + } + + /** + * Set the usages property: The quota limit properties for this resource. + * + * @param usages the usages value to set. + * @return the UsagesProperties object itself. + */ + public UsagesProperties withUsages(UsagesObject usages) { + this.usages = usages; + return this; + } + + /** + * Get the unit property: The units for the quota usage, 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. + * + * @return the unit value. + */ + public String unit() { + return this.unit; + } + + /** + * Get the name property: Resource name provided by the resource provider. Use this property name when requesting + * quota. + * + * @return the name value. + */ + public ResourceName name() { + return this.name; + } + + /** + * Set the name property: Resource name provided by the resource provider. Use this property name when requesting + * quota. + * + * @param name the name value to set. + * @return the UsagesProperties object itself. + */ + public UsagesProperties withName(ResourceName name) { + this.name = name; + return this; + } + + /** + * Get the resourceType property: The name of the resource type. + * + * @return the resourceType value. + */ + public String resourceType() { + return this.resourceType; + } + + /** + * Set the resourceType property: The name of the resource type. + * + * @param resourceType the resourceType value to set. + * @return the UsagesProperties object itself. + */ + public UsagesProperties withResourceType(String resourceType) { + this.resourceType = resourceType; + return this; + } + + /** + * Get the quotaPeriod property: The time period for the summary of the quota usage values. For example: *P1D (per + * one day) *PT1M (per one minute) *PT1S (per one second). This parameter is optional because it is not relevant for + * all resources such as compute. + * + * @return the quotaPeriod value. + */ + public String quotaPeriod() { + return this.quotaPeriod; + } + + /** + * Get the isQuotaApplicable property: States if quota can be requested for this resource. + * + * @return the isQuotaApplicable value. + */ + public Boolean isQuotaApplicable() { + return this.isQuotaApplicable; + } + + /** + * Get the properties property: Additional properties for the specific resource provider. + * + * @return the properties value. + */ + public Object properties() { + return this.properties; + } + + /** + * Set the properties property: Additional properties for the specific resource provider. + * + * @param properties the properties value to set. + * @return the UsagesProperties object itself. + */ + public UsagesProperties withProperties(Object properties) { + this.properties = properties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (usages() != null) { + usages().validate(); + } + if (name() != null) { + name().validate(); + } + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesTypes.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesTypes.java new file mode 100644 index 0000000000000..0626f69c2b516 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/UsagesTypes.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.quota.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for UsagesTypes. */ +public final class UsagesTypes extends ExpandableStringEnum { + /** Static value Individual for UsagesTypes. */ + public static final UsagesTypes INDIVIDUAL = fromString("Individual"); + + /** Static value Combined for UsagesTypes. */ + public static final UsagesTypes COMBINED = fromString("Combined"); + + /** + * Creates or finds a UsagesTypes from its string representation. + * + * @param name a name to look for. + * @return the corresponding UsagesTypes. + */ + @JsonCreator + public static UsagesTypes fromString(String name) { + return fromString(name, UsagesTypes.class); + } + + /** @return known UsagesTypes values. */ + public static Collection values() { + return values(UsagesTypes.class); + } +} diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/package-info.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/package-info.java new file mode 100644 index 0000000000000..2bc29ac9d800f --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/models/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the data models for AzureQuotaExtensionApi. Microsoft Azure Quota Resource Provider. */ +package com.azure.resourcemanager.quota.models; diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/package-info.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/package-info.java new file mode 100644 index 0000000000000..8fa6b5e13b6cf --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/com/azure/resourcemanager/quota/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the classes for AzureQuotaExtensionApi. Microsoft Azure Quota Resource Provider. */ +package com.azure.resourcemanager.quota; diff --git a/sdk/quota/azure-resourcemanager-quota/src/main/java/module-info.java b/sdk/quota/azure-resourcemanager-quota/src/main/java/module-info.java new file mode 100644 index 0000000000000..9a6fbebe2e286 --- /dev/null +++ b/sdk/quota/azure-resourcemanager-quota/src/main/java/module-info.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.resourcemanager.quota { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.quota; + exports com.azure.resourcemanager.quota.fluent; + exports com.azure.resourcemanager.quota.fluent.models; + exports com.azure.resourcemanager.quota.models; + + opens com.azure.resourcemanager.quota.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.quota.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/quota/ci.yml b/sdk/quota/ci.yml new file mode 100644 index 0000000000000..93cb81bba2ed1 --- /dev/null +++ b/sdk/quota/ci.yml @@ -0,0 +1,39 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/quota/ci.yml + - sdk/quota/azure-resourcemanager-quota/ + exclude: + - sdk/quota/pom.xml + - sdk/quota/azure-resourcemanager-quota/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/quota/ci.yml + - sdk/quota/azure-resourcemanager-quota/ + exclude: + - sdk/quota/pom.xml + - sdk/quota/azure-resourcemanager-quota/pom.xml + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: quota + Artifacts: + - name: azure-resourcemanager-quota + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerquota diff --git a/sdk/quota/pom.xml b/sdk/quota/pom.xml new file mode 100644 index 0000000000000..4c9a78ee387ca --- /dev/null +++ b/sdk/quota/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + com.azure + azure-quota-service + pom + 1.0.0 + + + + coverage + + + + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + report-aggregate + verify + + report-aggregate + + + ${project.reporting.outputDirectory}/test-coverage + + + + + + + + + default + + true + + + azure-resourcemanager-quota + + + +