diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 96ccc01599f7..2224cb896b26 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -330,6 +330,7 @@ com.azure.resourcemanager:azure-resourcemanager-desktopvirtualization;1.0.0-beta com.azure.resourcemanager:azure-resourcemanager-loadtestservice;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-automanage;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-edgeorder;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-softwareplan;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.0.0 # Unreleased dependencies: Copy the entry from above, prepend "unreleased_" and remove the current diff --git a/pom.xml b/pom.xml index acd793f3d360..d354c9c72fb9 100644 --- a/pom.xml +++ b/pom.xml @@ -826,6 +826,7 @@ sdk/servicebus sdk/servicefabric sdk/signalr + sdk/softwareplan sdk/spring sdk/sqlvirtualmachine sdk/storage diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/CHANGELOG.md b/sdk/softwareplan/azure-resourcemanager-softwareplan/CHANGELOG.md new file mode 100644 index 000000000000..fc5ff799112a --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2021-12-22) + +- Azure Resource Manager SoftwarePlan client library for Java. This package contains Microsoft Azure SDK for SoftwarePlan Management SDK. Azure software plans let users create and manage licenses for various software used in Azure. Package tag package-2019-12-01. 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/softwareplan/azure-resourcemanager-softwareplan/README.md b/sdk/softwareplan/azure-resourcemanager-softwareplan/README.md new file mode 100644 index 000000000000..31fb9b0d6cd4 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager SoftwarePlan client library for Java + +Azure Resource Manager SoftwarePlan client library for Java. + +This package contains Microsoft Azure SDK for SoftwarePlan Management SDK. Azure software plans let users create and manage licenses for various software used in Azure. Package tag package-2019-12-01. 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-softwareplan;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-softwareplan + 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(); +SoftwarePlanManager manager = SoftwarePlanManager + .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 + +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/softwareplan/azure-resourcemanager-softwareplan/SAMPLE.md) + + +## 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/softwareplan/azure-resourcemanager-softwareplan/SAMPLE.md b/sdk/softwareplan/azure-resourcemanager-softwareplan/SAMPLE.md new file mode 100644 index 000000000000..fae18d6c643b --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/SAMPLE.md @@ -0,0 +1,231 @@ +# Code snippets and samples + + +## HybridUseBenefit + +- [Create](#hybridusebenefit_create) +- [Delete](#hybridusebenefit_delete) +- [Get](#hybridusebenefit_get) +- [List](#hybridusebenefit_list) +- [Update](#hybridusebenefit_update) + +## HybridUseBenefitRevision + +- [List](#hybridusebenefitrevision_list) + +## Operations + +- [List](#operations_list) + +## SoftwarePlan + +- [Register](#softwareplan_register) +### HybridUseBenefit_Create + +```java +import com.azure.resourcemanager.softwareplan.models.Sku; + +/** Samples for HybridUseBenefit Create. */ +public final class HybridUseBenefitCreateSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/PutHybridUseBenefit.json + */ + /** + * Sample code: HybridUseBenefit. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefit(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefits() + .define("94f46eda-45f8-493a-8425-251921463a89") + .withExistingScope( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}") + .withSku(new Sku().withName("SQL_Server_Perpetual")) + .create(); + } +} +``` + +### HybridUseBenefit_Delete + +```java +import com.azure.core.util.Context; + +/** Samples for HybridUseBenefit Delete. */ +public final class HybridUseBenefitDeleteSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/DeleteHybridUseBenefit.json + */ + /** + * Sample code: HybridUseBenefit. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefit(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefits() + .deleteWithResponse( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "94f46eda-45f8-493a-8425-251921463a89", + Context.NONE); + } +} +``` + +### HybridUseBenefit_Get + +```java +import com.azure.core.util.Context; + +/** Samples for HybridUseBenefit Get. */ +public final class HybridUseBenefitGetSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/GetSingleHybridUseBenefit.json + */ + /** + * Sample code: HybridUseBenefit. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefit(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefits() + .getWithResponse( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "94f46eda-45f8-493a-8425-251921463a89", + Context.NONE); + } +} +``` + +### HybridUseBenefit_List + +```java +import com.azure.core.util.Context; + +/** Samples for HybridUseBenefit List. */ +public final class HybridUseBenefitListSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/GetAllHybridUseBenefits.json + */ + /** + * Sample code: HybridUseBenefitListResult. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefitListResult(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefits() + .list( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "SQL_Server_EE_AHB", + Context.NONE); + } +} +``` + +### HybridUseBenefit_Update + +```java +import com.azure.core.util.Context; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefitModel; +import com.azure.resourcemanager.softwareplan.models.Sku; + +/** Samples for HybridUseBenefit Update. */ +public final class HybridUseBenefitUpdateSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/PatchHybridUseBenefit.json + */ + /** + * Sample code: HybridUseBenefit. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefit(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + HybridUseBenefitModel resource = + manager + .hybridUseBenefits() + .getWithResponse( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "94f46eda-45f8-493a-8425-251921463a89", + Context.NONE) + .getValue(); + resource.update().withSku(new Sku().withName("SQLBYOLStandardForADH")).apply(); + } +} +``` + +### HybridUseBenefitRevision_List + +```java +import com.azure.core.util.Context; + +/** Samples for HybridUseBenefitRevision List. */ +public final class HybridUseBenefitRevisionListSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/GetHybridUseBenefitRevisions.json + */ + /** + * Sample code: HybridUseBenefitRevisionsResponse. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefitRevisionsResponse( + com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefitRevisions() + .list( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "94f46eda-45f8-493a-8425-251921463a89", + Context.NONE); + } +} +``` + +### Operations_List + +```java +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/GetOperations.json + */ + /** + * Sample code: GetOperations. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void getOperations(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .operations() + .list( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + Context.NONE); + } +} +``` + +### SoftwarePlan_Register + +```java +import com.azure.core.util.Context; + +/** Samples for SoftwarePlan Register. */ +public final class SoftwarePlanRegisterSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/RegisterSubscription.json + */ + /** + * Sample code: HybridUseBenefitListResult. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefitListResult(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager.softwarePlans().registerWithResponse(Context.NONE); + } +} +``` + diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/pom.xml b/sdk/softwareplan/azure-resourcemanager-softwareplan/pom.xml new file mode 100644 index 000000000000..90695e2accca --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-softwareplan + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for SoftwarePlan Management + This package contains Microsoft Azure SDK for SoftwarePlan Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure software plans let users create and manage licenses for various software used in Azure. Package tag package-2019-12-01. + 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 + true + false + + + + + + com.azure + azure-core + 1.23.1 + + + com.azure + azure-core-management + 1.4.4 + + + + + + org.revapi + revapi-maven-plugin + 0.11.2 + + + + + java.method.addedToInterface + + + true + .* + com\.azure\.resourcemanager(\.[^.]+)+\.fluent(\.[^.]+)* + + + + + + + + diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/SoftwarePlanManager.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/SoftwarePlanManager.java new file mode 100644 index 000000000000..25ae3b53dec9 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/SoftwarePlanManager.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.softwareplan; + +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.HttpPipelinePosition; +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.softwareplan.fluent.SoftwarePlanRP; +import com.azure.resourcemanager.softwareplan.implementation.HybridUseBenefitRevisionsImpl; +import com.azure.resourcemanager.softwareplan.implementation.HybridUseBenefitsImpl; +import com.azure.resourcemanager.softwareplan.implementation.OperationsImpl; +import com.azure.resourcemanager.softwareplan.implementation.SoftwarePlanRPBuilder; +import com.azure.resourcemanager.softwareplan.implementation.SoftwarePlansImpl; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefitRevisions; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefits; +import com.azure.resourcemanager.softwareplan.models.Operations; +import com.azure.resourcemanager.softwareplan.models.SoftwarePlans; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to SoftwarePlanManager. Azure software plans let users create and manage licenses for various software + * used in Azure. + */ +public final class SoftwarePlanManager { + private SoftwarePlans softwarePlans; + + private HybridUseBenefits hybridUseBenefits; + + private HybridUseBenefitRevisions hybridUseBenefitRevisions; + + private Operations operations; + + private final SoftwarePlanRP clientObject; + + private SoftwarePlanManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new SoftwarePlanRPBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of SoftwarePlan service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the SoftwarePlan service API instance. + */ + public static SoftwarePlanManager 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 SoftwarePlanManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new SoftwarePlanManager.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 SoftwarePlan service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the SoftwarePlan service API instance. + */ + public SoftwarePlanManager 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.softwareplan") + .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()); + policies + .addAll( + this + .policies + .stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies + .addAll( + this + .policies + .stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new SoftwarePlanManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of SoftwarePlans. */ + public SoftwarePlans softwarePlans() { + if (this.softwarePlans == null) { + this.softwarePlans = new SoftwarePlansImpl(clientObject.getSoftwarePlans(), this); + } + return softwarePlans; + } + + /** @return Resource collection API of HybridUseBenefits. */ + public HybridUseBenefits hybridUseBenefits() { + if (this.hybridUseBenefits == null) { + this.hybridUseBenefits = new HybridUseBenefitsImpl(clientObject.getHybridUseBenefits(), this); + } + return hybridUseBenefits; + } + + /** @return Resource collection API of HybridUseBenefitRevisions. */ + public HybridUseBenefitRevisions hybridUseBenefitRevisions() { + if (this.hybridUseBenefitRevisions == null) { + this.hybridUseBenefitRevisions = + new HybridUseBenefitRevisionsImpl(clientObject.getHybridUseBenefitRevisions(), this); + } + return hybridUseBenefitRevisions; + } + + /** @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 SoftwarePlanRP providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + */ + public SoftwarePlanRP serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/HybridUseBenefitRevisionsClient.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/HybridUseBenefitRevisionsClient.java new file mode 100644 index 000000000000..a4fd42066ed2 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/HybridUseBenefitRevisionsClient.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.softwareplan.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.softwareplan.fluent.models.HybridUseBenefitModelInner; + +/** An instance of this class provides access to all the operations defined in HybridUseBenefitRevisionsClient. */ +public interface HybridUseBenefitRevisionsClient { + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope, String planId); + + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope, String planId, Context context); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/HybridUseBenefitsClient.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/HybridUseBenefitsClient.java new file mode 100644 index 000000000000..594dfb56e7e7 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/HybridUseBenefitsClient.java @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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.softwareplan.fluent.models.HybridUseBenefitModelInner; + +/** An instance of this class provides access to all the operations defined in HybridUseBenefitsClient. */ +public interface HybridUseBenefitsClient { + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 all hybrid use benefits associated with an ARM resource. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope); + + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param filter Supports applying filter on the type of SKU. + * @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 all hybrid use benefits associated with an ARM resource. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope, String filter, Context context); + + /** + * Create a new hybrid use benefit under a given scope. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + HybridUseBenefitModelInner create(String scope, String planId, HybridUseBenefitModelInner body); + + /** + * Create a new hybrid use benefit under a given scope. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createWithResponse( + String scope, String planId, HybridUseBenefitModelInner body, Context context); + + /** + * Updates an existing hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + HybridUseBenefitModelInner update(String scope, String planId, HybridUseBenefitModelInner body); + + /** + * Updates an existing hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String scope, String planId, HybridUseBenefitModelInner body, Context context); + + /** + * Gets a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 given plan ID. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + HybridUseBenefitModelInner get(String scope, String planId); + + /** + * Gets a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 given plan ID. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String scope, String planId, Context context); + + /** + * Deletes a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String scope, String planId); + + /** + * Deletes a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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.SINGLE) + Response deleteWithResponse(String scope, String planId, Context context); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/OperationsClient.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/OperationsClient.java new file mode 100644 index 000000000000..2f47a1226ce3 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/OperationsClient.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.softwareplan.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.softwareplan.fluent.models.OperationResponseInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * List all the operations. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope); + + /** + * List all the operations. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String scope, Context context); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/SoftwarePlanRP.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/SoftwarePlanRP.java new file mode 100644 index 000000000000..9ebc5588bd1f --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/SoftwarePlanRP.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.softwareplan.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for SoftwarePlanRP class. */ +public interface SoftwarePlanRP { + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * 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 SoftwarePlansClient object to access its operations. + * + * @return the SoftwarePlansClient object. + */ + SoftwarePlansClient getSoftwarePlans(); + + /** + * Gets the HybridUseBenefitsClient object to access its operations. + * + * @return the HybridUseBenefitsClient object. + */ + HybridUseBenefitsClient getHybridUseBenefits(); + + /** + * Gets the HybridUseBenefitRevisionsClient object to access its operations. + * + * @return the HybridUseBenefitRevisionsClient object. + */ + HybridUseBenefitRevisionsClient getHybridUseBenefitRevisions(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/SoftwarePlansClient.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/SoftwarePlansClient.java new file mode 100644 index 000000000000..9ebf699207e6 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/SoftwarePlansClient.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.softwareplan.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** An instance of this class provides access to all the operations defined in SoftwarePlansClient. */ +public interface SoftwarePlansClient { + /** + * Register to Microsoft.SoftwarePlan 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void register(); + + /** + * Register to Microsoft.SoftwarePlan 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.SINGLE) + Response registerWithResponse(Context context); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/HybridUseBenefitModelInner.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/HybridUseBenefitModelInner.java new file mode 100644 index 000000000000..136147edf578 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/HybridUseBenefitModelInner.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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.softwareplan.models.ProvisioningState; +import com.azure.resourcemanager.softwareplan.models.Sku; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** Response on GET of a hybrid use benefit. */ +@Fluent +public final class HybridUseBenefitModelInner extends ProxyResource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(HybridUseBenefitModelInner.class); + + /* + * Hybrid use benefit SKU + */ + @JsonProperty(value = "sku", required = true) + private Sku sku; + + /* + * Indicates the revision of the hybrid use benefit + */ + @JsonProperty(value = "etag", access = JsonProperty.Access.WRITE_ONLY) + private Integer etag; + + /* + * Property bag for a hybrid use benefit response + */ + @JsonProperty(value = "properties") + private HybridUseBenefitProperties innerProperties; + + /** + * Get the sku property: Hybrid use benefit SKU. + * + * @return the sku value. + */ + public Sku sku() { + return this.sku; + } + + /** + * Set the sku property: Hybrid use benefit SKU. + * + * @param sku the sku value to set. + * @return the HybridUseBenefitModelInner object itself. + */ + public HybridUseBenefitModelInner withSku(Sku sku) { + this.sku = sku; + return this; + } + + /** + * Get the etag property: Indicates the revision of the hybrid use benefit. + * + * @return the etag value. + */ + public Integer etag() { + return this.etag; + } + + /** + * Get the innerProperties property: Property bag for a hybrid use benefit response. + * + * @return the innerProperties value. + */ + private HybridUseBenefitProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the provisioningState property: Provisioning state. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Get the createdDate property: Created date. + * + * @return the createdDate value. + */ + public OffsetDateTime createdDate() { + return this.innerProperties() == null ? null : this.innerProperties().createdDate(); + } + + /** + * Get the lastUpdatedDate property: Last updated date. + * + * @return the lastUpdatedDate value. + */ + public OffsetDateTime lastUpdatedDate() { + return this.innerProperties() == null ? null : this.innerProperties().lastUpdatedDate(); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (sku() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property sku in model HybridUseBenefitModelInner")); + } else { + sku().validate(); + } + if (innerProperties() != null) { + innerProperties().validate(); + } + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/HybridUseBenefitProperties.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/HybridUseBenefitProperties.java new file mode 100644 index 000000000000..01c1e531e785 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/HybridUseBenefitProperties.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.softwareplan.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.softwareplan.models.ProvisioningState; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** Hybrid use benefit properties. */ +@Immutable +public final class HybridUseBenefitProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(HybridUseBenefitProperties.class); + + /* + * Provisioning state + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private ProvisioningState provisioningState; + + /* + * Created date + */ + @JsonProperty(value = "createdDate", access = JsonProperty.Access.WRITE_ONLY) + private OffsetDateTime createdDate; + + /* + * Last updated date + */ + @JsonProperty(value = "lastUpdatedDate", access = JsonProperty.Access.WRITE_ONLY) + private OffsetDateTime lastUpdatedDate; + + /** + * Get the provisioningState property: Provisioning state. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the createdDate property: Created date. + * + * @return the createdDate value. + */ + public OffsetDateTime createdDate() { + return this.createdDate; + } + + /** + * Get the lastUpdatedDate property: Last updated date. + * + * @return the lastUpdatedDate value. + */ + public OffsetDateTime lastUpdatedDate() { + return this.lastUpdatedDate; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/OperationResponseInner.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/OperationResponseInner.java new file mode 100644 index 000000000000..474ce58d000d --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/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.softwareplan.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.softwareplan.models.OperationDisplay; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Operation response. */ +@Fluent +public final class OperationResponseInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationResponseInner.class); + + /* + * Name of the operation + */ + @JsonProperty(value = "name") + private String name; + + /* + * Display properties for the operation + */ + @JsonProperty(value = "display") + private OperationDisplay display; + + /* + * Origin of the response + */ + @JsonProperty(value = "origin") + private String origin; + + /** + * Get the name property: Name of the operation. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Name of the operation. + * + * @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: Display properties for the operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the display property: Display properties for the operation. + * + * @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: Origin of the response. + * + * @return the origin value. + */ + public String origin() { + return this.origin; + } + + /** + * Set the origin property: Origin of the response. + * + * @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/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/package-info.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/package-info.java new file mode 100644 index 000000000000..49762d64dd9c --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// 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 SoftwarePlanRP. Azure software plans let users create and manage + * licenses for various software used in Azure. + */ +package com.azure.resourcemanager.softwareplan.fluent.models; diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/package-info.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/package-info.java new file mode 100644 index 000000000000..b3e06a4eec29 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/fluent/package-info.java @@ -0,0 +1,9 @@ +// 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 SoftwarePlanRP. Azure software plans let users create and manage licenses + * for various software used in Azure. + */ +package com.azure.resourcemanager.softwareplan.fluent; diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitModelImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitModelImpl.java new file mode 100644 index 000000000000..d3426c73066e --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitModelImpl.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.softwareplan.implementation; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.softwareplan.fluent.models.HybridUseBenefitModelInner; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefitModel; +import com.azure.resourcemanager.softwareplan.models.ProvisioningState; +import com.azure.resourcemanager.softwareplan.models.Sku; +import java.time.OffsetDateTime; + +public final class HybridUseBenefitModelImpl + implements HybridUseBenefitModel, HybridUseBenefitModel.Definition, HybridUseBenefitModel.Update { + private HybridUseBenefitModelInner innerObject; + + private final com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public Sku sku() { + return this.innerModel().sku(); + } + + public Integer etag() { + return this.innerModel().etag(); + } + + public ProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public OffsetDateTime createdDate() { + return this.innerModel().createdDate(); + } + + public OffsetDateTime lastUpdatedDate() { + return this.innerModel().lastUpdatedDate(); + } + + public HybridUseBenefitModelInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager() { + return this.serviceManager; + } + + private String scope; + + private String planId; + + public HybridUseBenefitModelImpl withExistingScope(String scope) { + this.scope = scope; + return this; + } + + public HybridUseBenefitModel create() { + this.innerObject = + serviceManager + .serviceClient() + .getHybridUseBenefits() + .createWithResponse(scope, planId, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public HybridUseBenefitModel create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getHybridUseBenefits() + .createWithResponse(scope, planId, this.innerModel(), context) + .getValue(); + return this; + } + + HybridUseBenefitModelImpl(String name, com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager) { + this.innerObject = new HybridUseBenefitModelInner(); + this.serviceManager = serviceManager; + this.planId = name; + } + + public HybridUseBenefitModelImpl update() { + return this; + } + + public HybridUseBenefitModel apply() { + this.innerObject = + serviceManager + .serviceClient() + .getHybridUseBenefits() + .updateWithResponse(scope, planId, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public HybridUseBenefitModel apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getHybridUseBenefits() + .updateWithResponse(scope, planId, this.innerModel(), context) + .getValue(); + return this; + } + + HybridUseBenefitModelImpl( + HybridUseBenefitModelInner innerObject, + com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.scope = + Utils + .getValueFromIdByParameterName( + innerObject.id(), "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "scope"); + this.planId = + Utils + .getValueFromIdByParameterName( + innerObject.id(), "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "planId"); + } + + public HybridUseBenefitModel refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getHybridUseBenefits() + .getWithResponse(scope, planId, Context.NONE) + .getValue(); + return this; + } + + public HybridUseBenefitModel refresh(Context context) { + this.innerObject = + serviceManager.serviceClient().getHybridUseBenefits().getWithResponse(scope, planId, context).getValue(); + return this; + } + + public HybridUseBenefitModelImpl withSku(Sku sku) { + this.innerModel().withSku(sku); + return this; + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitRevisionsClientImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitRevisionsClientImpl.java new file mode 100644 index 000000000000..75457d98aaef --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitRevisionsClientImpl.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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.softwareplan.fluent.HybridUseBenefitRevisionsClient; +import com.azure.resourcemanager.softwareplan.fluent.models.HybridUseBenefitModelInner; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefitListResult; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in HybridUseBenefitRevisionsClient. */ +public final class HybridUseBenefitRevisionsClientImpl implements HybridUseBenefitRevisionsClient { + private final ClientLogger logger = new ClientLogger(HybridUseBenefitRevisionsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final HybridUseBenefitRevisionsService service; + + /** The service client containing this operation class. */ + private final SoftwarePlanRPImpl client; + + /** + * Initializes an instance of HybridUseBenefitRevisionsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + HybridUseBenefitRevisionsClientImpl(SoftwarePlanRPImpl client) { + this.service = + RestProxy + .create( + HybridUseBenefitRevisionsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SoftwarePlanRPHybridUseBenefitRevisions to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "SoftwarePlanRPHybrid") + private interface HybridUseBenefitRevisionsService { + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}/revisions") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @PathParam("scope") String scope, + @PathParam("planId") String planId, + @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); + } + + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String scope, String planId) { + 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .list(this.client.getEndpoint(), scope, planId, 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())); + } + + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync( + String scope, String planId, 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), scope, planId, this.client.getApiVersion(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope, String planId) { + return new PagedFlux<>(() -> listSinglePageAsync(scope, planId), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope, String planId, Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(scope, planId, context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope, String planId) { + return new PagedIterable<>(listAsync(scope, planId)); + } + + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope, String planId, Context context) { + return new PagedIterable<>(listAsync(scope, planId, 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 list of hybrid use benefits. + */ + @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 list of hybrid use benefits. + */ + @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/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitRevisionsImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitRevisionsImpl.java new file mode 100644 index 000000000000..b7142e9c37fe --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitRevisionsImpl.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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.softwareplan.fluent.HybridUseBenefitRevisionsClient; +import com.azure.resourcemanager.softwareplan.fluent.models.HybridUseBenefitModelInner; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefitModel; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefitRevisions; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class HybridUseBenefitRevisionsImpl implements HybridUseBenefitRevisions { + @JsonIgnore private final ClientLogger logger = new ClientLogger(HybridUseBenefitRevisionsImpl.class); + + private final HybridUseBenefitRevisionsClient innerClient; + + private final com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager; + + public HybridUseBenefitRevisionsImpl( + HybridUseBenefitRevisionsClient innerClient, + com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list(String scope, String planId) { + PagedIterable inner = this.serviceClient().list(scope, planId); + return Utils.mapPage(inner, inner1 -> new HybridUseBenefitModelImpl(inner1, this.manager())); + } + + public PagedIterable list(String scope, String planId, Context context) { + PagedIterable inner = this.serviceClient().list(scope, planId, context); + return Utils.mapPage(inner, inner1 -> new HybridUseBenefitModelImpl(inner1, this.manager())); + } + + private HybridUseBenefitRevisionsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitsClientImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitsClientImpl.java new file mode 100644 index 000000000000..446c39d4ca9e --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitsClientImpl.java @@ -0,0 +1,902 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +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.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.softwareplan.fluent.HybridUseBenefitsClient; +import com.azure.resourcemanager.softwareplan.fluent.models.HybridUseBenefitModelInner; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefitListResult; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in HybridUseBenefitsClient. */ +public final class HybridUseBenefitsClientImpl implements HybridUseBenefitsClient { + private final ClientLogger logger = new ClientLogger(HybridUseBenefitsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final HybridUseBenefitsService service; + + /** The service client containing this operation class. */ + private final SoftwarePlanRPImpl client; + + /** + * Initializes an instance of HybridUseBenefitsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + HybridUseBenefitsClientImpl(SoftwarePlanRPImpl client) { + this.service = + RestProxy.create(HybridUseBenefitsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SoftwarePlanRPHybridUseBenefits to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "SoftwarePlanRPHybrid") + private interface HybridUseBenefitsService { + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @PathParam("scope") String scope, + @QueryParam("api-version") String apiVersion, + @QueryParam("$filter") String filter, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put("/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> create( + @HostParam("$host") String endpoint, + @PathParam("scope") String scope, + @PathParam("planId") String planId, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") HybridUseBenefitModelInner body, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch("/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @PathParam("scope") String scope, + @PathParam("planId") String planId, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") HybridUseBenefitModelInner body, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get( + @HostParam("$host") String endpoint, + @PathParam("scope") String scope, + @PathParam("planId") String planId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete("/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}") + @ExpectedResponses({200, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete( + @HostParam("$host") String endpoint, + @PathParam("scope") String scope, + @PathParam("planId") String planId, + @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); + } + + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param filter Supports applying filter on the type of SKU. + * @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 all hybrid use benefits associated with an ARM resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String scope, String filter) { + 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(), scope, this.client.getApiVersion(), filter, 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 all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param filter Supports applying filter on the type of SKU. + * @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 all hybrid use benefits associated with an ARM resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync( + String scope, String filter, 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(), scope, this.client.getApiVersion(), filter, accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param filter Supports applying filter on the type of SKU. + * @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 all hybrid use benefits associated with an ARM resource. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope, String filter) { + return new PagedFlux<>(() -> listSinglePageAsync(scope, filter), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 all hybrid use benefits associated with an ARM resource. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope) { + final String filter = null; + return new PagedFlux<>(() -> listSinglePageAsync(scope, filter), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param filter Supports applying filter on the type of SKU. + * @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 all hybrid use benefits associated with an ARM resource. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope, String filter, Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(scope, filter, context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 all hybrid use benefits associated with an ARM resource. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope) { + final String filter = null; + return new PagedIterable<>(listAsync(scope, filter)); + } + + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param filter Supports applying filter on the type of SKU. + * @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 all hybrid use benefits associated with an ARM resource. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope, String filter, Context context) { + return new PagedIterable<>(listAsync(scope, filter, context)); + } + + /** + * Create a new hybrid use benefit under a given scope. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createWithResponseAsync( + String scope, String planId, HybridUseBenefitModelInner body) { + 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .create( + this.client.getEndpoint(), + scope, + planId, + this.client.getApiVersion(), + body, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a new hybrid use benefit under a given scope. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createWithResponseAsync( + String scope, String planId, HybridUseBenefitModelInner body, 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .create(this.client.getEndpoint(), scope, planId, this.client.getApiVersion(), body, accept, context); + } + + /** + * Create a new hybrid use benefit under a given scope. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync(String scope, String planId, HybridUseBenefitModelInner body) { + return createWithResponseAsync(scope, planId, body) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Create a new hybrid use benefit under a given scope. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public HybridUseBenefitModelInner create(String scope, String planId, HybridUseBenefitModelInner body) { + return createAsync(scope, planId, body).block(); + } + + /** + * Create a new hybrid use benefit under a given scope. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse( + String scope, String planId, HybridUseBenefitModelInner body, Context context) { + return createWithResponseAsync(scope, planId, body, context).block(); + } + + /** + * Updates an existing hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String scope, String planId, HybridUseBenefitModelInner body) { + 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + scope, + planId, + this.client.getApiVersion(), + body, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Updates an existing hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String scope, String planId, HybridUseBenefitModelInner body, 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update(this.client.getEndpoint(), scope, planId, this.client.getApiVersion(), body, accept, context); + } + + /** + * Updates an existing hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String scope, String planId, HybridUseBenefitModelInner body) { + return updateWithResponseAsync(scope, planId, body) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Updates an existing hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public HybridUseBenefitModelInner update(String scope, String planId, HybridUseBenefitModelInner body) { + return updateAsync(scope, planId, body).block(); + } + + /** + * Updates an existing hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @param body Request body for creating a hybrid use benefit. + * @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 response on GET of a hybrid use benefit. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String scope, String planId, HybridUseBenefitModelInner body, Context context) { + return updateWithResponseAsync(scope, planId, body, context).block(); + } + + /** + * Gets a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 given plan ID. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String scope, String planId) { + 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service.get(this.client.getEndpoint(), scope, planId, this.client.getApiVersion(), accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Gets a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 given plan ID. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync( + String scope, String planId, 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), scope, planId, this.client.getApiVersion(), accept, context); + } + + /** + * Gets a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 given plan ID. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String scope, String planId) { + return getWithResponseAsync(scope, planId) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Gets a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 given plan ID. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public HybridUseBenefitModelInner get(String scope, String planId) { + return getAsync(scope, planId).block(); + } + + /** + * Gets a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 given plan ID. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String scope, String planId, Context context) { + return getWithResponseAsync(scope, planId, context).block(); + } + + /** + * Deletes a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String scope, String planId) { + 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete(this.client.getEndpoint(), scope, planId, this.client.getApiVersion(), accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Deletes a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String scope, String planId, 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.")); + } + if (planId == null) { + return Mono.error(new IllegalArgumentException("Parameter planId is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), scope, planId, this.client.getApiVersion(), accept, context); + } + + /** + * Deletes a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String scope, String planId) { + return deleteWithResponseAsync(scope, planId).flatMap((Response res) -> Mono.empty()); + } + + /** + * Deletes a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String scope, String planId) { + deleteAsync(scope, planId).block(); + } + + /** + * Deletes a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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) + public Response deleteWithResponse(String scope, String planId, Context context) { + return deleteWithResponseAsync(scope, planId, context).block(); + } + + /** + * 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 list of hybrid use benefits. + */ + @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 list of hybrid use benefits. + */ + @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/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitsImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitsImpl.java new file mode 100644 index 000000000000..4cb80ed79340 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/HybridUseBenefitsImpl.java @@ -0,0 +1,187 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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.softwareplan.fluent.HybridUseBenefitsClient; +import com.azure.resourcemanager.softwareplan.fluent.models.HybridUseBenefitModelInner; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefitModel; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefits; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class HybridUseBenefitsImpl implements HybridUseBenefits { + @JsonIgnore private final ClientLogger logger = new ClientLogger(HybridUseBenefitsImpl.class); + + private final HybridUseBenefitsClient innerClient; + + private final com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager; + + public HybridUseBenefitsImpl( + HybridUseBenefitsClient innerClient, + com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list(String scope) { + PagedIterable inner = this.serviceClient().list(scope); + return Utils.mapPage(inner, inner1 -> new HybridUseBenefitModelImpl(inner1, this.manager())); + } + + public PagedIterable list(String scope, String filter, Context context) { + PagedIterable inner = this.serviceClient().list(scope, filter, context); + return Utils.mapPage(inner, inner1 -> new HybridUseBenefitModelImpl(inner1, this.manager())); + } + + public HybridUseBenefitModel get(String scope, String planId) { + HybridUseBenefitModelInner inner = this.serviceClient().get(scope, planId); + if (inner != null) { + return new HybridUseBenefitModelImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getWithResponse(String scope, String planId, Context context) { + Response inner = this.serviceClient().getWithResponse(scope, planId, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new HybridUseBenefitModelImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public void deleteByResourceGroup(String scope, String planId) { + this.serviceClient().delete(scope, planId); + } + + public Response deleteWithResponse(String scope, String planId, Context context) { + return this.serviceClient().deleteWithResponse(scope, planId, context); + } + + public HybridUseBenefitModel getById(String id) { + String scope = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "scope"); + if (scope == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id))); + } + String planId = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "planId"); + if (planId == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'hybridUseBenefits'.", id))); + } + return this.getWithResponse(scope, planId, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String scope = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "scope"); + if (scope == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id))); + } + String planId = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "planId"); + if (planId == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'hybridUseBenefits'.", id))); + } + return this.getWithResponse(scope, planId, context); + } + + public void deleteById(String id) { + String scope = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "scope"); + if (scope == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id))); + } + String planId = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "planId"); + if (planId == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'hybridUseBenefits'.", id))); + } + this.deleteWithResponse(scope, planId, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String scope = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "scope"); + if (scope == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id))); + } + String planId = + Utils + .getValueFromIdByParameterName( + id, "/{scope}/providers/Microsoft.SoftwarePlan/hybridUseBenefits/{planId}", "planId"); + if (planId == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'hybridUseBenefits'.", id))); + } + return this.deleteWithResponse(scope, planId, context); + } + + private HybridUseBenefitsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager() { + return this.serviceManager; + } + + public HybridUseBenefitModelImpl define(String name) { + return new HybridUseBenefitModelImpl(name, this.manager()); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/OperationResponseImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/OperationResponseImpl.java new file mode 100644 index 000000000000..70e11a3221fc --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/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.softwareplan.implementation; + +import com.azure.resourcemanager.softwareplan.fluent.models.OperationResponseInner; +import com.azure.resourcemanager.softwareplan.models.OperationDisplay; +import com.azure.resourcemanager.softwareplan.models.OperationResponse; + +public final class OperationResponseImpl implements OperationResponse { + private OperationResponseInner innerObject; + + private final com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager; + + OperationResponseImpl( + OperationResponseInner innerObject, com.azure.resourcemanager.softwareplan.SoftwarePlanManager 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.softwareplan.SoftwarePlanManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/OperationsClientImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..ffbf778e7508 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/OperationsClientImpl.java @@ -0,0 +1,291 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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.softwareplan.fluent.OperationsClient; +import com.azure.resourcemanager.softwareplan.fluent.models.OperationResponseInner; +import com.azure.resourcemanager.softwareplan.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 SoftwarePlanRPImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(SoftwarePlanRPImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SoftwarePlanRPOperations to be used by the proxy service to perform + * REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "SoftwarePlanRPOperat") + private interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/{scope}/providers/Microsoft.SoftwarePlan/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @PathParam("scope") String scope, + @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. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + @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(), scope, 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. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + @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(), scope, 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. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope) { + return new PagedFlux<>(() -> listSinglePageAsync(scope), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List all the operations. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String scope, Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(scope, context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List all the operations. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String scope) { + return new PagedIterable<>(listAsync(scope)); + } + + /** + * List all the operations. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + @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 list all the operations. + */ + @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 list all the operations. + */ + @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/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/OperationsImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/OperationsImpl.java new file mode 100644 index 000000000000..00e26a62bcb7 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/OperationsImpl.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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.softwareplan.fluent.OperationsClient; +import com.azure.resourcemanager.softwareplan.fluent.models.OperationResponseInner; +import com.azure.resourcemanager.softwareplan.models.OperationResponse; +import com.azure.resourcemanager.softwareplan.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.softwareplan.SoftwarePlanManager serviceManager; + + public OperationsImpl( + OperationsClient innerClient, com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list(String scope) { + PagedIterable inner = this.serviceClient().list(scope); + return Utils.mapPage(inner, inner1 -> new OperationResponseImpl(inner1, this.manager())); + } + + public PagedIterable list(String scope, Context context) { + PagedIterable inner = this.serviceClient().list(scope, context); + return Utils.mapPage(inner, inner1 -> new OperationResponseImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlanRPBuilder.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlanRPBuilder.java new file mode 100644 index 000000000000..a84ae374ae3d --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlanRPBuilder.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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 SoftwarePlanRPImpl type. */ +@ServiceClientBuilder(serviceClients = {SoftwarePlanRPImpl.class}) +public final class SoftwarePlanRPBuilder { + /* + * The ID of the target subscription. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. + * + * @param subscriptionId the subscriptionId value. + * @return the SoftwarePlanRPBuilder. + */ + public SoftwarePlanRPBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the SoftwarePlanRPBuilder. + */ + public SoftwarePlanRPBuilder 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 SoftwarePlanRPBuilder. + */ + public SoftwarePlanRPBuilder 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 SoftwarePlanRPBuilder. + */ + public SoftwarePlanRPBuilder 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 SoftwarePlanRPBuilder. + */ + public SoftwarePlanRPBuilder 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 SoftwarePlanRPBuilder. + */ + public SoftwarePlanRPBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of SoftwarePlanRPImpl with the provided parameters. + * + * @return an instance of SoftwarePlanRPImpl. + */ + public SoftwarePlanRPImpl 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(); + } + SoftwarePlanRPImpl client = + new SoftwarePlanRPImpl( + pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint); + return client; + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlanRPImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlanRPImpl.java new file mode 100644 index 000000000000..b12bbc0cd9ba --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlanRPImpl.java @@ -0,0 +1,335 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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.softwareplan.fluent.HybridUseBenefitRevisionsClient; +import com.azure.resourcemanager.softwareplan.fluent.HybridUseBenefitsClient; +import com.azure.resourcemanager.softwareplan.fluent.OperationsClient; +import com.azure.resourcemanager.softwareplan.fluent.SoftwarePlanRP; +import com.azure.resourcemanager.softwareplan.fluent.SoftwarePlansClient; +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 SoftwarePlanRPImpl type. */ +@ServiceClient(builder = SoftwarePlanRPBuilder.class) +public final class SoftwarePlanRPImpl implements SoftwarePlanRP { + private final ClientLogger logger = new ClientLogger(SoftwarePlanRPImpl.class); + + /** The ID of the target subscription. */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** 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 SoftwarePlansClient object to access its operations. */ + private final SoftwarePlansClient softwarePlans; + + /** + * Gets the SoftwarePlansClient object to access its operations. + * + * @return the SoftwarePlansClient object. + */ + public SoftwarePlansClient getSoftwarePlans() { + return this.softwarePlans; + } + + /** The HybridUseBenefitsClient object to access its operations. */ + private final HybridUseBenefitsClient hybridUseBenefits; + + /** + * Gets the HybridUseBenefitsClient object to access its operations. + * + * @return the HybridUseBenefitsClient object. + */ + public HybridUseBenefitsClient getHybridUseBenefits() { + return this.hybridUseBenefits; + } + + /** The HybridUseBenefitRevisionsClient object to access its operations. */ + private final HybridUseBenefitRevisionsClient hybridUseBenefitRevisions; + + /** + * Gets the HybridUseBenefitRevisionsClient object to access its operations. + * + * @return the HybridUseBenefitRevisionsClient object. + */ + public HybridUseBenefitRevisionsClient getHybridUseBenefitRevisions() { + return this.hybridUseBenefitRevisions; + } + + /** 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 SoftwarePlanRP 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 subscriptionId The ID of the target subscription. + * @param endpoint server parameter. + */ + SoftwarePlanRPImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + Duration defaultPollInterval, + AzureEnvironment environment, + String subscriptionId, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + this.apiVersion = "2019-12-01"; + this.softwarePlans = new SoftwarePlansClientImpl(this); + this.hybridUseBenefits = new HybridUseBenefitsClientImpl(this); + this.hybridUseBenefitRevisions = new HybridUseBenefitRevisionsClientImpl(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/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlansClientImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlansClientImpl.java new file mode 100644 index 000000000000..0bddf35c19dc --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlansClientImpl.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.Post; +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.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.softwareplan.fluent.SoftwarePlansClient; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in SoftwarePlansClient. */ +public final class SoftwarePlansClientImpl implements SoftwarePlansClient { + private final ClientLogger logger = new ClientLogger(SoftwarePlansClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final SoftwarePlansService service; + + /** The service client containing this operation class. */ + private final SoftwarePlanRPImpl client; + + /** + * Initializes an instance of SoftwarePlansClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SoftwarePlansClientImpl(SoftwarePlanRPImpl client) { + this.service = + RestProxy.create(SoftwarePlansService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SoftwarePlanRPSoftwarePlans to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "SoftwarePlanRPSoftwa") + private interface SoftwarePlansService { + @Headers({"Content-Type: application/json"}) + @Post("/subscriptions/{subscriptionId}/providers/Microsoft.SoftwarePlan/register") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> register( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Register to Microsoft.SoftwarePlan 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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> registerWithResponseAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .register( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Register to Microsoft.SoftwarePlan 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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> registerWithResponseAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .register( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context); + } + + /** + * Register to Microsoft.SoftwarePlan 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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono registerAsync() { + return registerWithResponseAsync().flatMap((Response res) -> Mono.empty()); + } + + /** + * Register to Microsoft.SoftwarePlan 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void register() { + registerAsync().block(); + } + + /** + * Register to Microsoft.SoftwarePlan 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) + public Response registerWithResponse(Context context) { + return registerWithResponseAsync(context).block(); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlansImpl.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlansImpl.java new file mode 100644 index 000000000000..c5e339c600c5 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/SoftwarePlansImpl.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.implementation; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.softwareplan.fluent.SoftwarePlansClient; +import com.azure.resourcemanager.softwareplan.models.SoftwarePlans; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class SoftwarePlansImpl implements SoftwarePlans { + @JsonIgnore private final ClientLogger logger = new ClientLogger(SoftwarePlansImpl.class); + + private final SoftwarePlansClient innerClient; + + private final com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager; + + public SoftwarePlansImpl( + SoftwarePlansClient innerClient, com.azure.resourcemanager.softwareplan.SoftwarePlanManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public void register() { + this.serviceClient().register(); + } + + public Response registerWithResponse(Context context) { + return this.serviceClient().registerWithResponse(context); + } + + private SoftwarePlansClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/Utils.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/Utils.java new file mode 100644 index 000000000000..74b0e27acc5d --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/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.softwareplan.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/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/package-info.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/package-info.java new file mode 100644 index 000000000000..e8f25247be80 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/implementation/package-info.java @@ -0,0 +1,9 @@ +// 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 SoftwarePlanRP. Azure software plans let users create and manage licenses + * for various software used in Azure. + */ +package com.azure.resourcemanager.softwareplan.implementation; diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefitListResult.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefitListResult.java new file mode 100644 index 000000000000..df05cbb4a7ff --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefitListResult.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.softwareplan.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.softwareplan.fluent.models.HybridUseBenefitModelInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** List of hybrid use benefits. */ +@Fluent +public final class HybridUseBenefitListResult { + @JsonIgnore private final ClientLogger logger = new ClientLogger(HybridUseBenefitListResult.class); + + /* + * List of hybrid use benefits + */ + @JsonProperty(value = "value") + private List value; + + /* + * Url to get the next page of items. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: List of hybrid use benefits. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of hybrid use benefits. + * + * @param value the value value to set. + * @return the HybridUseBenefitListResult object itself. + */ + public HybridUseBenefitListResult 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 HybridUseBenefitListResult object itself. + */ + public HybridUseBenefitListResult 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/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefitModel.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefitModel.java new file mode 100644 index 000000000000..dbd624e1c346 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefitModel.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.softwareplan.models; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.softwareplan.fluent.models.HybridUseBenefitModelInner; +import java.time.OffsetDateTime; + +/** An immutable client-side representation of HybridUseBenefitModel. */ +public interface HybridUseBenefitModel { + /** + * 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 sku property: Hybrid use benefit SKU. + * + * @return the sku value. + */ + Sku sku(); + + /** + * Gets the etag property: Indicates the revision of the hybrid use benefit. + * + * @return the etag value. + */ + Integer etag(); + + /** + * Gets the provisioningState property: Provisioning state. + * + * @return the provisioningState value. + */ + ProvisioningState provisioningState(); + + /** + * Gets the createdDate property: Created date. + * + * @return the createdDate value. + */ + OffsetDateTime createdDate(); + + /** + * Gets the lastUpdatedDate property: Last updated date. + * + * @return the lastUpdatedDate value. + */ + OffsetDateTime lastUpdatedDate(); + + /** + * Gets the inner com.azure.resourcemanager.softwareplan.fluent.models.HybridUseBenefitModelInner object. + * + * @return the inner object. + */ + HybridUseBenefitModelInner innerModel(); + + /** The entirety of the HybridUseBenefitModel definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithScope, + DefinitionStages.WithSku, + DefinitionStages.WithCreate { + } + /** The HybridUseBenefitModel definition stages. */ + interface DefinitionStages { + /** The first stage of the HybridUseBenefitModel definition. */ + interface Blank extends WithScope { + } + /** The stage of the HybridUseBenefitModel definition allowing to specify parent resource. */ + interface WithScope { + /** + * Specifies scope. + * + * @param scope The scope at which the operation is performed. This is limited to + * Microsoft.Compute/virtualMachines and Microsoft.Compute/hostGroups/hosts for now. + * @return the next definition stage. + */ + WithSku withExistingScope(String scope); + } + /** The stage of the HybridUseBenefitModel definition allowing to specify sku. */ + interface WithSku { + /** + * Specifies the sku property: Hybrid use benefit SKU. + * + * @param sku Hybrid use benefit SKU. + * @return the next definition stage. + */ + WithCreate withSku(Sku sku); + } + /** + * The stage of the HybridUseBenefitModel 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 { + /** + * Executes the create request. + * + * @return the created resource. + */ + HybridUseBenefitModel create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + HybridUseBenefitModel create(Context context); + } + } + /** + * Begins update for the HybridUseBenefitModel resource. + * + * @return the stage of resource update. + */ + HybridUseBenefitModel.Update update(); + + /** The template for HybridUseBenefitModel update. */ + interface Update extends UpdateStages.WithSku { + /** + * Executes the update request. + * + * @return the updated resource. + */ + HybridUseBenefitModel apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + HybridUseBenefitModel apply(Context context); + } + /** The HybridUseBenefitModel update stages. */ + interface UpdateStages { + /** The stage of the HybridUseBenefitModel update allowing to specify sku. */ + interface WithSku { + /** + * Specifies the sku property: Hybrid use benefit SKU. + * + * @param sku Hybrid use benefit SKU. + * @return the next definition stage. + */ + Update withSku(Sku sku); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + HybridUseBenefitModel refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + HybridUseBenefitModel refresh(Context context); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefitRevisions.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefitRevisions.java new file mode 100644 index 000000000000..2ec5f1fe3c6c --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefitRevisions.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.softwareplan.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of HybridUseBenefitRevisions. */ +public interface HybridUseBenefitRevisions { + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + PagedIterable list(String scope, String planId); + + /** + * Gets the version history of a hybrid use benefit. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 version history of a hybrid use benefit. + */ + PagedIterable list(String scope, String planId, Context context); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefits.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefits.java new file mode 100644 index 000000000000..843c2eadccd5 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/HybridUseBenefits.java @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.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 HybridUseBenefits. */ +public interface HybridUseBenefits { + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 all hybrid use benefits associated with an ARM resource. + */ + PagedIterable list(String scope); + + /** + * Get all hybrid use benefits associated with an ARM resource. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param filter Supports applying filter on the type of SKU. + * @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 all hybrid use benefits associated with an ARM resource. + */ + PagedIterable list(String scope, String filter, Context context); + + /** + * Gets a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 given plan ID. + */ + HybridUseBenefitModel get(String scope, String planId); + + /** + * Gets a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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 given plan ID. + */ + Response getWithResponse(String scope, String planId, Context context); + + /** + * Deletes a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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. + */ + void deleteByResourceGroup(String scope, String planId); + + /** + * Deletes a given plan ID. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @param planId This is a unique identifier for a plan. Should be a guid. + * @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. + */ + Response deleteWithResponse(String scope, String planId, Context context); + + /** + * Gets a given plan ID. + * + * @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 a given plan ID. + */ + HybridUseBenefitModel getById(String id); + + /** + * Gets a given plan ID. + * + * @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 a given plan ID. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Deletes a given plan ID. + * + * @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. + */ + void deleteById(String id); + + /** + * Deletes a given plan ID. + * + * @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 response. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new HybridUseBenefitModel resource. + * + * @param name resource name. + * @return the first stage of the new HybridUseBenefitModel definition. + */ + HybridUseBenefitModel.DefinitionStages.Blank define(String name); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/OperationDisplay.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/OperationDisplay.java new file mode 100644 index 000000000000..f3f1857dc887 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/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.softwareplan.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; + +/** Display fields for an operation. */ +@Fluent +public final class OperationDisplay { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationDisplay.class); + + /* + * Resource Provider name + */ + @JsonProperty(value = "provider") + private String provider; + + /* + * Resource that is acted upon + */ + @JsonProperty(value = "resource") + private String resource; + + /* + * Operation to be performed + */ + @JsonProperty(value = "operation") + private String operation; + + /* + * Description of the operation + */ + @JsonProperty(value = "description") + private String description; + + /** + * Get the provider property: Resource Provider name. + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider property: Resource 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 that is acted upon. + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Set the resource property: Resource that is acted upon. + * + * @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 to be performed. + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Set the operation property: Operation to be performed. + * + * @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: Description of the operation. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: Description of the operation. + * + * @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/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/OperationList.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/OperationList.java new file mode 100644 index 000000000000..6747ba36912b --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/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.softwareplan.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.softwareplan.fluent.models.OperationResponseInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** List all the operations. */ +@Fluent +public final class OperationList { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationList.class); + + /* + * List of all operations + */ + @JsonProperty(value = "value") + private List value; + + /* + * Url to get the next page of items. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: List of all operations. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of all operations. + * + * @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/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/OperationResponse.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/OperationResponse.java new file mode 100644 index 000000000000..fa0c126cd77b --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/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.softwareplan.models; + +import com.azure.resourcemanager.softwareplan.fluent.models.OperationResponseInner; + +/** An immutable client-side representation of OperationResponse. */ +public interface OperationResponse { + /** + * Gets the name property: Name of the operation. + * + * @return the name value. + */ + String name(); + + /** + * Gets the display property: Display properties for the operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: Origin of the response. + * + * @return the origin value. + */ + String origin(); + + /** + * Gets the inner com.azure.resourcemanager.softwareplan.fluent.models.OperationResponseInner object. + * + * @return the inner object. + */ + OperationResponseInner innerModel(); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/Operations.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/Operations.java new file mode 100644 index 000000000000..da6bbe940ae6 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/Operations.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.softwareplan.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. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + PagedIterable list(String scope); + + /** + * List all the operations. + * + * @param scope The scope at which the operation is performed. This is limited to Microsoft.Compute/virtualMachines + * and Microsoft.Compute/hostGroups/hosts for now. + * @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 list all the operations. + */ + PagedIterable list(String scope, Context context); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/ProvisioningState.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/ProvisioningState.java new file mode 100644 index 000000000000..10b8c0ec3a83 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/ProvisioningState.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.softwareplan.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for ProvisioningState. */ +public final class ProvisioningState extends ExpandableStringEnum { + /** Static value Succeeded for ProvisioningState. */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** Static value Cancelled for ProvisioningState. */ + public static final ProvisioningState CANCELLED = fromString("Cancelled"); + + /** Static value Failed for ProvisioningState. */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + @JsonCreator + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** @return known ProvisioningState values. */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/Sku.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/Sku.java new file mode 100644 index 000000000000..117cdcf1278b --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/Sku.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.softwareplan.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 SKU to be applied for this resource. */ +@Fluent +public final class Sku { + @JsonIgnore private final ClientLogger logger = new ClientLogger(Sku.class); + + /* + * Name of the SKU to be applied + */ + @JsonProperty(value = "name") + private String name; + + /** + * Get the name property: Name of the SKU to be applied. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Name of the SKU to be applied. + * + * @param name the name value to set. + * @return the Sku object itself. + */ + public Sku withName(String name) { + this.name = name; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/SoftwarePlans.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/SoftwarePlans.java new file mode 100644 index 000000000000..fec36c86c929 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/SoftwarePlans.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of SoftwarePlans. */ +public interface SoftwarePlans { + /** + * Register to Microsoft.SoftwarePlan 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. + */ + void register(); + + /** + * Register to Microsoft.SoftwarePlan 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. + */ + Response registerWithResponse(Context context); +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/package-info.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/package-info.java new file mode 100644 index 000000000000..b4f9a9d2168f --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/models/package-info.java @@ -0,0 +1,9 @@ +// 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 SoftwarePlanRP. Azure software plans let users create and manage licenses for + * various software used in Azure. + */ +package com.azure.resourcemanager.softwareplan.models; diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/package-info.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/package-info.java new file mode 100644 index 000000000000..fb8153da5de2 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/com/azure/resourcemanager/softwareplan/package-info.java @@ -0,0 +1,9 @@ +// 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 SoftwarePlanRP. Azure software plans let users create and manage licenses for + * various software used in Azure. + */ +package com.azure.resourcemanager.softwareplan; diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/module-info.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/main/java/module-info.java new file mode 100644 index 000000000000..75d42c1974ff --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/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.softwareplan { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.softwareplan; + exports com.azure.resourcemanager.softwareplan.fluent; + exports com.azure.resourcemanager.softwareplan.fluent.models; + exports com.azure.resourcemanager.softwareplan.models; + + opens com.azure.resourcemanager.softwareplan.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.softwareplan.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitCreateSamples.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitCreateSamples.java new file mode 100644 index 000000000000..2bb4e5472797 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitCreateSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.generated; + +import com.azure.resourcemanager.softwareplan.models.Sku; + +/** Samples for HybridUseBenefit Create. */ +public final class HybridUseBenefitCreateSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/PutHybridUseBenefit.json + */ + /** + * Sample code: HybridUseBenefit. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefit(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefits() + .define("94f46eda-45f8-493a-8425-251921463a89") + .withExistingScope( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}") + .withSku(new Sku().withName("SQL_Server_Perpetual")) + .create(); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitDeleteSamples.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitDeleteSamples.java new file mode 100644 index 000000000000..7f32f969638f --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitDeleteSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.generated; + +import com.azure.core.util.Context; + +/** Samples for HybridUseBenefit Delete. */ +public final class HybridUseBenefitDeleteSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/DeleteHybridUseBenefit.json + */ + /** + * Sample code: HybridUseBenefit. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefit(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefits() + .deleteWithResponse( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "94f46eda-45f8-493a-8425-251921463a89", + Context.NONE); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitGetSamples.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitGetSamples.java new file mode 100644 index 000000000000..259ca85dc7af --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitGetSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.generated; + +import com.azure.core.util.Context; + +/** Samples for HybridUseBenefit Get. */ +public final class HybridUseBenefitGetSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/GetSingleHybridUseBenefit.json + */ + /** + * Sample code: HybridUseBenefit. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefit(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefits() + .getWithResponse( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "94f46eda-45f8-493a-8425-251921463a89", + Context.NONE); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitListSamples.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitListSamples.java new file mode 100644 index 000000000000..36487a75be3e --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitListSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.generated; + +import com.azure.core.util.Context; + +/** Samples for HybridUseBenefit List. */ +public final class HybridUseBenefitListSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/GetAllHybridUseBenefits.json + */ + /** + * Sample code: HybridUseBenefitListResult. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefitListResult(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefits() + .list( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "SQL_Server_EE_AHB", + Context.NONE); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitRevisionListSamples.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitRevisionListSamples.java new file mode 100644 index 000000000000..8d6a4d43d279 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitRevisionListSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.generated; + +import com.azure.core.util.Context; + +/** Samples for HybridUseBenefitRevision List. */ +public final class HybridUseBenefitRevisionListSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/GetHybridUseBenefitRevisions.json + */ + /** + * Sample code: HybridUseBenefitRevisionsResponse. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefitRevisionsResponse( + com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .hybridUseBenefitRevisions() + .list( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "94f46eda-45f8-493a-8425-251921463a89", + Context.NONE); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitUpdateSamples.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitUpdateSamples.java new file mode 100644 index 000000000000..7f8482e61f56 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/HybridUseBenefitUpdateSamples.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.softwareplan.generated; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.softwareplan.models.HybridUseBenefitModel; +import com.azure.resourcemanager.softwareplan.models.Sku; + +/** Samples for HybridUseBenefit Update. */ +public final class HybridUseBenefitUpdateSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/PatchHybridUseBenefit.json + */ + /** + * Sample code: HybridUseBenefit. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefit(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + HybridUseBenefitModel resource = + manager + .hybridUseBenefits() + .getWithResponse( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + "94f46eda-45f8-493a-8425-251921463a89", + Context.NONE) + .getValue(); + resource.update().withSku(new Sku().withName("SQLBYOLStandardForADH")).apply(); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/OperationsListSamples.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/OperationsListSamples.java new file mode 100644 index 000000000000..ff6d0b66cf71 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/OperationsListSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.generated; + +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/GetOperations.json + */ + /** + * Sample code: GetOperations. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void getOperations(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager + .operations() + .list( + "subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/HostGroups/{host-group-name}/hosts/{host-name}", + Context.NONE); + } +} diff --git a/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/SoftwarePlanRegisterSamples.java b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/SoftwarePlanRegisterSamples.java new file mode 100644 index 000000000000..7d227b06f003 --- /dev/null +++ b/sdk/softwareplan/azure-resourcemanager-softwareplan/src/samples/java/com/azure/resourcemanager/softwareplan/generated/SoftwarePlanRegisterSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.softwareplan.generated; + +import com.azure.core.util.Context; + +/** Samples for SoftwarePlan Register. */ +public final class SoftwarePlanRegisterSamples { + /* + * x-ms-original-file: specification/softwareplan/resource-manager/Microsoft.SoftwarePlan/stable/2019-12-01/examples/RegisterSubscription.json + */ + /** + * Sample code: HybridUseBenefitListResult. + * + * @param manager Entry point to SoftwarePlanManager. + */ + public static void hybridUseBenefitListResult(com.azure.resourcemanager.softwareplan.SoftwarePlanManager manager) { + manager.softwarePlans().registerWithResponse(Context.NONE); + } +} diff --git a/sdk/softwareplan/ci.yml b/sdk/softwareplan/ci.yml new file mode 100644 index 000000000000..b84ce5389c6d --- /dev/null +++ b/sdk/softwareplan/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/softwareplan/ci.yml + - sdk/softwareplan/azure-resourcemanager-softwareplan/ + exclude: + - sdk/softwareplan/pom.xml + - sdk/softwareplan/azure-resourcemanager-softwareplan/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/softwareplan/ci.yml + - sdk/softwareplan/azure-resourcemanager-softwareplan/ + exclude: + - sdk/softwareplan/pom.xml + - sdk/softwareplan/azure-resourcemanager-softwareplan/pom.xml + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: softwareplan + Artifacts: + - name: azure-resourcemanager-softwareplan + groupId: com.azure.resourcemanager + safeName: azureresourcemanagersoftwareplan diff --git a/sdk/softwareplan/pom.xml b/sdk/softwareplan/pom.xml new file mode 100644 index 000000000000..d51a0771e7b3 --- /dev/null +++ b/sdk/softwareplan/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + com.azure + azure-softwareplan-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-softwareplan + + + +