diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 8e04955187aa..ee0a8cdaf1da 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -324,6 +324,7 @@ com.azure.resourcemanager:azure-resourcemanager-storagepool;1.0.0-beta.1;1.0.0-b com.azure.resourcemanager:azure-resourcemanager-dataprotection;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-desktopvirtualization;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-loadtestservice;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-windowsesu;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 bf7a714e06c4..891ed2c31777 100644 --- a/pom.xml +++ b/pom.xml @@ -842,6 +842,7 @@ sdk/videoanalyzer sdk/vmwarecloudsimple sdk/webpubsub + sdk/windowsesu diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/CHANGELOG.md b/sdk/windowsesu/azure-resourcemanager-windowsesu/CHANGELOG.md new file mode 100644 index 000000000000..9b1d3e3b3df3 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2021-12-10) + +- Azure Resource Manager Windowsesu client library for Java. This package contains Microsoft Azure SDK for Windowsesu Management SDK. Manage Multi-Access Keys (MAK) that enable Windows Extended Security Updates (ESU). Package tag package-2019-09-16-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/README.md b/sdk/windowsesu/azure-resourcemanager-windowsesu/README.md new file mode 100644 index 000000000000..b56e5df34dd1 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager Windowsesu client library for Java + +Azure Resource Manager Windowsesu client library for Java. + +This package contains Microsoft Azure SDK for Windowsesu Management SDK. Manage Multi-Access Keys (MAK) that enable Windows Extended Security Updates (ESU). Package tag package-2019-09-16-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-windowsesu;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-windowsesu + 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(); +WindowsesuManager manager = WindowsesuManager + .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/windowsesu/azure-resourcemanager-windowsesu/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/windowsesu/azure-resourcemanager-windowsesu/SAMPLE.md b/sdk/windowsesu/azure-resourcemanager-windowsesu/SAMPLE.md new file mode 100644 index 000000000000..4d6ed05d0d11 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/SAMPLE.md @@ -0,0 +1,192 @@ +# Code snippets and samples + + +## MultipleActivationKeys + +- [Create](#multipleactivationkeys_create) +- [Delete](#multipleactivationkeys_delete) +- [GetByResourceGroup](#multipleactivationkeys_getbyresourcegroup) +- [List](#multipleactivationkeys_list) +- [ListByResourceGroup](#multipleactivationkeys_listbyresourcegroup) +- [Update](#multipleactivationkeys_update) + +## Operations + +- [List](#operations_list) +### MultipleActivationKeys_Create + +```java +import com.azure.resourcemanager.windowsesu.models.OsType; +import com.azure.resourcemanager.windowsesu.models.SupportType; + +/** Samples for MultipleActivationKeys Create. */ +public final class MultipleActivationKeysCreateSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/CreateMultipleActivationKey.json + */ + /** + * Sample code: CreateMultipleActivationKey. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void createMultipleActivationKey(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager + .multipleActivationKeys() + .define("server08-key-2019") + .withRegion("East US") + .withExistingResourceGroup("testgr1") + .withOsType(OsType.WINDOWS_SERVER2008) + .withSupportType(SupportType.SUPPLEMENTAL_SERVICING) + .withInstalledServerNumber(100) + .withAgreementNumber("1a2b45ag") + .withIsEligible(true) + .create(); + } +} +``` + +### MultipleActivationKeys_Delete + +```java +import com.azure.core.util.Context; + +/** Samples for MultipleActivationKeys Delete. */ +public final class MultipleActivationKeysDeleteSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/DeleteMultipleActivationKey.json + */ + /** + * Sample code: DeleteMultipleActivationKey. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void deleteMultipleActivationKey(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.multipleActivationKeys().deleteWithResponse("testgr1", "server08-key-2019", Context.NONE); + } +} +``` + +### MultipleActivationKeys_GetByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for MultipleActivationKeys GetByResourceGroup. */ +public final class MultipleActivationKeysGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/GetMultipleActivationKey.json + */ + /** + * Sample code: GetMultipleActivationKey. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void getMultipleActivationKey(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.multipleActivationKeys().getByResourceGroupWithResponse("testgr1", "server08-key-2019", Context.NONE); + } +} +``` + +### MultipleActivationKeys_List + +```java +import com.azure.core.util.Context; + +/** Samples for MultipleActivationKeys List. */ +public final class MultipleActivationKeysListSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListMultipleActivationKeys.json + */ + /** + * Sample code: ListMultipleActivationKeys. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void listMultipleActivationKeys(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.multipleActivationKeys().list(Context.NONE); + } +} +``` + +### MultipleActivationKeys_ListByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for MultipleActivationKeys ListByResourceGroup. */ +public final class MultipleActivationKeysListByResourceGroupSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListMultipleActivationKeysByResourceGroup.json + */ + /** + * Sample code: ListMultipleActivationKeys. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void listMultipleActivationKeys(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.multipleActivationKeys().listByResourceGroup("testrg1", Context.NONE); + } +} +``` + +### MultipleActivationKeys_Update + +```java +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKey; +import java.util.HashMap; +import java.util.Map; + +/** Samples for MultipleActivationKeys Update. */ +public final class MultipleActivationKeysUpdateSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/UpdateMultipleActivationKey.json + */ + /** + * Sample code: UpdateMultipleActivationKey. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void updateMultipleActivationKey(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + MultipleActivationKey resource = + manager + .multipleActivationKeys() + .getByResourceGroupWithResponse("testgr1", "server08-key-2019", Context.NONE) + .getValue(); + resource.update().withTags(mapOf("tag1", "value1", "tag2", "value2")).apply(); + } + + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### Operations_List + +```java +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListOperations.json + */ + /** + * Sample code: ListOperations. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void listOperations(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.operations().list(Context.NONE); + } +} +``` + diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/pom.xml b/sdk/windowsesu/azure-resourcemanager-windowsesu/pom.xml new file mode 100644 index 000000000000..cd047c91a429 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/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-windowsesu + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Windowsesu Management + This package contains Microsoft Azure SDK for Windowsesu Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Manage Multi-Access Keys (MAK) that enable Windows Extended Security Updates (ESU). Package tag package-2019-09-16-preview. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/WindowsesuManager.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/WindowsesuManager.java new file mode 100644 index 000000000000..7e87b95bbbad --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/WindowsesuManager.java @@ -0,0 +1,257 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu; + +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.windowsesu.fluent.Windowsesu; +import com.azure.resourcemanager.windowsesu.implementation.MultipleActivationKeysImpl; +import com.azure.resourcemanager.windowsesu.implementation.OperationsImpl; +import com.azure.resourcemanager.windowsesu.implementation.WindowsesuBuilder; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKeys; +import com.azure.resourcemanager.windowsesu.models.Operations; +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 WindowsesuManager. Manage Multi-Access Keys (MAK) that enable Windows Extended Security Updates (ESU). + */ +public final class WindowsesuManager { + private Operations operations; + + private MultipleActivationKeys multipleActivationKeys; + + private final Windowsesu clientObject; + + private WindowsesuManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new WindowsesuBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Windowsesu service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Windowsesu service API instance. + */ + public static WindowsesuManager 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 WindowsesuManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new WindowsesuManager.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 Windowsesu service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Windowsesu service API instance. + */ + public WindowsesuManager 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.windowsesu") + .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 WindowsesuManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of Operations. */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** @return Resource collection API of MultipleActivationKeys. */ + public MultipleActivationKeys multipleActivationKeys() { + if (this.multipleActivationKeys == null) { + this.multipleActivationKeys = + new MultipleActivationKeysImpl(clientObject.getMultipleActivationKeys(), this); + } + return multipleActivationKeys; + } + + /** + * @return Wrapped service client Windowsesu providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + */ + public Windowsesu serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/MultipleActivationKeysClient.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/MultipleActivationKeysClient.java new file mode 100644 index 000000000000..c758d677f665 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/MultipleActivationKeysClient.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.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.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.windowsesu.fluent.models.MultipleActivationKeyInner; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKeyUpdate; + +/** An instance of this class provides access to all the operations defined in MultipleActivationKeysClient. */ +public interface MultipleActivationKeysClient { + /** + * List all Multiple Activation Keys (MAK) created for a subscription. + * + * @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 of MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List all Multiple Activation Keys (MAK) created for a subscription. + * + * @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 of MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * List all Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 of MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List all Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 of MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 MAK key. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MultipleActivationKeyInner getByResourceGroup(String resourceGroupName, String multipleActivationKeyName); + + /** + * Get a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 MAK key. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse( + String resourceGroupName, String multipleActivationKeyName, Context context); + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, MultipleActivationKeyInner> beginCreate( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyInner multipleActivationKey); + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, MultipleActivationKeyInner> beginCreate( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyInner multipleActivationKey, + Context context); + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MultipleActivationKeyInner create( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyInner multipleActivationKey); + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MultipleActivationKeyInner create( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyInner multipleActivationKey, + Context context); + + /** + * Update a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MultipleActivationKeyInner update( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyUpdate multipleActivationKey); + + /** + * Update a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyUpdate multipleActivationKey, + Context context); + + /** + * Delete a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 resourceGroupName, String multipleActivationKeyName); + + /** + * Delete a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 resourceGroupName, String multipleActivationKeyName, Context context); +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/OperationsClient.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/OperationsClient.java new file mode 100644 index 000000000000..f51df1ad2d73 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/OperationsClient.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.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.windowsesu.fluent.models.OperationInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * List all available Windows.ESU provider operations. + * + * @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 of available REST API operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List all available Windows.ESU provider operations. + * + * @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 of available REST API operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/Windowsesu.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/Windowsesu.java new file mode 100644 index 000000000000..aa5dc7e7560b --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/Windowsesu.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for Windowsesu class. */ +public interface Windowsesu { + /** + * 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 OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the MultipleActivationKeysClient object to access its operations. + * + * @return the MultipleActivationKeysClient object. + */ + MultipleActivationKeysClient getMultipleActivationKeys(); +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/MultipleActivationKeyInner.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/MultipleActivationKeyInner.java new file mode 100644 index 000000000000..b074c884c3a2 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/MultipleActivationKeyInner.java @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.windowsesu.models.OsType; +import com.azure.resourcemanager.windowsesu.models.ProvisioningState; +import com.azure.resourcemanager.windowsesu.models.SupportType; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.Map; + +/** MAK key details. */ +@Fluent +public final class MultipleActivationKeyInner extends Resource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(MultipleActivationKeyInner.class); + + /* + * MAK key specific properties. + */ + @JsonProperty(value = "properties") + private MultipleActivationKeyProperties innerProperties; + + /** + * Get the innerProperties property: MAK key specific properties. + * + * @return the innerProperties value. + */ + private MultipleActivationKeyProperties innerProperties() { + return this.innerProperties; + } + + /** {@inheritDoc} */ + @Override + public MultipleActivationKeyInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public MultipleActivationKeyInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the multipleActivationKey property: MAK 5x5 key. + * + * @return the multipleActivationKey value. + */ + public String multipleActivationKey() { + return this.innerProperties() == null ? null : this.innerProperties().multipleActivationKey(); + } + + /** + * Get the expirationDate property: End of support of security updates activated by the MAK key. + * + * @return the expirationDate value. + */ + public OffsetDateTime expirationDate() { + return this.innerProperties() == null ? null : this.innerProperties().expirationDate(); + } + + /** + * Get the osType property: Type of OS for which the key is requested. + * + * @return the osType value. + */ + public OsType osType() { + return this.innerProperties() == null ? null : this.innerProperties().osType(); + } + + /** + * Set the osType property: Type of OS for which the key is requested. + * + * @param osType the osType value to set. + * @return the MultipleActivationKeyInner object itself. + */ + public MultipleActivationKeyInner withOsType(OsType osType) { + if (this.innerProperties() == null) { + this.innerProperties = new MultipleActivationKeyProperties(); + } + this.innerProperties().withOsType(osType); + return this; + } + + /** + * Get the supportType property: Type of support. + * + * @return the supportType value. + */ + public SupportType supportType() { + return this.innerProperties() == null ? null : this.innerProperties().supportType(); + } + + /** + * Set the supportType property: Type of support. + * + * @param supportType the supportType value to set. + * @return the MultipleActivationKeyInner object itself. + */ + public MultipleActivationKeyInner withSupportType(SupportType supportType) { + if (this.innerProperties() == null) { + this.innerProperties = new MultipleActivationKeyProperties(); + } + this.innerProperties().withSupportType(supportType); + return this; + } + + /** + * Get the installedServerNumber property: Number of activations/servers using the MAK key. + * + * @return the installedServerNumber value. + */ + public Integer installedServerNumber() { + return this.innerProperties() == null ? null : this.innerProperties().installedServerNumber(); + } + + /** + * Set the installedServerNumber property: Number of activations/servers using the MAK key. + * + * @param installedServerNumber the installedServerNumber value to set. + * @return the MultipleActivationKeyInner object itself. + */ + public MultipleActivationKeyInner withInstalledServerNumber(Integer installedServerNumber) { + if (this.innerProperties() == null) { + this.innerProperties = new MultipleActivationKeyProperties(); + } + this.innerProperties().withInstalledServerNumber(installedServerNumber); + return this; + } + + /** + * Get the agreementNumber property: Agreement number under which the key is requested. + * + * @return the agreementNumber value. + */ + public String agreementNumber() { + return this.innerProperties() == null ? null : this.innerProperties().agreementNumber(); + } + + /** + * Set the agreementNumber property: Agreement number under which the key is requested. + * + * @param agreementNumber the agreementNumber value to set. + * @return the MultipleActivationKeyInner object itself. + */ + public MultipleActivationKeyInner withAgreementNumber(String agreementNumber) { + if (this.innerProperties() == null) { + this.innerProperties = new MultipleActivationKeyProperties(); + } + this.innerProperties().withAgreementNumber(agreementNumber); + return this; + } + + /** + * Get the isEligible property: <code> true </code> if user has eligible on-premises Windows physical or + * virtual machines, and that the requested key will only be used in their organization; <code> false + * </code> otherwise. + * + * @return the isEligible value. + */ + public Boolean isEligible() { + return this.innerProperties() == null ? null : this.innerProperties().isEligible(); + } + + /** + * Set the isEligible property: <code> true </code> if user has eligible on-premises Windows physical or + * virtual machines, and that the requested key will only be used in their organization; <code> false + * </code> otherwise. + * + * @param isEligible the isEligible value to set. + * @return the MultipleActivationKeyInner object itself. + */ + public MultipleActivationKeyInner withIsEligible(Boolean isEligible) { + if (this.innerProperties() == null) { + this.innerProperties = new MultipleActivationKeyProperties(); + } + this.innerProperties().withIsEligible(isEligible); + return this; + } + + /** + * Get the provisioningState property: The provisioningState property. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/MultipleActivationKeyProperties.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/MultipleActivationKeyProperties.java new file mode 100644 index 000000000000..c2878e778aa4 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/MultipleActivationKeyProperties.java @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.windowsesu.models.OsType; +import com.azure.resourcemanager.windowsesu.models.ProvisioningState; +import com.azure.resourcemanager.windowsesu.models.SupportType; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** MAK key specific properties. */ +@Fluent +public final class MultipleActivationKeyProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(MultipleActivationKeyProperties.class); + + /* + * MAK 5x5 key. + */ + @JsonProperty(value = "multipleActivationKey", access = JsonProperty.Access.WRITE_ONLY) + private String multipleActivationKey; + + /* + * End of support of security updates activated by the MAK key. + */ + @JsonProperty(value = "expirationDate", access = JsonProperty.Access.WRITE_ONLY) + private OffsetDateTime expirationDate; + + /* + * Type of OS for which the key is requested. + */ + @JsonProperty(value = "osType") + private OsType osType; + + /* + * Type of support + */ + @JsonProperty(value = "supportType") + private SupportType supportType; + + /* + * Number of activations/servers using the MAK key. + */ + @JsonProperty(value = "installedServerNumber") + private Integer installedServerNumber; + + /* + * Agreement number under which the key is requested. + */ + @JsonProperty(value = "agreementNumber") + private String agreementNumber; + + /* + * true if user has eligible on-premises Windows physical or + * virtual machines, and that the requested key will only be used in their + * organization; false otherwise. + */ + @JsonProperty(value = "isEligible") + private Boolean isEligible; + + /* + * The provisioningState property. + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private ProvisioningState provisioningState; + + /** + * Get the multipleActivationKey property: MAK 5x5 key. + * + * @return the multipleActivationKey value. + */ + public String multipleActivationKey() { + return this.multipleActivationKey; + } + + /** + * Get the expirationDate property: End of support of security updates activated by the MAK key. + * + * @return the expirationDate value. + */ + public OffsetDateTime expirationDate() { + return this.expirationDate; + } + + /** + * Get the osType property: Type of OS for which the key is requested. + * + * @return the osType value. + */ + public OsType osType() { + return this.osType; + } + + /** + * Set the osType property: Type of OS for which the key is requested. + * + * @param osType the osType value to set. + * @return the MultipleActivationKeyProperties object itself. + */ + public MultipleActivationKeyProperties withOsType(OsType osType) { + this.osType = osType; + return this; + } + + /** + * Get the supportType property: Type of support. + * + * @return the supportType value. + */ + public SupportType supportType() { + return this.supportType; + } + + /** + * Set the supportType property: Type of support. + * + * @param supportType the supportType value to set. + * @return the MultipleActivationKeyProperties object itself. + */ + public MultipleActivationKeyProperties withSupportType(SupportType supportType) { + this.supportType = supportType; + return this; + } + + /** + * Get the installedServerNumber property: Number of activations/servers using the MAK key. + * + * @return the installedServerNumber value. + */ + public Integer installedServerNumber() { + return this.installedServerNumber; + } + + /** + * Set the installedServerNumber property: Number of activations/servers using the MAK key. + * + * @param installedServerNumber the installedServerNumber value to set. + * @return the MultipleActivationKeyProperties object itself. + */ + public MultipleActivationKeyProperties withInstalledServerNumber(Integer installedServerNumber) { + this.installedServerNumber = installedServerNumber; + return this; + } + + /** + * Get the agreementNumber property: Agreement number under which the key is requested. + * + * @return the agreementNumber value. + */ + public String agreementNumber() { + return this.agreementNumber; + } + + /** + * Set the agreementNumber property: Agreement number under which the key is requested. + * + * @param agreementNumber the agreementNumber value to set. + * @return the MultipleActivationKeyProperties object itself. + */ + public MultipleActivationKeyProperties withAgreementNumber(String agreementNumber) { + this.agreementNumber = agreementNumber; + return this; + } + + /** + * Get the isEligible property: <code> true </code> if user has eligible on-premises Windows physical or + * virtual machines, and that the requested key will only be used in their organization; <code> false + * </code> otherwise. + * + * @return the isEligible value. + */ + public Boolean isEligible() { + return this.isEligible; + } + + /** + * Set the isEligible property: <code> true </code> if user has eligible on-premises Windows physical or + * virtual machines, and that the requested key will only be used in their organization; <code> false + * </code> otherwise. + * + * @param isEligible the isEligible value to set. + * @return the MultipleActivationKeyProperties object itself. + */ + public MultipleActivationKeyProperties withIsEligible(Boolean isEligible) { + this.isEligible = isEligible; + return this; + } + + /** + * Get the provisioningState property: The provisioningState property. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/OperationInner.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/OperationInner.java new file mode 100644 index 000000000000..94146ccbdabb --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/OperationInner.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.windowsesu.models.OperationDisplay; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** REST API operation details. */ +@Fluent +public final class OperationInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationInner.class); + + /* + * Name of the operation. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * Meta data about operation used for display in portal. + */ + @JsonProperty(value = "display") + private OperationDisplay display; + + /** + * Get the name property: Name of the operation. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the display property: Meta data about operation used for display in portal. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the display property: Meta data about operation used for display in portal. + * + * @param display the display value to set. + * @return the OperationInner object itself. + */ + public OperationInner withDisplay(OperationDisplay display) { + this.display = display; + 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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/package-info.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/models/package-info.java new file mode 100644 index 000000000000..461255dddf60 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/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 Windowsesu. Manage Multi-Access Keys (MAK) that enable Windows Extended + * Security Updates (ESU). + */ +package com.azure.resourcemanager.windowsesu.fluent.models; diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/package-info.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/fluent/package-info.java new file mode 100644 index 000000000000..ad7dbfd6ab66 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/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 Windowsesu. Manage Multi-Access Keys (MAK) that enable Windows Extended + * Security Updates (ESU). + */ +package com.azure.resourcemanager.windowsesu.fluent; diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/MultipleActivationKeyImpl.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/MultipleActivationKeyImpl.java new file mode 100644 index 000000000000..a73cefd0cabd --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/MultipleActivationKeyImpl.java @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.implementation; + +import com.azure.core.management.Region; +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsesu.fluent.models.MultipleActivationKeyInner; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKey; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKeyUpdate; +import com.azure.resourcemanager.windowsesu.models.OsType; +import com.azure.resourcemanager.windowsesu.models.ProvisioningState; +import com.azure.resourcemanager.windowsesu.models.SupportType; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.Map; + +public final class MultipleActivationKeyImpl + implements MultipleActivationKey, MultipleActivationKey.Definition, MultipleActivationKey.Update { + private MultipleActivationKeyInner innerObject; + + private final com.azure.resourcemanager.windowsesu.WindowsesuManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public String multipleActivationKey() { + return this.innerModel().multipleActivationKey(); + } + + public OffsetDateTime expirationDate() { + return this.innerModel().expirationDate(); + } + + public OsType osType() { + return this.innerModel().osType(); + } + + public SupportType supportType() { + return this.innerModel().supportType(); + } + + public Integer installedServerNumber() { + return this.innerModel().installedServerNumber(); + } + + public String agreementNumber() { + return this.innerModel().agreementNumber(); + } + + public Boolean isEligible() { + return this.innerModel().isEligible(); + } + + public ProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public MultipleActivationKeyInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.windowsesu.WindowsesuManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String multipleActivationKeyName; + + private MultipleActivationKeyUpdate updateMultipleActivationKey; + + public MultipleActivationKeyImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public MultipleActivationKey create() { + this.innerObject = + serviceManager + .serviceClient() + .getMultipleActivationKeys() + .create(resourceGroupName, multipleActivationKeyName, this.innerModel(), Context.NONE); + return this; + } + + public MultipleActivationKey create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getMultipleActivationKeys() + .create(resourceGroupName, multipleActivationKeyName, this.innerModel(), context); + return this; + } + + MultipleActivationKeyImpl(String name, com.azure.resourcemanager.windowsesu.WindowsesuManager serviceManager) { + this.innerObject = new MultipleActivationKeyInner(); + this.serviceManager = serviceManager; + this.multipleActivationKeyName = name; + } + + public MultipleActivationKeyImpl update() { + this.updateMultipleActivationKey = new MultipleActivationKeyUpdate(); + return this; + } + + public MultipleActivationKey apply() { + this.innerObject = + serviceManager + .serviceClient() + .getMultipleActivationKeys() + .updateWithResponse( + resourceGroupName, multipleActivationKeyName, updateMultipleActivationKey, Context.NONE) + .getValue(); + return this; + } + + public MultipleActivationKey apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getMultipleActivationKeys() + .updateWithResponse(resourceGroupName, multipleActivationKeyName, updateMultipleActivationKey, context) + .getValue(); + return this; + } + + MultipleActivationKeyImpl( + MultipleActivationKeyInner innerObject, com.azure.resourcemanager.windowsesu.WindowsesuManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.multipleActivationKeyName = Utils.getValueFromIdByName(innerObject.id(), "multipleActivationKeys"); + } + + public MultipleActivationKey refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getMultipleActivationKeys() + .getByResourceGroupWithResponse(resourceGroupName, multipleActivationKeyName, Context.NONE) + .getValue(); + return this; + } + + public MultipleActivationKey refresh(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getMultipleActivationKeys() + .getByResourceGroupWithResponse(resourceGroupName, multipleActivationKeyName, context) + .getValue(); + return this; + } + + public MultipleActivationKeyImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public MultipleActivationKeyImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public MultipleActivationKeyImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateMultipleActivationKey.withTags(tags); + return this; + } + } + + public MultipleActivationKeyImpl withOsType(OsType osType) { + this.innerModel().withOsType(osType); + return this; + } + + public MultipleActivationKeyImpl withSupportType(SupportType supportType) { + this.innerModel().withSupportType(supportType); + return this; + } + + public MultipleActivationKeyImpl withInstalledServerNumber(Integer installedServerNumber) { + this.innerModel().withInstalledServerNumber(installedServerNumber); + return this; + } + + public MultipleActivationKeyImpl withAgreementNumber(String agreementNumber) { + this.innerModel().withAgreementNumber(agreementNumber); + return this; + } + + public MultipleActivationKeyImpl withIsEligible(Boolean isEligible) { + this.innerModel().withIsEligible(isEligible); + return this; + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/MultipleActivationKeysClientImpl.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/MultipleActivationKeysClientImpl.java new file mode 100644 index 000000000000..d31e10abbaec --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/MultipleActivationKeysClientImpl.java @@ -0,0 +1,1408 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.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.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.windowsesu.fluent.MultipleActivationKeysClient; +import com.azure.resourcemanager.windowsesu.fluent.models.MultipleActivationKeyInner; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKeyList; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKeyUpdate; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in MultipleActivationKeysClient. */ +public final class MultipleActivationKeysClientImpl implements MultipleActivationKeysClient { + private final ClientLogger logger = new ClientLogger(MultipleActivationKeysClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final MultipleActivationKeysService service; + + /** The service client containing this operation class. */ + private final WindowsesuImpl client; + + /** + * Initializes an instance of MultipleActivationKeysClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + MultipleActivationKeysClientImpl(WindowsesuImpl client) { + this.service = + RestProxy + .create(MultipleActivationKeysService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for WindowsesuMultipleActivationKeys to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "WindowsesuMultipleAc") + private interface MultipleActivationKeysService { + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.WindowsESU/multipleActivationKeys") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsESU" + + "/multipleActivationKeys") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsESU" + + "/multipleActivationKeys/{multipleActivationKeyName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @PathParam("multipleActivationKeyName") String multipleActivationKeyName, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsESU" + + "/multipleActivationKeys/{multipleActivationKeyName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> create( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @PathParam("multipleActivationKeyName") String multipleActivationKeyName, + @BodyParam("application/json") MultipleActivationKeyInner multipleActivationKey, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsESU" + + "/multipleActivationKeys/{multipleActivationKeyName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @PathParam("multipleActivationKeyName") String multipleActivationKeyName, + @BodyParam("application/json") MultipleActivationKeyUpdate multipleActivationKey, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsESU" + + "/multipleActivationKeys/{multipleActivationKeyName}") + @ExpectedResponses({200, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @PathParam("multipleActivationKeyName") String multipleActivationKeyName, + @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); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * List all Multiple Activation Keys (MAK) created for a subscription. + * + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + 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 + .list( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + 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 Multiple Activation Keys (MAK) created for a subscription. + * + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + 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 + .list( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * List all Multiple Activation Keys (MAK) created for a subscription. + * + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List all Multiple Activation Keys (MAK) created for a subscription. + * + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List all Multiple Activation Keys (MAK) created for a subscription. + * + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List all Multiple Activation Keys (MAK) created for a subscription. + * + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * List all Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync( + String resourceGroupName) { + 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + 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 Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync( + String resourceGroupName, 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * List all Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List all Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * List all Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * List all Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Get a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 MAK key. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String multipleActivationKeyName) { + 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (multipleActivationKeyName == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter multipleActivationKeyName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + multipleActivationKeyName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 MAK key. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String multipleActivationKeyName, 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (multipleActivationKeyName == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter multipleActivationKeyName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + multipleActivationKeyName, + accept, + context); + } + + /** + * Get a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 MAK key. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync( + String resourceGroupName, String multipleActivationKeyName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, multipleActivationKeyName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 MAK key. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MultipleActivationKeyInner getByResourceGroup(String resourceGroupName, String multipleActivationKeyName) { + return getByResourceGroupAsync(resourceGroupName, multipleActivationKeyName).block(); + } + + /** + * Get a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 MAK key. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse( + String resourceGroupName, String multipleActivationKeyName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, multipleActivationKeyName, context).block(); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyInner multipleActivationKey) { + 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (multipleActivationKeyName == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter multipleActivationKeyName is required and cannot be null.")); + } + if (multipleActivationKey == null) { + return Mono + .error(new IllegalArgumentException("Parameter multipleActivationKey is required and cannot be null.")); + } else { + multipleActivationKey.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .create( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + multipleActivationKeyName, + multipleActivationKey, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyInner multipleActivationKey, + 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (multipleActivationKeyName == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter multipleActivationKeyName is required and cannot be null.")); + } + if (multipleActivationKey == null) { + return Mono + .error(new IllegalArgumentException("Parameter multipleActivationKey is required and cannot be null.")); + } else { + multipleActivationKey.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .create( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + multipleActivationKeyName, + multipleActivationKey, + accept, + context); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, MultipleActivationKeyInner> beginCreateAsync( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyInner multipleActivationKey) { + Mono>> mono = + createWithResponseAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + MultipleActivationKeyInner.class, + MultipleActivationKeyInner.class, + this.client.getContext()); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, MultipleActivationKeyInner> beginCreateAsync( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyInner multipleActivationKey, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono = + createWithResponseAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey, context); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + MultipleActivationKeyInner.class, + MultipleActivationKeyInner.class, + context); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, MultipleActivationKeyInner> beginCreate( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyInner multipleActivationKey) { + return beginCreateAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey).getSyncPoller(); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, MultipleActivationKeyInner> beginCreate( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyInner multipleActivationKey, + Context context) { + return beginCreateAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey, context) + .getSyncPoller(); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyInner multipleActivationKey) { + return beginCreateAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyInner multipleActivationKey, + Context context) { + return beginCreateAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MultipleActivationKeyInner create( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyInner multipleActivationKey) { + return createAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey).block(); + } + + /** + * Create a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MultipleActivationKeyInner create( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyInner multipleActivationKey, + Context context) { + return createAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey, context).block(); + } + + /** + * Update a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyUpdate multipleActivationKey) { + 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (multipleActivationKeyName == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter multipleActivationKeyName is required and cannot be null.")); + } + if (multipleActivationKey == null) { + return Mono + .error(new IllegalArgumentException("Parameter multipleActivationKey is required and cannot be null.")); + } else { + multipleActivationKey.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + multipleActivationKeyName, + multipleActivationKey, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyUpdate multipleActivationKey, + 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (multipleActivationKeyName == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter multipleActivationKeyName is required and cannot be null.")); + } + if (multipleActivationKey == null) { + return Mono + .error(new IllegalArgumentException("Parameter multipleActivationKey is required and cannot be null.")); + } else { + multipleActivationKey.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + multipleActivationKeyName, + multipleActivationKey, + accept, + context); + } + + /** + * Update a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyUpdate multipleActivationKey) { + return updateWithResponseAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Update a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MultipleActivationKeyInner update( + String resourceGroupName, String multipleActivationKeyName, MultipleActivationKeyUpdate multipleActivationKey) { + return updateAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey).block(); + } + + /** + * Update a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @param multipleActivationKey Details of the MAK key. + * @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 mAK key details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String resourceGroupName, + String multipleActivationKeyName, + MultipleActivationKeyUpdate multipleActivationKey, + Context context) { + return updateWithResponseAsync(resourceGroupName, multipleActivationKeyName, multipleActivationKey, context) + .block(); + } + + /** + * Delete a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 resourceGroupName, String multipleActivationKeyName) { + 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (multipleActivationKeyName == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter multipleActivationKeyName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + multipleActivationKeyName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 resourceGroupName, String multipleActivationKeyName, 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.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (multipleActivationKeyName == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter multipleActivationKeyName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + multipleActivationKeyName, + accept, + context); + } + + /** + * Delete a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 resourceGroupName, String multipleActivationKeyName) { + return deleteWithResponseAsync(resourceGroupName, multipleActivationKeyName) + .flatMap((Response res) -> Mono.empty()); + } + + /** + * Delete a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 resourceGroupName, String multipleActivationKeyName) { + deleteAsync(resourceGroupName, multipleActivationKeyName).block(); + } + + /** + * Delete a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 resourceGroupName, String multipleActivationKeyName, Context context) { + return deleteWithResponseAsync(resourceGroupName, multipleActivationKeyName, 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 MAK keys. + */ + @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 MAK keys. + */ + @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)); + } + + /** + * 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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(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.listByResourceGroupNext(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 MAK keys. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync( + 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 + .listByResourceGroupNext(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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/MultipleActivationKeysImpl.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/MultipleActivationKeysImpl.java new file mode 100644 index 000000000000..0e7cec74b0be --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/MultipleActivationKeysImpl.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.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.windowsesu.fluent.MultipleActivationKeysClient; +import com.azure.resourcemanager.windowsesu.fluent.models.MultipleActivationKeyInner; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKey; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKeys; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class MultipleActivationKeysImpl implements MultipleActivationKeys { + @JsonIgnore private final ClientLogger logger = new ClientLogger(MultipleActivationKeysImpl.class); + + private final MultipleActivationKeysClient innerClient; + + private final com.azure.resourcemanager.windowsesu.WindowsesuManager serviceManager; + + public MultipleActivationKeysImpl( + MultipleActivationKeysClient innerClient, + com.azure.resourcemanager.windowsesu.WindowsesuManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new MultipleActivationKeyImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new MultipleActivationKeyImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new MultipleActivationKeyImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = + this.serviceClient().listByResourceGroup(resourceGroupName, context); + return Utils.mapPage(inner, inner1 -> new MultipleActivationKeyImpl(inner1, this.manager())); + } + + public MultipleActivationKey getByResourceGroup(String resourceGroupName, String multipleActivationKeyName) { + MultipleActivationKeyInner inner = + this.serviceClient().getByResourceGroup(resourceGroupName, multipleActivationKeyName); + if (inner != null) { + return new MultipleActivationKeyImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getByResourceGroupWithResponse( + String resourceGroupName, String multipleActivationKeyName, Context context) { + Response inner = + this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, multipleActivationKeyName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new MultipleActivationKeyImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String multipleActivationKeyName) { + this.serviceClient().delete(resourceGroupName, multipleActivationKeyName); + } + + public Response deleteWithResponse( + String resourceGroupName, String multipleActivationKeyName, Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, multipleActivationKeyName, context); + } + + public MultipleActivationKey getById(String id) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String multipleActivationKeyName = Utils.getValueFromIdByName(id, "multipleActivationKeys"); + if (multipleActivationKeyName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'multipleActivationKeys'.", + id))); + } + return this + .getByResourceGroupWithResponse(resourceGroupName, multipleActivationKeyName, Context.NONE) + .getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String multipleActivationKeyName = Utils.getValueFromIdByName(id, "multipleActivationKeys"); + if (multipleActivationKeyName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'multipleActivationKeys'.", + id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, multipleActivationKeyName, context); + } + + public void deleteById(String id) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String multipleActivationKeyName = Utils.getValueFromIdByName(id, "multipleActivationKeys"); + if (multipleActivationKeyName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'multipleActivationKeys'.", + id))); + } + this.deleteWithResponse(resourceGroupName, multipleActivationKeyName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String multipleActivationKeyName = Utils.getValueFromIdByName(id, "multipleActivationKeys"); + if (multipleActivationKeyName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'multipleActivationKeys'.", + id))); + } + return this.deleteWithResponse(resourceGroupName, multipleActivationKeyName, context); + } + + private MultipleActivationKeysClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.windowsesu.WindowsesuManager manager() { + return this.serviceManager; + } + + public MultipleActivationKeyImpl define(String name) { + return new MultipleActivationKeyImpl(name, this.manager()); + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/OperationImpl.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/OperationImpl.java new file mode 100644 index 000000000000..8f9e956fd612 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/OperationImpl.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.windowsesu.implementation; + +import com.azure.resourcemanager.windowsesu.fluent.models.OperationInner; +import com.azure.resourcemanager.windowsesu.models.Operation; +import com.azure.resourcemanager.windowsesu.models.OperationDisplay; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.windowsesu.WindowsesuManager serviceManager; + + OperationImpl(OperationInner innerObject, com.azure.resourcemanager.windowsesu.WindowsesuManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.windowsesu.WindowsesuManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/OperationsClientImpl.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..5cc90e80a33d --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/OperationsClientImpl.java @@ -0,0 +1,269 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.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.windowsesu.fluent.OperationsClient; +import com.azure.resourcemanager.windowsesu.fluent.models.OperationInner; +import com.azure.resourcemanager.windowsesu.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 WindowsesuImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(WindowsesuImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for WindowsesuOperations to be used by the proxy service to perform REST + * calls. + */ + @Host("{$host}") + @ServiceInterface(name = "WindowsesuOperations") + private interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.WindowsESU/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * List all available Windows.ESU provider operations. + * + * @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 available REST API operations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List all available Windows.ESU provider operations. + * + * @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 available REST API operations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * List all available Windows.ESU provider operations. + * + * @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 available REST API operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List all available Windows.ESU provider operations. + * + * @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 available REST API operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List all available Windows.ESU provider operations. + * + * @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 available REST API operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List all available Windows.ESU provider operations. + * + * @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 available REST API operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of available REST API 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 of available REST API 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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/OperationsImpl.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/OperationsImpl.java new file mode 100644 index 000000000000..8c443dccead2 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/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.windowsesu.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.windowsesu.fluent.OperationsClient; +import com.azure.resourcemanager.windowsesu.fluent.models.OperationInner; +import com.azure.resourcemanager.windowsesu.models.Operation; +import com.azure.resourcemanager.windowsesu.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.windowsesu.WindowsesuManager serviceManager; + + public OperationsImpl( + OperationsClient innerClient, com.azure.resourcemanager.windowsesu.WindowsesuManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.windowsesu.WindowsesuManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/Utils.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/Utils.java new file mode 100644 index 000000000000..eabfada57a40 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/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.windowsesu.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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/WindowsesuBuilder.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/WindowsesuBuilder.java new file mode 100644 index 000000000000..fac58a1df70f --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/WindowsesuBuilder.java @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.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 WindowsesuImpl type. */ +@ServiceClientBuilder(serviceClients = {WindowsesuImpl.class}) +public final class WindowsesuBuilder { + /* + * The ID of the target subscription. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. + * + * @param subscriptionId the subscriptionId value. + * @return the WindowsesuBuilder. + */ + public WindowsesuBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the WindowsesuBuilder. + */ + public WindowsesuBuilder 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 WindowsesuBuilder. + */ + public WindowsesuBuilder 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 WindowsesuBuilder. + */ + public WindowsesuBuilder 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 WindowsesuBuilder. + */ + public WindowsesuBuilder 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 WindowsesuBuilder. + */ + public WindowsesuBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of WindowsesuImpl with the provided parameters. + * + * @return an instance of WindowsesuImpl. + */ + public WindowsesuImpl 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(); + } + WindowsesuImpl client = + new WindowsesuImpl(pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint); + return client; + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/WindowsesuImpl.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/WindowsesuImpl.java new file mode 100644 index 000000000000..0ec0ee152602 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/WindowsesuImpl.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.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.windowsesu.fluent.MultipleActivationKeysClient; +import com.azure.resourcemanager.windowsesu.fluent.OperationsClient; +import com.azure.resourcemanager.windowsesu.fluent.Windowsesu; +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 WindowsesuImpl type. */ +@ServiceClient(builder = WindowsesuBuilder.class) +public final class WindowsesuImpl implements Windowsesu { + private final ClientLogger logger = new ClientLogger(WindowsesuImpl.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 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; + } + + /** The MultipleActivationKeysClient object to access its operations. */ + private final MultipleActivationKeysClient multipleActivationKeys; + + /** + * Gets the MultipleActivationKeysClient object to access its operations. + * + * @return the MultipleActivationKeysClient object. + */ + public MultipleActivationKeysClient getMultipleActivationKeys() { + return this.multipleActivationKeys; + } + + /** + * Initializes an instance of Windowsesu 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. + */ + WindowsesuImpl( + 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-09-16-preview"; + this.operations = new OperationsClientImpl(this); + this.multipleActivationKeys = new MultipleActivationKeysClientImpl(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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/package-info.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/implementation/package-info.java new file mode 100644 index 000000000000..c9262077ec04 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/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 Windowsesu. Manage Multi-Access Keys (MAK) that enable Windows Extended + * Security Updates (ESU). + */ +package com.azure.resourcemanager.windowsesu.implementation; diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKey.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKey.java new file mode 100644 index 000000000000..7f0b0f792e24 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKey.java @@ -0,0 +1,311 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.models; + +import com.azure.core.management.Region; +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsesu.fluent.models.MultipleActivationKeyInner; +import java.time.OffsetDateTime; +import java.util.Map; + +/** An immutable client-side representation of MultipleActivationKey. */ +public interface MultipleActivationKey { + /** + * 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 location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the multipleActivationKey property: MAK 5x5 key. + * + * @return the multipleActivationKey value. + */ + String multipleActivationKey(); + + /** + * Gets the expirationDate property: End of support of security updates activated by the MAK key. + * + * @return the expirationDate value. + */ + OffsetDateTime expirationDate(); + + /** + * Gets the osType property: Type of OS for which the key is requested. + * + * @return the osType value. + */ + OsType osType(); + + /** + * Gets the supportType property: Type of support. + * + * @return the supportType value. + */ + SupportType supportType(); + + /** + * Gets the installedServerNumber property: Number of activations/servers using the MAK key. + * + * @return the installedServerNumber value. + */ + Integer installedServerNumber(); + + /** + * Gets the agreementNumber property: Agreement number under which the key is requested. + * + * @return the agreementNumber value. + */ + String agreementNumber(); + + /** + * Gets the isEligible property: <code> true </code> if user has eligible on-premises Windows physical + * or virtual machines, and that the requested key will only be used in their organization; <code> false + * </code> otherwise. + * + * @return the isEligible value. + */ + Boolean isEligible(); + + /** + * Gets the provisioningState property: The provisioningState property. + * + * @return the provisioningState value. + */ + ProvisioningState provisioningState(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the inner com.azure.resourcemanager.windowsesu.fluent.models.MultipleActivationKeyInner object. + * + * @return the inner object. + */ + MultipleActivationKeyInner innerModel(); + + /** The entirety of the MultipleActivationKey definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, + DefinitionStages.WithCreate { + } + /** The MultipleActivationKey definition stages. */ + interface DefinitionStages { + /** The first stage of the MultipleActivationKey definition. */ + interface Blank extends WithLocation { + } + /** The stage of the MultipleActivationKey definition allowing to specify location. */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + /** The stage of the MultipleActivationKey definition allowing to specify parent resource. */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + /** + * The stage of the MultipleActivationKey definition which contains all the minimum required properties for the + * resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate + extends DefinitionStages.WithTags, + DefinitionStages.WithOsType, + DefinitionStages.WithSupportType, + DefinitionStages.WithInstalledServerNumber, + DefinitionStages.WithAgreementNumber, + DefinitionStages.WithIsEligible { + /** + * Executes the create request. + * + * @return the created resource. + */ + MultipleActivationKey create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + MultipleActivationKey create(Context context); + } + /** The stage of the MultipleActivationKey definition allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + /** The stage of the MultipleActivationKey definition allowing to specify osType. */ + interface WithOsType { + /** + * Specifies the osType property: Type of OS for which the key is requested.. + * + * @param osType Type of OS for which the key is requested. + * @return the next definition stage. + */ + WithCreate withOsType(OsType osType); + } + /** The stage of the MultipleActivationKey definition allowing to specify supportType. */ + interface WithSupportType { + /** + * Specifies the supportType property: Type of support. + * + * @param supportType Type of support. + * @return the next definition stage. + */ + WithCreate withSupportType(SupportType supportType); + } + /** The stage of the MultipleActivationKey definition allowing to specify installedServerNumber. */ + interface WithInstalledServerNumber { + /** + * Specifies the installedServerNumber property: Number of activations/servers using the MAK key.. + * + * @param installedServerNumber Number of activations/servers using the MAK key. + * @return the next definition stage. + */ + WithCreate withInstalledServerNumber(Integer installedServerNumber); + } + /** The stage of the MultipleActivationKey definition allowing to specify agreementNumber. */ + interface WithAgreementNumber { + /** + * Specifies the agreementNumber property: Agreement number under which the key is requested.. + * + * @param agreementNumber Agreement number under which the key is requested. + * @return the next definition stage. + */ + WithCreate withAgreementNumber(String agreementNumber); + } + /** The stage of the MultipleActivationKey definition allowing to specify isEligible. */ + interface WithIsEligible { + /** + * Specifies the isEligible property: <code> true </code> if user has eligible on-premises + * Windows physical or virtual machines, and that the requested key will only be used in their organization; + * <code> false </code> otherwise.. + * + * @param isEligible <code> true </code> if user has eligible on-premises Windows physical or + * virtual machines, and that the requested key will only be used in their organization; <code> + * false </code> otherwise. + * @return the next definition stage. + */ + WithCreate withIsEligible(Boolean isEligible); + } + } + /** + * Begins update for the MultipleActivationKey resource. + * + * @return the stage of resource update. + */ + MultipleActivationKey.Update update(); + + /** The template for MultipleActivationKey update. */ + interface Update extends UpdateStages.WithTags { + /** + * Executes the update request. + * + * @return the updated resource. + */ + MultipleActivationKey apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + MultipleActivationKey apply(Context context); + } + /** The MultipleActivationKey update stages. */ + interface UpdateStages { + /** The stage of the MultipleActivationKey update allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + MultipleActivationKey refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + MultipleActivationKey refresh(Context context); +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKeyList.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKeyList.java new file mode 100644 index 000000000000..2722cdd4ab7b --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKeyList.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.windowsesu.fluent.models.MultipleActivationKeyInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** List of MAK keys. */ +@Fluent +public final class MultipleActivationKeyList { + @JsonIgnore private final ClientLogger logger = new ClientLogger(MultipleActivationKeyList.class); + + /* + * List of MAK keys. + */ + @JsonProperty(value = "value") + private List value; + + /* + * Link to the next page of resources. + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** + * Get the value property: List of MAK keys. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of MAK keys. + * + * @param value the value value to set. + * @return the MultipleActivationKeyList object itself. + */ + public MultipleActivationKeyList withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: Link to the next page of resources. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * 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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKeyUpdate.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKeyUpdate.java new file mode 100644 index 000000000000..08c9d0b54849 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKeyUpdate.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.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.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** MAK key details. */ +@Fluent +public final class MultipleActivationKeyUpdate { + @JsonIgnore private final ClientLogger logger = new ClientLogger(MultipleActivationKeyUpdate.class); + + /* + * Resource tags. + */ + @JsonProperty(value = "tags") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map tags; + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the MultipleActivationKeyUpdate object itself. + */ + public MultipleActivationKeyUpdate withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKeys.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKeys.java new file mode 100644 index 000000000000..d554df7db3bf --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/MultipleActivationKeys.java @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.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 MultipleActivationKeys. */ +public interface MultipleActivationKeys { + /** + * List all Multiple Activation Keys (MAK) created for a subscription. + * + * @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 of MAK keys. + */ + PagedIterable list(); + + /** + * List all Multiple Activation Keys (MAK) created for a subscription. + * + * @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 of MAK keys. + */ + PagedIterable list(Context context); + + /** + * List all Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 of MAK keys. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List all Multiple Activation Keys (MAK) in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 of MAK keys. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 MAK key. + */ + MultipleActivationKey getByResourceGroup(String resourceGroupName, String multipleActivationKeyName); + + /** + * Get a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 MAK key. + */ + Response getByResourceGroupWithResponse( + String resourceGroupName, String multipleActivationKeyName, Context context); + + /** + * Delete a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 resourceGroupName, String multipleActivationKeyName); + + /** + * Delete a MAK key. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param multipleActivationKeyName The name of the MAK key. + * @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 resourceGroupName, String multipleActivationKeyName, Context context); + + /** + * Get a MAK key. + * + * @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 MAK key. + */ + MultipleActivationKey getById(String id); + + /** + * Get a MAK key. + * + * @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 MAK key. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a MAK key. + * + * @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); + + /** + * Delete a MAK key. + * + * @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 MultipleActivationKey resource. + * + * @param name resource name. + * @return the first stage of the new MultipleActivationKey definition. + */ + MultipleActivationKey.DefinitionStages.Blank define(String name); +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/Operation.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/Operation.java new file mode 100644 index 000000000000..f7fd262fde93 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/Operation.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.models; + +import com.azure.resourcemanager.windowsesu.fluent.models.OperationInner; + +/** An immutable client-side representation of Operation. */ +public interface Operation { + /** + * Gets the name property: Name of the operation. + * + * @return the name value. + */ + String name(); + + /** + * Gets the display property: Meta data about operation used for display in portal. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the inner com.azure.resourcemanager.windowsesu.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/OperationDisplay.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/OperationDisplay.java new file mode 100644 index 000000000000..a910b715cc85 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/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.windowsesu.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; + +/** Meta data about operation used for display in portal. */ +@Fluent +public final class OperationDisplay { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationDisplay.class); + + /* + * The provider property. + */ + @JsonProperty(value = "provider") + private String provider; + + /* + * The resource property. + */ + @JsonProperty(value = "resource") + private String resource; + + /* + * The operation property. + */ + @JsonProperty(value = "operation") + private String operation; + + /* + * The description property. + */ + @JsonProperty(value = "description") + private String description; + + /** + * Get the provider property: The provider property. + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider property: The provider property. + * + * @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: The resource property. + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Set the resource property: The resource property. + * + * @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: The operation property. + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Set the operation property: The operation property. + * + * @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: The description property. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/OperationList.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/OperationList.java new file mode 100644 index 000000000000..88035aa8b76a --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/OperationList.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.windowsesu.fluent.models.OperationInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** List of available REST API operations. */ +@Fluent +public final class OperationList { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationList.class); + + /* + * List of operations. + */ + @JsonProperty(value = "value") + private List value; + + /* + * Link to the next page of resources. + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** + * Get the value property: List of operations. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of 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: Link to the next page of resources. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * 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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/Operations.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/Operations.java new file mode 100644 index 000000000000..34a62e391df8 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/Operations.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * List all available Windows.ESU provider operations. + * + * @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 of available REST API operations. + */ + PagedIterable list(); + + /** + * List all available Windows.ESU provider operations. + * + * @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 of available REST API operations. + */ + PagedIterable list(Context context); +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/OsType.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/OsType.java new file mode 100644 index 000000000000..38d675eede30 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/OsType.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.windowsesu.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for OsType. */ +public final class OsType extends ExpandableStringEnum { + /** Static value Windows7 for OsType. */ + public static final OsType WINDOWS7 = fromString("Windows7"); + + /** Static value WindowsServer2008 for OsType. */ + public static final OsType WINDOWS_SERVER2008 = fromString("WindowsServer2008"); + + /** Static value WindowsServer2008R2 for OsType. */ + public static final OsType WINDOWS_SERVER2008R2 = fromString("WindowsServer2008R2"); + + /** + * Creates or finds a OsType from its string representation. + * + * @param name a name to look for. + * @return the corresponding OsType. + */ + @JsonCreator + public static OsType fromString(String name) { + return fromString(name, OsType.class); + } + + /** @return known OsType values. */ + public static Collection values() { + return values(OsType.class); + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/ProvisioningState.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/ProvisioningState.java new file mode 100644 index 000000000000..b7b32b35513e --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/ProvisioningState.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.windowsesu.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 Failed for ProvisioningState. */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** Static value Canceled for ProvisioningState. */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** Static value Accepted for ProvisioningState. */ + public static final ProvisioningState ACCEPTED = fromString("Accepted"); + + /** Static value Provisioning for ProvisioningState. */ + public static final ProvisioningState PROVISIONING = fromString("Provisioning"); + + /** + * 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/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/SupportType.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/SupportType.java new file mode 100644 index 000000000000..4277073695f5 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/SupportType.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.windowsesu.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for SupportType. */ +public final class SupportType extends ExpandableStringEnum { + /** Static value SupplementalServicing for SupportType. */ + public static final SupportType SUPPLEMENTAL_SERVICING = fromString("SupplementalServicing"); + + /** Static value PremiumAssurance for SupportType. */ + public static final SupportType PREMIUM_ASSURANCE = fromString("PremiumAssurance"); + + /** + * Creates or finds a SupportType from its string representation. + * + * @param name a name to look for. + * @return the corresponding SupportType. + */ + @JsonCreator + public static SupportType fromString(String name) { + return fromString(name, SupportType.class); + } + + /** @return known SupportType values. */ + public static Collection values() { + return values(SupportType.class); + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/package-info.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/models/package-info.java new file mode 100644 index 000000000000..68eeb13ec811 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/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 Windowsesu. Manage Multi-Access Keys (MAK) that enable Windows Extended + * Security Updates (ESU). + */ +package com.azure.resourcemanager.windowsesu.models; diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/package-info.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/package-info.java new file mode 100644 index 000000000000..1c7c324d5c26 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/com/azure/resourcemanager/windowsesu/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 Windowsesu. Manage Multi-Access Keys (MAK) that enable Windows Extended Security + * Updates (ESU). + */ +package com.azure.resourcemanager.windowsesu; diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/module-info.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/main/java/module-info.java new file mode 100644 index 000000000000..cbceb71d37ac --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/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.windowsesu { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.windowsesu; + exports com.azure.resourcemanager.windowsesu.fluent; + exports com.azure.resourcemanager.windowsesu.fluent.models; + exports com.azure.resourcemanager.windowsesu.models; + + opens com.azure.resourcemanager.windowsesu.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.windowsesu.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysCreateSamples.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysCreateSamples.java new file mode 100644 index 000000000000..6d24be1e0efb --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysCreateSamples.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsesu.generated; + +import com.azure.resourcemanager.windowsesu.models.OsType; +import com.azure.resourcemanager.windowsesu.models.SupportType; + +/** Samples for MultipleActivationKeys Create. */ +public final class MultipleActivationKeysCreateSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/CreateMultipleActivationKey.json + */ + /** + * Sample code: CreateMultipleActivationKey. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void createMultipleActivationKey(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager + .multipleActivationKeys() + .define("server08-key-2019") + .withRegion("East US") + .withExistingResourceGroup("testgr1") + .withOsType(OsType.WINDOWS_SERVER2008) + .withSupportType(SupportType.SUPPLEMENTAL_SERVICING) + .withInstalledServerNumber(100) + .withAgreementNumber("1a2b45ag") + .withIsEligible(true) + .create(); + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysDeleteSamples.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysDeleteSamples.java new file mode 100644 index 000000000000..3d03a14e624f --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysDeleteSamples.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.windowsesu.generated; + +import com.azure.core.util.Context; + +/** Samples for MultipleActivationKeys Delete. */ +public final class MultipleActivationKeysDeleteSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/DeleteMultipleActivationKey.json + */ + /** + * Sample code: DeleteMultipleActivationKey. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void deleteMultipleActivationKey(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.multipleActivationKeys().deleteWithResponse("testgr1", "server08-key-2019", Context.NONE); + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysGetByResourceGroupSamples.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysGetByResourceGroupSamples.java new file mode 100644 index 000000000000..5d0900e4f4f1 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysGetByResourceGroupSamples.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.windowsesu.generated; + +import com.azure.core.util.Context; + +/** Samples for MultipleActivationKeys GetByResourceGroup. */ +public final class MultipleActivationKeysGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/GetMultipleActivationKey.json + */ + /** + * Sample code: GetMultipleActivationKey. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void getMultipleActivationKey(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.multipleActivationKeys().getByResourceGroupWithResponse("testgr1", "server08-key-2019", Context.NONE); + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysListByResourceGroupSamples.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysListByResourceGroupSamples.java new file mode 100644 index 000000000000..09305ddb9352 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysListByResourceGroupSamples.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.windowsesu.generated; + +import com.azure.core.util.Context; + +/** Samples for MultipleActivationKeys ListByResourceGroup. */ +public final class MultipleActivationKeysListByResourceGroupSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListMultipleActivationKeysByResourceGroup.json + */ + /** + * Sample code: ListMultipleActivationKeys. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void listMultipleActivationKeys(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.multipleActivationKeys().listByResourceGroup("testrg1", Context.NONE); + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysListSamples.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysListSamples.java new file mode 100644 index 000000000000..33bc5b969894 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysListSamples.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.windowsesu.generated; + +import com.azure.core.util.Context; + +/** Samples for MultipleActivationKeys List. */ +public final class MultipleActivationKeysListSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListMultipleActivationKeys.json + */ + /** + * Sample code: ListMultipleActivationKeys. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void listMultipleActivationKeys(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.multipleActivationKeys().list(Context.NONE); + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysUpdateSamples.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysUpdateSamples.java new file mode 100644 index 000000000000..a7c2f8721e19 --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/MultipleActivationKeysUpdateSamples.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.windowsesu.generated; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsesu.models.MultipleActivationKey; +import java.util.HashMap; +import java.util.Map; + +/** Samples for MultipleActivationKeys Update. */ +public final class MultipleActivationKeysUpdateSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/UpdateMultipleActivationKey.json + */ + /** + * Sample code: UpdateMultipleActivationKey. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void updateMultipleActivationKey(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + MultipleActivationKey resource = + manager + .multipleActivationKeys() + .getByResourceGroupWithResponse("testgr1", "server08-key-2019", Context.NONE) + .getValue(); + resource.update().withTags(mapOf("tag1", "value1", "tag2", "value2")).apply(); + } + + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/OperationsListSamples.java b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/OperationsListSamples.java new file mode 100644 index 000000000000..e1ac7ff3cd4a --- /dev/null +++ b/sdk/windowsesu/azure-resourcemanager-windowsesu/src/samples/java/com/azure/resourcemanager/windowsesu/generated/OperationsListSamples.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.windowsesu.generated; + +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListOperations.json + */ + /** + * Sample code: ListOperations. + * + * @param manager Entry point to WindowsesuManager. + */ + public static void listOperations(com.azure.resourcemanager.windowsesu.WindowsesuManager manager) { + manager.operations().list(Context.NONE); + } +} diff --git a/sdk/windowsesu/ci.yml b/sdk/windowsesu/ci.yml new file mode 100644 index 000000000000..f0b0189e2d14 --- /dev/null +++ b/sdk/windowsesu/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/windowsesu/ci.yml + - sdk/windowsesu/azure-resourcemanager-windowsesu/ + exclude: + - sdk/windowsesu/pom.xml + - sdk/windowsesu/azure-resourcemanager-windowsesu/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/windowsesu/ci.yml + - sdk/windowsesu/azure-resourcemanager-windowsesu/ + exclude: + - sdk/windowsesu/pom.xml + - sdk/windowsesu/azure-resourcemanager-windowsesu/pom.xml + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: windowsesu + Artifacts: + - name: azure-resourcemanager-windowsesu + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerwindowsesu diff --git a/sdk/windowsesu/pom.xml b/sdk/windowsesu/pom.xml new file mode 100644 index 000000000000..e76bd4ed8b89 --- /dev/null +++ b/sdk/windowsesu/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + com.azure + azure-windowsesu-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-windowsesu + + + +