diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 2ebac8f90c51..9ee320f0832d 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -397,6 +397,7 @@ com.azure.resourcemanager:azure-resourcemanager-reservations;1.0.0-beta.1;1.0.0- com.azure.resourcemanager:azure-resourcemanager-storagemover;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-containerservicefleet;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-voiceservices;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-graphservicesprod;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.2.0-beta.1 com.azure.tools:azure-sdk-build-tool;1.0.0-beta.1;1.0.0-beta.2 diff --git a/pom.xml b/pom.xml index 2c7336bffde9..d16f12bb90d8 100644 --- a/pom.xml +++ b/pom.xml @@ -82,6 +82,7 @@ sdk/fluidrelay sdk/formrecognizer sdk/frontdoor + sdk/graphservicesprod sdk/hanaonazure sdk/hardwaresecuritymodules sdk/hdinsight diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/CHANGELOG.md b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/CHANGELOG.md new file mode 100644 index 000000000000..b060bb77f0bb --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2023-03-02) + +- Azure Resource Manager graphservicesprod client library for Java. This package contains Microsoft Azure SDK for graphservicesprod Management SDK. Self service experience for Microsoft Graph metered services. Package tag package-2022-09-22-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/graphservicesprod/azure-resourcemanager-graphservicesprod/README.md b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/README.md new file mode 100644 index 000000000000..db99e22f398f --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/README.md @@ -0,0 +1,105 @@ +# Azure Resource Manager graphservicesprod client library for Java + +Azure Resource Manager graphservicesprod client library for Java. + +This package contains Microsoft Azure SDK for graphservicesprod Management SDK. Self service experience for Microsoft Graph metered services. Package tag package-2022-09-22-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-graphservicesprod;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-graphservicesprod + 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] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation. + +### Authentication + +By default, Azure Active Directory token authentication depends on correct configuration of the 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 `AZURE_SUBSCRIPTION_ID` environment variable. + +With above configuration, `azure` client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +GraphservicesprodManager manager = GraphservicesprodManager + .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/graphservicesprod/azure-resourcemanager-graphservicesprod/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide][cg]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact with any additional questions or comments. + + +[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 +[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/SAMPLE.md b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/SAMPLE.md new file mode 100644 index 000000000000..27e2c21726b1 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/SAMPLE.md @@ -0,0 +1,206 @@ +# Code snippets and samples + + +## AccountOperation + +- [CreateAndUpdate](#accountoperation_createandupdate) +- [Delete](#accountoperation_delete) +- [GetByResourceGroup](#accountoperation_getbyresourcegroup) +- [Update](#accountoperation_update) + +## Accounts + +- [List](#accounts_list) +- [ListByResourceGroup](#accounts_listbyresourcegroup) + +## Operation + +- [List](#operation_list) +### AccountOperation_CreateAndUpdate + +```java +import com.azure.resourcemanager.graphservicesprod.models.AccountResourceProperties; +import java.util.HashMap; +import java.util.Map; + +/** Samples for AccountOperation CreateAndUpdate. */ +public final class AccountOperationCreateAndUpdateSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_Create.json + */ + /** + * Sample code: Create Account resource. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void createAccountResource( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager + .accountOperations() + .define("11111111-aaaa-1111-bbbb-1111111111111") + .withRegion((String) null) + .withExistingResourceGroup("testResourceGroupGRAM") + .withProperties(new AccountResourceProperties().withApplicationId("11111111-aaaa-1111-bbbb-111111111111")) + .withTags(mapOf("tag1", "value1", "tag2", "value2")) + .create(); + } + + @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; + } +} +``` + +### AccountOperation_Delete + +```java +/** Samples for AccountOperation Delete. */ +public final class AccountOperationDeleteSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_Delete.json + */ + /** + * Sample code: Delete account resource. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void deleteAccountResource( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager + .accountOperations() + .deleteByResourceGroupWithResponse( + "testResourceGroupGRAM", "11111111-aaaa-1111-bbbb-111111111111", com.azure.core.util.Context.NONE); + } +} +``` + +### AccountOperation_GetByResourceGroup + +```java +/** Samples for AccountOperation GetByResourceGroup. */ +public final class AccountOperationGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_Get.json + */ + /** + * Sample code: Get accounts. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void getAccounts(com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager + .accountOperations() + .getByResourceGroupWithResponse( + "testResourceGroupGRAM", "11111111-aaaa-1111-bbbb-111111111111", com.azure.core.util.Context.NONE); + } +} +``` + +### AccountOperation_Update + +```java +import com.azure.resourcemanager.graphservicesprod.models.AccountResource; +import java.util.HashMap; +import java.util.Map; + +/** Samples for AccountOperation Update. */ +public final class AccountOperationUpdateSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_Update.json + */ + /** + * Sample code: Update account resource. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void updateAccountResource( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + AccountResource resource = + manager + .accountOperations() + .getByResourceGroupWithResponse( + "testResourceGroupGRAM", "11111111-aaaa-1111-bbbb-111111111111", com.azure.core.util.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; + } +} +``` + +### Accounts_List + +```java +/** Samples for Accounts List. */ +public final class AccountsListSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_List_Sub.json + */ + /** + * Sample code: Get list of accounts by subscription. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void getListOfAccountsBySubscription( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager.accounts().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Accounts_ListByResourceGroup + +```java +/** Samples for Accounts ListByResourceGroup. */ +public final class AccountsListByResourceGroupSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_List.json + */ + /** + * Sample code: Create or update account resource. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void createOrUpdateAccountResource( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager.accounts().listByResourceGroup("testResourceGroupGRAM", com.azure.core.util.Context.NONE); + } +} +``` + +### Operation_List + +```java +/** Samples for Operation List. */ +public final class OperationListSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Operations_List.json + */ + /** + * Sample code: Get list of operations. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void getListOfOperations( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/pom.xml b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/pom.xml new file mode 100644 index 000000000000..d0893a5cfb7a --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-graphservicesprod + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for graphservicesprod Management + This package contains Microsoft Azure SDK for graphservicesprod Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Self service experience for Microsoft Graph metered services. Package tag package-2022-09-22-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 + 0 + 0 + + + + com.azure + azure-core + 1.36.0 + + + com.azure + azure-core-management + 1.10.1 + + + diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/GraphservicesprodManager.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/GraphservicesprodManager.java new file mode 100644 index 000000000000..162e2c2b9ff6 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/GraphservicesprodManager.java @@ -0,0 +1,314 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod; + +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.AddHeadersFromContextPolicy; +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.RetryOptions; +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.graphservicesprod.fluent.GraphServices; +import com.azure.resourcemanager.graphservicesprod.implementation.AccountOperationsImpl; +import com.azure.resourcemanager.graphservicesprod.implementation.AccountsImpl; +import com.azure.resourcemanager.graphservicesprod.implementation.GraphServicesBuilder; +import com.azure.resourcemanager.graphservicesprod.implementation.OperationsImpl; +import com.azure.resourcemanager.graphservicesprod.models.AccountOperations; +import com.azure.resourcemanager.graphservicesprod.models.Accounts; +import com.azure.resourcemanager.graphservicesprod.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 GraphservicesprodManager. Self service experience for Microsoft Graph metered services. */ +public final class GraphservicesprodManager { + private Accounts accounts; + + private AccountOperations accountOperations; + + private Operations operations; + + private final GraphServices clientObject; + + private GraphservicesprodManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new GraphServicesBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of graphservicesprod service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the graphservicesprod service API instance. + */ + public static GraphservicesprodManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of graphservicesprod service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the graphservicesprod service API instance. + */ + public static GraphservicesprodManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new GraphservicesprodManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create GraphservicesprodManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new GraphservicesprodManager.Configurable(); + } + + /** The Configurable allowing configurations to be set. */ + public static final class Configurable { + private static 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 RetryOptions retryOptions; + 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 retry options for the HTTP pipeline retry policy. + * + *

This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' 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, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of graphservicesprod service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the graphservicesprod service API instance. + */ + public GraphservicesprodManager 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.graphservicesprod") + .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) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + 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 GraphservicesprodManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Accounts. + * + * @return Resource collection API of Accounts. + */ + public Accounts accounts() { + if (this.accounts == null) { + this.accounts = new AccountsImpl(clientObject.getAccounts(), this); + } + return accounts; + } + + /** + * Gets the resource collection API of AccountOperations. It manages AccountResource. + * + * @return Resource collection API of AccountOperations. + */ + public AccountOperations accountOperations() { + if (this.accountOperations == null) { + this.accountOperations = new AccountOperationsImpl(clientObject.getAccountOperations(), this); + } + return accountOperations; + } + + /** + * Gets the resource collection API of Operations. + * + * @return Resource collection API of Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * @return Wrapped service client GraphServices providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + */ + public GraphServices serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/AccountOperationsClient.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/AccountOperationsClient.java new file mode 100644 index 000000000000..5e4eecb4f017 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/AccountOperationsClient.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +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.graphservicesprod.fluent.models.AccountResourceInner; +import com.azure.resourcemanager.graphservicesprod.models.AccountPatchResource; + +/** An instance of this class provides access to all the operations defined in AccountOperationsClient. */ +public interface AccountOperationsClient { + /** + * Returns account resource for a given name. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return account details along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse( + String resourceGroupName, String resourceName, Context context); + + /** + * Returns account resource for a given name. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return account details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AccountResourceInner getByResourceGroup(String resourceGroupName, String resourceName); + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 {@link SyncPoller} for polling of account details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, AccountResourceInner> beginCreateAndUpdate( + String resourceGroupName, String resourceName, AccountResourceInner accountResource); + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 {@link SyncPoller} for polling of account details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, AccountResourceInner> beginCreateAndUpdate( + String resourceGroupName, String resourceName, AccountResourceInner accountResource, Context context); + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 account details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AccountResourceInner createAndUpdate( + String resourceGroupName, String resourceName, AccountResourceInner accountResource); + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 account details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AccountResourceInner createAndUpdate( + String resourceGroupName, String resourceName, AccountResourceInner accountResource, Context context); + + /** + * Update account details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account patch details. + * @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 account details along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String resourceGroupName, String resourceName, AccountPatchResource accountResource, Context context); + + /** + * Update account details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account patch details. + * @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 account details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AccountResourceInner update(String resourceGroupName, String resourceName, AccountPatchResource accountResource); + + /** + * Deletes a account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String resourceName, Context context); + + /** + * Deletes a account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String resourceName); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/AccountsClient.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/AccountsClient.java new file mode 100644 index 000000000000..7275aebfa4fd --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/AccountsClient.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.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.graphservicesprod.fluent.models.AccountResourceInner; + +/** An instance of this class provides access to all the operations defined in AccountsClient. */ +public interface AccountsClient { + /** + * Returns list of accounts apps. + * + * @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 the list of accounts as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Returns list of accounts apps. + * + * @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 the list of accounts as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Returns list of accounts belonging to 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 the list of accounts as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Returns list of accounts belonging to 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 the list of accounts as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/GraphServices.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/GraphServices.java new file mode 100644 index 000000000000..8ca94ffa3783 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/GraphServices.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for GraphServices class. */ +public interface GraphServices { + /** + * 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 AccountsClient object to access its operations. + * + * @return the AccountsClient object. + */ + AccountsClient getAccounts(); + + /** + * Gets the AccountOperationsClient object to access its operations. + * + * @return the AccountOperationsClient object. + */ + AccountOperationsClient getAccountOperations(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/OperationsClient.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/OperationsClient.java new file mode 100644 index 000000000000..43d70273a227 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/OperationsClient.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.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.graphservicesprod.fluent.models.OperationInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/models/AccountResourceInner.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/models/AccountResourceInner.java new file mode 100644 index 000000000000..6ebf3540bbdb --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/models/AccountResourceInner.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.graphservicesprod.models.AccountResourceProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** Account details. */ +@Fluent +public final class AccountResourceInner extends Resource { + /* + * Metadata pertaining to creation and last modification of the resource. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /* + * Property bag from billing account + */ + @JsonProperty(value = "properties", required = true) + private AccountResourceProperties properties; + + /** Creates an instance of AccountResourceInner class. */ + public AccountResourceInner() { + } + + /** + * Get the systemData property: Metadata pertaining to creation and last modification of the resource. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the properties property: Property bag from billing account. + * + * @return the properties value. + */ + public AccountResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: Property bag from billing account. + * + * @param properties the properties value to set. + * @return the AccountResourceInner object itself. + */ + public AccountResourceInner withProperties(AccountResourceProperties properties) { + this.properties = properties; + return this; + } + + /** {@inheritDoc} */ + @Override + public AccountResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public AccountResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException("Missing required property properties in model AccountResourceInner")); + } else { + properties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AccountResourceInner.class); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/models/OperationInner.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/models/OperationInner.java new file mode 100644 index 000000000000..06e12fd52af5 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/models/OperationInner.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.resourcemanager.graphservicesprod.models.ActionType; +import com.azure.resourcemanager.graphservicesprod.models.OperationDisplay; +import com.azure.resourcemanager.graphservicesprod.models.Origin; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * REST API Operation + * + *

Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Fluent +public final class OperationInner { + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for + * ARM/control-plane operations. + */ + @JsonProperty(value = "isDataAction", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + @JsonProperty(value = "display") + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + * value is "user,system" + */ + @JsonProperty(value = "origin", access = JsonProperty.Access.WRITE_ONLY) + private Origin origin; + + /* + * Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + @JsonProperty(value = "actionType", access = JsonProperty.Access.WRITE_ONLY) + private ActionType actionType; + + /** Creates an instance of OperationInner class. */ + public OperationInner() { + } + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for ARM/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the display property: Localized display information for this particular operation. + * + * @param display the display value to set. + * @return the OperationInner object itself. + */ + public OperationInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Enum. Indicates the action type. "Internal" refers to actions that are for internal + * only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/models/package-info.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/models/package-info.java new file mode 100644 index 000000000000..2592312d7931 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/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 GraphServices. Self service experience for Microsoft Graph metered + * services. + */ +package com.azure.resourcemanager.graphservicesprod.fluent.models; diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/package-info.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/fluent/package-info.java new file mode 100644 index 000000000000..f63a058897c7 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/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 GraphServices. Self service experience for Microsoft Graph metered + * services. + */ +package com.azure.resourcemanager.graphservicesprod.fluent; diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountOperationsClientImpl.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountOperationsClientImpl.java new file mode 100644 index 000000000000..32447355646b --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountOperationsClientImpl.java @@ -0,0 +1,840 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.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.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.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.graphservicesprod.fluent.AccountOperationsClient; +import com.azure.resourcemanager.graphservicesprod.fluent.models.AccountResourceInner; +import com.azure.resourcemanager.graphservicesprod.models.AccountPatchResource; +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 AccountOperationsClient. */ +public final class AccountOperationsClientImpl implements AccountOperationsClient { + /** The proxy service used to perform REST calls. */ + private final AccountOperationsService service; + + /** The service client containing this operation class. */ + private final GraphServicesImpl client; + + /** + * Initializes an instance of AccountOperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AccountOperationsClientImpl(GraphServicesImpl client) { + this.service = + RestProxy.create(AccountOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for GraphServicesAccountOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "GraphServicesAccount") + public interface AccountOperationsService { + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices" + + "/accounts/{resourceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("resourceName") String resourceName, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices" + + "/accounts/{resourceName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createAndUpdate( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("resourceName") String resourceName, + @BodyParam("application/json") AccountResourceInner accountResource, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices" + + "/accounts/{resourceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("resourceName") String resourceName, + @BodyParam("application/json") AccountPatchResource accountResource, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices" + + "/accounts/{resourceName}") + @ExpectedResponses({200, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("resourceName") String resourceName, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Returns account resource for a given name. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return account details along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String resourceName) { + 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 (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + resourceName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Returns account resource for a given name. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return account details along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String resourceName, 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 (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + resourceName, + accept, + context); + } + + /** + * Returns account resource for a given name. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return account details on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String resourceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, resourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Returns account resource for a given name. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return account details along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse( + String resourceGroupName, String resourceName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, resourceName, context).block(); + } + + /** + * Returns account resource for a given name. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return account details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AccountResourceInner getByResourceGroup(String resourceGroupName, String resourceName) { + return getByResourceGroupWithResponse(resourceGroupName, resourceName, Context.NONE).getValue(); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 account details along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createAndUpdateWithResponseAsync( + String resourceGroupName, String resourceName, AccountResourceInner accountResource) { + 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 (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (accountResource == null) { + return Mono + .error(new IllegalArgumentException("Parameter accountResource is required and cannot be null.")); + } else { + accountResource.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createAndUpdate( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + resourceName, + accountResource, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 account details along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createAndUpdateWithResponseAsync( + String resourceGroupName, String resourceName, AccountResourceInner accountResource, 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 (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (accountResource == null) { + return Mono + .error(new IllegalArgumentException("Parameter accountResource is required and cannot be null.")); + } else { + accountResource.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createAndUpdate( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + resourceName, + accountResource, + accept, + context); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 {@link PollerFlux} for polling of account details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, AccountResourceInner> beginCreateAndUpdateAsync( + String resourceGroupName, String resourceName, AccountResourceInner accountResource) { + Mono>> mono = + createAndUpdateWithResponseAsync(resourceGroupName, resourceName, accountResource); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + AccountResourceInner.class, + AccountResourceInner.class, + this.client.getContext()); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 {@link PollerFlux} for polling of account details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, AccountResourceInner> beginCreateAndUpdateAsync( + String resourceGroupName, String resourceName, AccountResourceInner accountResource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = + createAndUpdateWithResponseAsync(resourceGroupName, resourceName, accountResource, context); + return this + .client + .getLroResult( + mono, this.client.getHttpPipeline(), AccountResourceInner.class, AccountResourceInner.class, context); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 {@link SyncPoller} for polling of account details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, AccountResourceInner> beginCreateAndUpdate( + String resourceGroupName, String resourceName, AccountResourceInner accountResource) { + return this.beginCreateAndUpdateAsync(resourceGroupName, resourceName, accountResource).getSyncPoller(); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 {@link SyncPoller} for polling of account details. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, AccountResourceInner> beginCreateAndUpdate( + String resourceGroupName, String resourceName, AccountResourceInner accountResource, Context context) { + return this + .beginCreateAndUpdateAsync(resourceGroupName, resourceName, accountResource, context) + .getSyncPoller(); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 account details on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAndUpdateAsync( + String resourceGroupName, String resourceName, AccountResourceInner accountResource) { + return beginCreateAndUpdateAsync(resourceGroupName, resourceName, accountResource) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 account details on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAndUpdateAsync( + String resourceGroupName, String resourceName, AccountResourceInner accountResource, Context context) { + return beginCreateAndUpdateAsync(resourceGroupName, resourceName, accountResource, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 account details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AccountResourceInner createAndUpdate( + String resourceGroupName, String resourceName, AccountResourceInner accountResource) { + return createAndUpdateAsync(resourceGroupName, resourceName, accountResource).block(); + } + + /** + * Create or update account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @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 account details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AccountResourceInner createAndUpdate( + String resourceGroupName, String resourceName, AccountResourceInner accountResource, Context context) { + return createAndUpdateAsync(resourceGroupName, resourceName, accountResource, context).block(); + } + + /** + * Update account details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account patch details. + * @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 account details along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, String resourceName, AccountPatchResource accountResource) { + 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 (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (accountResource == null) { + return Mono + .error(new IllegalArgumentException("Parameter accountResource is required and cannot be null.")); + } else { + accountResource.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + resourceName, + accountResource, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update account details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account patch details. + * @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 account details along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, String resourceName, AccountPatchResource accountResource, 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 (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + if (accountResource == null) { + return Mono + .error(new IllegalArgumentException("Parameter accountResource is required and cannot be null.")); + } else { + accountResource.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + resourceName, + accountResource, + accept, + context); + } + + /** + * Update account details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account patch details. + * @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 account details on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, String resourceName, AccountPatchResource accountResource) { + return updateWithResponseAsync(resourceGroupName, resourceName, accountResource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update account details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account patch details. + * @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 account details along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String resourceGroupName, String resourceName, AccountPatchResource accountResource, Context context) { + return updateWithResponseAsync(resourceGroupName, resourceName, accountResource, context).block(); + } + + /** + * Update account details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account patch details. + * @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 account details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AccountResourceInner update( + String resourceGroupName, String resourceName, AccountPatchResource accountResource) { + return updateWithResponse(resourceGroupName, resourceName, accountResource, Context.NONE).getValue(); + } + + /** + * Deletes a account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String resourceName) { + 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 (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + resourceName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Deletes a account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync( + String resourceGroupName, String resourceName, 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 (resourceName == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .delete( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + resourceName, + accept, + context); + } + + /** + * Deletes a account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String resourceName) { + return deleteWithResponseAsync(resourceGroupName, resourceName).flatMap(ignored -> Mono.empty()); + } + + /** + * Deletes a account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String resourceName, Context context) { + return deleteWithResponseAsync(resourceGroupName, resourceName, context).block(); + } + + /** + * Deletes a account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String resourceName) { + deleteWithResponse(resourceGroupName, resourceName, Context.NONE); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountOperationsImpl.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountOperationsImpl.java new file mode 100644 index 000000000000..78554e811848 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountOperationsImpl.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.implementation; + +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.graphservicesprod.fluent.AccountOperationsClient; +import com.azure.resourcemanager.graphservicesprod.fluent.models.AccountResourceInner; +import com.azure.resourcemanager.graphservicesprod.models.AccountOperations; +import com.azure.resourcemanager.graphservicesprod.models.AccountResource; + +public final class AccountOperationsImpl implements AccountOperations { + private static final ClientLogger LOGGER = new ClientLogger(AccountOperationsImpl.class); + + private final AccountOperationsClient innerClient; + + private final com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager serviceManager; + + public AccountOperationsImpl( + AccountOperationsClient innerClient, + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse( + String resourceGroupName, String resourceName, Context context) { + Response inner = + this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, resourceName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new AccountResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public AccountResource getByResourceGroup(String resourceGroupName, String resourceName) { + AccountResourceInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, resourceName); + if (inner != null) { + return new AccountResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteByResourceGroupWithResponse( + String resourceGroupName, String resourceName, Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, resourceName, context); + } + + public void deleteByResourceGroup(String resourceGroupName, String resourceName) { + this.serviceClient().delete(resourceGroupName, resourceName); + } + + public AccountResource 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 resourceName = Utils.getValueFromIdByName(id, "accounts"); + if (resourceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'accounts'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, resourceName, 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 resourceName = Utils.getValueFromIdByName(id, "accounts"); + if (resourceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'accounts'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, resourceName, 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 resourceName = Utils.getValueFromIdByName(id, "accounts"); + if (resourceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'accounts'.", id))); + } + this.deleteByResourceGroupWithResponse(resourceGroupName, resourceName, 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 resourceName = Utils.getValueFromIdByName(id, "accounts"); + if (resourceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'accounts'.", id))); + } + return this.deleteByResourceGroupWithResponse(resourceGroupName, resourceName, context); + } + + private AccountOperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager() { + return this.serviceManager; + } + + public AccountResourceImpl define(String name) { + return new AccountResourceImpl(name, this.manager()); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountResourceImpl.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountResourceImpl.java new file mode 100644 index 000000000000..23292da9c4ee --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountResourceImpl.java @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.graphservicesprod.fluent.models.AccountResourceInner; +import com.azure.resourcemanager.graphservicesprod.models.AccountPatchResource; +import com.azure.resourcemanager.graphservicesprod.models.AccountResource; +import com.azure.resourcemanager.graphservicesprod.models.AccountResourceProperties; +import java.util.Collections; +import java.util.Map; + +public final class AccountResourceImpl implements AccountResource, AccountResource.Definition, AccountResource.Update { + private AccountResourceInner innerObject; + + private final com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager 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 SystemData systemData() { + return this.innerModel().systemData(); + } + + public AccountResourceProperties properties() { + return this.innerModel().properties(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public AccountResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String resourceName; + + private AccountPatchResource updateAccountResource; + + public AccountResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public AccountResource create() { + this.innerObject = + serviceManager + .serviceClient() + .getAccountOperations() + .createAndUpdate(resourceGroupName, resourceName, this.innerModel(), Context.NONE); + return this; + } + + public AccountResource create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getAccountOperations() + .createAndUpdate(resourceGroupName, resourceName, this.innerModel(), context); + return this; + } + + AccountResourceImpl( + String name, com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager serviceManager) { + this.innerObject = new AccountResourceInner(); + this.serviceManager = serviceManager; + this.resourceName = name; + } + + public AccountResourceImpl update() { + this.updateAccountResource = new AccountPatchResource(); + return this; + } + + public AccountResource apply() { + this.innerObject = + serviceManager + .serviceClient() + .getAccountOperations() + .updateWithResponse(resourceGroupName, resourceName, updateAccountResource, Context.NONE) + .getValue(); + return this; + } + + public AccountResource apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getAccountOperations() + .updateWithResponse(resourceGroupName, resourceName, updateAccountResource, context) + .getValue(); + return this; + } + + AccountResourceImpl( + AccountResourceInner innerObject, + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.resourceName = Utils.getValueFromIdByName(innerObject.id(), "accounts"); + } + + public AccountResource refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getAccountOperations() + .getByResourceGroupWithResponse(resourceGroupName, resourceName, Context.NONE) + .getValue(); + return this; + } + + public AccountResource refresh(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getAccountOperations() + .getByResourceGroupWithResponse(resourceGroupName, resourceName, context) + .getValue(); + return this; + } + + public AccountResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public AccountResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public AccountResourceImpl withProperties(AccountResourceProperties properties) { + this.innerModel().withProperties(properties); + return this; + } + + public AccountResourceImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateAccountResource.withTags(tags); + return this; + } + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountsClientImpl.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountsClientImpl.java new file mode 100644 index 000000000000..bb4c89ed5724 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountsClientImpl.java @@ -0,0 +1,557 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.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.resourcemanager.graphservicesprod.fluent.AccountsClient; +import com.azure.resourcemanager.graphservicesprod.fluent.models.AccountResourceInner; +import com.azure.resourcemanager.graphservicesprod.models.AccountResourceList; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in AccountsClient. */ +public final class AccountsClientImpl implements AccountsClient { + /** The proxy service used to perform REST calls. */ + private final AccountsService service; + + /** The service client containing this operation class. */ + private final GraphServicesImpl client; + + /** + * Initializes an instance of AccountsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AccountsClientImpl(GraphServicesImpl client) { + this.service = RestProxy.create(AccountsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for GraphServicesAccounts to be used by the proxy service to perform REST + * calls. + */ + @Host("{$host}") + @ServiceInterface(name = "GraphServicesAccount") + public interface AccountsService { + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices" + + "/accounts") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.GraphServices/accounts") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @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); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Returns list of accounts apps. + * + * @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 the list of accounts along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @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.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + 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())); + } + + /** + * Returns list of accounts apps. + * + * @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 the list of accounts along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @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.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Returns list of accounts apps. + * + * @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 the list of accounts as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Returns list of accounts apps. + * + * @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 the list of accounts as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * Returns list of accounts apps. + * + * @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 the list of accounts as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * Returns list of accounts apps. + * + * @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 the list of accounts as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Returns list of accounts belonging to 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 the list of accounts along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @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.getApiVersion(), + this.client.getSubscriptionId(), + 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())); + } + + /** + * Returns list of accounts belonging to 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 the list of accounts along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @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.getApiVersion(), + this.client.getSubscriptionId(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Returns list of accounts belonging to 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 the list of accounts as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>( + () -> listSinglePageAsync(), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * Returns list of accounts belonging to 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 the list of accounts as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * Returns list of accounts belonging to 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 the list of accounts as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Returns list of accounts belonging to 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 the list of accounts as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of accounts along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @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 URL to get the next list of items + *

The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of accounts along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @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)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of accounts along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(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.listBySubscriptionNext(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 URL to get the next list of items + *

The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of accounts along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync( + 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 + .listBySubscriptionNext(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/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountsImpl.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountsImpl.java new file mode 100644 index 000000000000..ea3510a8f1db --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/AccountsImpl.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.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.graphservicesprod.fluent.AccountsClient; +import com.azure.resourcemanager.graphservicesprod.fluent.models.AccountResourceInner; +import com.azure.resourcemanager.graphservicesprod.models.AccountResource; +import com.azure.resourcemanager.graphservicesprod.models.Accounts; + +public final class AccountsImpl implements Accounts { + private static final ClientLogger LOGGER = new ClientLogger(AccountsImpl.class); + + private final AccountsClient innerClient; + + private final com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager serviceManager; + + public AccountsImpl( + AccountsClient innerClient, + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new AccountResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = + this.serviceClient().listByResourceGroup(resourceGroupName, context); + return Utils.mapPage(inner, inner1 -> new AccountResourceImpl(inner1, this.manager())); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new AccountResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new AccountResourceImpl(inner1, this.manager())); + } + + private AccountsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/GraphServicesBuilder.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/GraphServicesBuilder.java new file mode 100644 index 000000000000..ba6a7de08b50 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/GraphServicesBuilder.java @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.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.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 GraphServicesImpl type. */ +@ServiceClientBuilder(serviceClients = {GraphServicesImpl.class}) +public final class GraphServicesBuilder { + /* + * The ID of the target subscription. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. + * + * @param subscriptionId the subscriptionId value. + * @return the GraphServicesBuilder. + */ + public GraphServicesBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the GraphServicesBuilder. + */ + public GraphServicesBuilder 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 GraphServicesBuilder. + */ + public GraphServicesBuilder environment(AzureEnvironment environment) { + this.environment = environment; + 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 GraphServicesBuilder. + */ + public GraphServicesBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + 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 GraphServicesBuilder. + */ + public GraphServicesBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + 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 GraphServicesBuilder. + */ + public GraphServicesBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of GraphServicesImpl with the provided parameters. + * + * @return an instance of GraphServicesImpl. + */ + public GraphServicesImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = + (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval = + (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = + (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + GraphServicesImpl client = + new GraphServicesImpl( + localPipeline, + localSerializerAdapter, + localDefaultPollInterval, + localEnvironment, + subscriptionId, + localEndpoint); + return client; + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/GraphServicesImpl.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/GraphServicesImpl.java new file mode 100644 index 000000000000..74062352bc62 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/GraphServicesImpl.java @@ -0,0 +1,318 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.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.CoreUtils; +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.graphservicesprod.fluent.AccountOperationsClient; +import com.azure.resourcemanager.graphservicesprod.fluent.AccountsClient; +import com.azure.resourcemanager.graphservicesprod.fluent.GraphServices; +import com.azure.resourcemanager.graphservicesprod.fluent.OperationsClient; +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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the GraphServicesImpl type. */ +@ServiceClient(builder = GraphServicesBuilder.class) +public final class GraphServicesImpl implements GraphServices { + /** 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 AccountsClient object to access its operations. */ + private final AccountsClient accounts; + + /** + * Gets the AccountsClient object to access its operations. + * + * @return the AccountsClient object. + */ + public AccountsClient getAccounts() { + return this.accounts; + } + + /** The AccountOperationsClient object to access its operations. */ + private final AccountOperationsClient accountOperations; + + /** + * Gets the AccountOperationsClient object to access its operations. + * + * @return the AccountOperationsClient object. + */ + public AccountOperationsClient getAccountOperations() { + return this.accountOperations; + } + + /** The OperationsClient object to access its operations. */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * Initializes an instance of GraphServices 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. + */ + GraphServicesImpl( + 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 = "2022-09-22-preview"; + this.accounts = new AccountsClientImpl(this); + this.accountOperations = new AccountOperationsClientImpl(this); + this.operations = new OperationsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), 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)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(GraphServicesImpl.class); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/OperationImpl.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/OperationImpl.java new file mode 100644 index 000000000000..397e47612ada --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/OperationImpl.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.implementation; + +import com.azure.resourcemanager.graphservicesprod.fluent.models.OperationInner; +import com.azure.resourcemanager.graphservicesprod.models.ActionType; +import com.azure.resourcemanager.graphservicesprod.models.Operation; +import com.azure.resourcemanager.graphservicesprod.models.OperationDisplay; +import com.azure.resourcemanager.graphservicesprod.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager serviceManager; + + OperationImpl( + OperationInner innerObject, + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/OperationsClientImpl.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..e081d3cbdc9f --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/OperationsClientImpl.java @@ -0,0 +1,276 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.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.resourcemanager.graphservicesprod.fluent.OperationsClient; +import com.azure.resourcemanager.graphservicesprod.fluent.models.OperationInner; +import com.azure.resourcemanager.graphservicesprod.models.OperationListResult; +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 { + /** The proxy service used to perform REST calls. */ + private final OperationsService service; + + /** The service client containing this operation class. */ + private final GraphServicesImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(GraphServicesImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for GraphServicesOperations to be used by the proxy service to perform + * REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "GraphServicesOperati") + public interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.GraphServices/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); + } + + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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())); + } + + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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)); + } + + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider as paginated response with {@link + * PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider as paginated response with {@link + * PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items + *

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 a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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 URL to get the next list of items + *

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 a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/OperationsImpl.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/OperationsImpl.java new file mode 100644 index 000000000000..a92b2b732a4d --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/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.graphservicesprod.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.graphservicesprod.fluent.OperationsClient; +import com.azure.resourcemanager.graphservicesprod.fluent.models.OperationInner; +import com.azure.resourcemanager.graphservicesprod.models.Operation; +import com.azure.resourcemanager.graphservicesprod.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager serviceManager; + + public OperationsImpl( + OperationsClient innerClient, + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager 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.graphservicesprod.GraphservicesprodManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/Utils.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/Utils.java new file mode 100644 index 000000000000..ab47f3f3468f --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/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.graphservicesprod.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/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/package-info.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/implementation/package-info.java new file mode 100644 index 000000000000..4447bc7916b1 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/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 GraphServices. Self service experience for Microsoft Graph metered + * services. + */ +package com.azure.resourcemanager.graphservicesprod.implementation; diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountOperations.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountOperations.java new file mode 100644 index 000000000000..0a17df67dd45 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountOperations.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of AccountOperations. */ +public interface AccountOperations { + /** + * Returns account resource for a given name. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return account details along with {@link Response}. + */ + Response getByResourceGroupWithResponse( + String resourceGroupName, String resourceName, Context context); + + /** + * Returns account resource for a given name. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return account details. + */ + AccountResource getByResourceGroup(String resourceGroupName, String resourceName); + + /** + * Deletes a account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByResourceGroupWithResponse(String resourceGroupName, String resourceName, Context context); + + /** + * Deletes a account resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String resourceGroupName, String resourceName); + + /** + * Returns account resource for a given name. + * + * @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 account details along with {@link Response}. + */ + AccountResource getById(String id); + + /** + * Returns account resource for a given name. + * + * @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 account details along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Deletes a account resource. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Deletes a account resource. + * + * @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 {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new AccountResource resource. + * + * @param name resource name. + * @return the first stage of the new AccountResource definition. + */ + AccountResource.DefinitionStages.Blank define(String name); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountPatchResource.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountPatchResource.java new file mode 100644 index 000000000000..05bd679948fa --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountPatchResource.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.graphservicesprod.models; + +import com.azure.core.annotation.Fluent; +import java.util.Map; + +/** Account patch properties. */ +@Fluent +public final class AccountPatchResource extends TagUpdate { + /** Creates an instance of AccountPatchResource class. */ + public AccountPatchResource() { + } + + /** {@inheritDoc} */ + @Override + public AccountPatchResource withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountResource.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountResource.java new file mode 100644 index 000000000000..e19e307d3743 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountResource.java @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.graphservicesprod.fluent.models.AccountResourceInner; +import java.util.Map; + +/** An immutable client-side representation of AccountResource. */ +public interface AccountResource { + /** + * 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 systemData property: Metadata pertaining to creation and last modification of the resource. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the properties property: Property bag from billing account. + * + * @return the properties value. + */ + AccountResourceProperties properties(); + + /** + * 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 name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.graphservicesprod.fluent.models.AccountResourceInner object. + * + * @return the inner object. + */ + AccountResourceInner innerModel(); + + /** The entirety of the AccountResource definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, + DefinitionStages.WithProperties, + DefinitionStages.WithCreate { + } + /** The AccountResource definition stages. */ + interface DefinitionStages { + /** The first stage of the AccountResource definition. */ + interface Blank extends WithLocation { + } + /** The stage of the AccountResource 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 AccountResource 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. + */ + WithProperties withExistingResourceGroup(String resourceGroupName); + } + /** The stage of the AccountResource definition allowing to specify properties. */ + interface WithProperties { + /** + * Specifies the properties property: Property bag from billing account. + * + * @param properties Property bag from billing account. + * @return the next definition stage. + */ + WithCreate withProperties(AccountResourceProperties properties); + } + /** + * The stage of the AccountResource 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 { + /** + * Executes the create request. + * + * @return the created resource. + */ + AccountResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + AccountResource create(Context context); + } + /** The stage of the AccountResource 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); + } + } + /** + * Begins update for the AccountResource resource. + * + * @return the stage of resource update. + */ + AccountResource.Update update(); + + /** The template for AccountResource update. */ + interface Update extends UpdateStages.WithTags { + /** + * Executes the update request. + * + * @return the updated resource. + */ + AccountResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + AccountResource apply(Context context); + } + /** The AccountResource update stages. */ + interface UpdateStages { + /** The stage of the AccountResource update allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: List of key value pairs that describe the resource. This will overwrite the + * existing tags.. + * + * @param tags List of key value pairs that describe the resource. This will overwrite the existing tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + AccountResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + AccountResource refresh(Context context); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountResourceList.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountResourceList.java new file mode 100644 index 000000000000..e44d464d892b --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountResourceList.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.core.annotation.Fluent; +import com.azure.resourcemanager.graphservicesprod.fluent.models.AccountResourceInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The list of accounts. */ +@Fluent +public final class AccountResourceList { + /* + * The link to the next page of items + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /* + * The list of recommendations. + */ + @JsonProperty(value = "value") + private List value; + + /** Creates an instance of AccountResourceList class. */ + public AccountResourceList() { + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link to the next page of items. + * + * @param nextLink the nextLink value to set. + * @return the AccountResourceList object itself. + */ + public AccountResourceList withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Get the value property: The list of recommendations. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The list of recommendations. + * + * @param value the value value to set. + * @return the AccountResourceList object itself. + */ + public AccountResourceList withValue(List value) { + this.value = value; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountResourceProperties.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountResourceProperties.java new file mode 100644 index 000000000000..827e6ec606df --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/AccountResourceProperties.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Property bag from billing account. */ +@Fluent +public final class AccountResourceProperties { + /* + * Provisioning state. + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private ProvisioningState provisioningState; + + /* + * Customer owned application ID + */ + @JsonProperty(value = "applicationId", required = true) + private String applicationId; + + /* + * Billing plan Id + */ + @JsonProperty(value = "billingPlanId", access = JsonProperty.Access.WRITE_ONLY) + private String billingPlanId; + + /** Creates an instance of AccountResourceProperties class. */ + public AccountResourceProperties() { + } + + /** + * Get the provisioningState property: Provisioning state. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the applicationId property: Customer owned application ID. + * + * @return the applicationId value. + */ + public String applicationId() { + return this.applicationId; + } + + /** + * Set the applicationId property: Customer owned application ID. + * + * @param applicationId the applicationId value to set. + * @return the AccountResourceProperties object itself. + */ + public AccountResourceProperties withApplicationId(String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * Get the billingPlanId property: Billing plan Id. + * + * @return the billingPlanId value. + */ + public String billingPlanId() { + return this.billingPlanId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (applicationId() == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property applicationId in model AccountResourceProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AccountResourceProperties.class); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Accounts.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Accounts.java new file mode 100644 index 000000000000..c87475a09b33 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Accounts.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Accounts. */ +public interface Accounts { + /** + * Returns list of accounts apps. + * + * @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 the list of accounts as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Returns list of accounts apps. + * + * @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 the list of accounts as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Returns list of accounts belonging to 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 the list of accounts as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * Returns list of accounts belonging to 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 the list of accounts as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/ActionType.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/ActionType.java new file mode 100644 index 000000000000..1b33c8b108f2 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/ActionType.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ +public final class ActionType extends ExpandableStringEnum { + /** Static value Internal for ActionType. */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates a new instance of ActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActionType() { + } + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + @JsonCreator + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * Gets known ActionType values. + * + * @return known ActionType values. + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Operation.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Operation.java new file mode 100644 index 000000000000..b18e2b2b4e0b --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Operation.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.resourcemanager.graphservicesprod.fluent.models.OperationInner; + +/** An immutable client-side representation of Operation. */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for ARM/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Enum. Indicates the action type. "Internal" refers to actions that are for internal + * only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.azure.resourcemanager.graphservicesprod.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/OperationDisplay.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/OperationDisplay.java new file mode 100644 index 000000000000..f0a57946496e --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/OperationDisplay.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Localized display information for this particular operation. */ +@Immutable +public final class OperationDisplay { + /* + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + * Compute". + */ + @JsonProperty(value = "provider", access = JsonProperty.Access.WRITE_ONLY) + private String provider; + + /* + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + * Schedule Collections". + */ + @JsonProperty(value = "resource", access = JsonProperty.Access.WRITE_ONLY) + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + * Machine", "Restart Virtual Machine". + */ + @JsonProperty(value = "operation", access = JsonProperty.Access.WRITE_ONLY) + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + */ + @JsonProperty(value = "description", access = JsonProperty.Access.WRITE_ONLY) + private String description; + + /** Creates an instance of OperationDisplay class. */ + public OperationDisplay() { + } + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/OperationListResult.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/OperationListResult.java new file mode 100644 index 000000000000..4445526f8a16 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/OperationListResult.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.core.annotation.Immutable; +import com.azure.resourcemanager.graphservicesprod.fluent.models.OperationInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult { + /* + * List of operations supported by the resource provider + */ + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) + private List value; + + /* + * URL to get the next set of operation list results (if there are any). + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** Creates an instance of OperationListResult class. */ + public OperationListResult() { + } + + /** + * Get the value property: List of operations supported by the resource provider. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: URL to get the next set of operation list results (if there are any). + * + * @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/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Operations.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Operations.java new file mode 100644 index 000000000000..948caa154b89 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Operations.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.graphservicesprod.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider as paginated response with {@link + * PagedIterable}. + */ + PagedIterable list(); + + /** + * Returns list of 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 a list of REST API operations supported by an Azure Resource Provider as paginated response with {@link + * PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Origin.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Origin.java new file mode 100644 index 000000000000..5a9e32ea2900 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/Origin.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.graphservicesprod.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value + * is "user,system". + */ +public final class Origin extends ExpandableStringEnum { + /** Static value user for Origin. */ + public static final Origin USER = fromString("user"); + + /** Static value system for Origin. */ + public static final Origin SYSTEM = fromString("system"); + + /** Static value user,system for Origin. */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates a new instance of Origin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Origin() { + } + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + @JsonCreator + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** + * Gets known Origin values. + * + * @return known Origin values. + */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/ProvisioningState.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/ProvisioningState.java new file mode 100644 index 000000000000..9751fc8d68ee --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/ProvisioningState.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Provisioning state. */ +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"); + + /** + * Creates a new instance of ProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ProvisioningState() { + } + + /** + * 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); + } + + /** + * Gets known ProvisioningState values. + * + * @return known ProvisioningState values. + */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/TagUpdate.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/TagUpdate.java new file mode 100644 index 000000000000..545b5479d494 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/TagUpdate.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.graphservicesprod.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** Request payload used to update an existing resource's tags. */ +@Fluent +public class TagUpdate { + /* + * List of key value pairs that describe the resource. This will overwrite the existing tags. + */ + @JsonProperty(value = "tags") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map tags; + + /** Creates an instance of TagUpdate class. */ + public TagUpdate() { + } + + /** + * Get the tags property: List of key value pairs that describe the resource. This will overwrite the existing tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: List of key value pairs that describe the resource. This will overwrite the existing tags. + * + * @param tags the tags value to set. + * @return the TagUpdate object itself. + */ + public TagUpdate 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/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/package-info.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/package-info.java new file mode 100644 index 000000000000..a00eba644dc0 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/models/package-info.java @@ -0,0 +1,8 @@ +// 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 GraphServices. Self service experience for Microsoft Graph metered services. + */ +package com.azure.resourcemanager.graphservicesprod.models; diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/package-info.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/package-info.java new file mode 100644 index 000000000000..290ff254bc8d --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/com/azure/resourcemanager/graphservicesprod/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the classes for GraphServices. Self service experience for Microsoft Graph metered services. */ +package com.azure.resourcemanager.graphservicesprod; diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/module-info.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/main/java/module-info.java new file mode 100644 index 000000000000..7ac2c6df391a --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/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.graphservicesprod { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.graphservicesprod; + exports com.azure.resourcemanager.graphservicesprod.fluent; + exports com.azure.resourcemanager.graphservicesprod.fluent.models; + exports com.azure.resourcemanager.graphservicesprod.models; + + opens com.azure.resourcemanager.graphservicesprod.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.graphservicesprod.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationCreateAndUpdateSamples.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationCreateAndUpdateSamples.java new file mode 100644 index 000000000000..e533b19f2666 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationCreateAndUpdateSamples.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.graphservicesprod.generated; + +import com.azure.resourcemanager.graphservicesprod.models.AccountResourceProperties; +import java.util.HashMap; +import java.util.Map; + +/** Samples for AccountOperation CreateAndUpdate. */ +public final class AccountOperationCreateAndUpdateSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_Create.json + */ + /** + * Sample code: Create Account resource. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void createAccountResource( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager + .accountOperations() + .define("11111111-aaaa-1111-bbbb-1111111111111") + .withRegion((String) null) + .withExistingResourceGroup("testResourceGroupGRAM") + .withProperties(new AccountResourceProperties().withApplicationId("11111111-aaaa-1111-bbbb-111111111111")) + .withTags(mapOf("tag1", "value1", "tag2", "value2")) + .create(); + } + + @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/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationDeleteSamples.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationDeleteSamples.java new file mode 100644 index 000000000000..0cc1519c5199 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationDeleteSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.generated; + +/** Samples for AccountOperation Delete. */ +public final class AccountOperationDeleteSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_Delete.json + */ + /** + * Sample code: Delete account resource. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void deleteAccountResource( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager + .accountOperations() + .deleteByResourceGroupWithResponse( + "testResourceGroupGRAM", "11111111-aaaa-1111-bbbb-111111111111", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationGetByResourceGroupSamples.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationGetByResourceGroupSamples.java new file mode 100644 index 000000000000..49bb33a62baf --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationGetByResourceGroupSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.generated; + +/** Samples for AccountOperation GetByResourceGroup. */ +public final class AccountOperationGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_Get.json + */ + /** + * Sample code: Get accounts. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void getAccounts(com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager + .accountOperations() + .getByResourceGroupWithResponse( + "testResourceGroupGRAM", "11111111-aaaa-1111-bbbb-111111111111", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationUpdateSamples.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationUpdateSamples.java new file mode 100644 index 000000000000..c6e21859722d --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountOperationUpdateSamples.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.generated; + +import com.azure.resourcemanager.graphservicesprod.models.AccountResource; +import java.util.HashMap; +import java.util.Map; + +/** Samples for AccountOperation Update. */ +public final class AccountOperationUpdateSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_Update.json + */ + /** + * Sample code: Update account resource. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void updateAccountResource( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + AccountResource resource = + manager + .accountOperations() + .getByResourceGroupWithResponse( + "testResourceGroupGRAM", "11111111-aaaa-1111-bbbb-111111111111", com.azure.core.util.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/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountsListByResourceGroupSamples.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountsListByResourceGroupSamples.java new file mode 100644 index 000000000000..9a23cafc4859 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountsListByResourceGroupSamples.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.generated; + +/** Samples for Accounts ListByResourceGroup. */ +public final class AccountsListByResourceGroupSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_List.json + */ + /** + * Sample code: Create or update account resource. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void createOrUpdateAccountResource( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager.accounts().listByResourceGroup("testResourceGroupGRAM", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountsListSamples.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountsListSamples.java new file mode 100644 index 000000000000..b9cc00785a54 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/AccountsListSamples.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.generated; + +/** Samples for Accounts List. */ +public final class AccountsListSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Accounts_List_Sub.json + */ + /** + * Sample code: Get list of accounts by subscription. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void getListOfAccountsBySubscription( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager.accounts().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/OperationListSamples.java b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/OperationListSamples.java new file mode 100644 index 000000000000..a5c37b3229d9 --- /dev/null +++ b/sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/src/samples/java/com/azure/resourcemanager/graphservicesprod/generated/OperationListSamples.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.graphservicesprod.generated; + +/** Samples for Operation List. */ +public final class OperationListSamples { + /* + * x-ms-original-file: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/preview/2022-09-22-preview/examples/Operations_List.json + */ + /** + * Sample code: Get list of operations. + * + * @param manager Entry point to GraphservicesprodManager. + */ + public static void getListOfOperations( + com.azure.resourcemanager.graphservicesprod.GraphservicesprodManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/graphservicesprod/ci.yml b/sdk/graphservicesprod/ci.yml new file mode 100644 index 000000000000..3b82648c2d8b --- /dev/null +++ b/sdk/graphservicesprod/ci.yml @@ -0,0 +1,47 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/graphservicesprod/ci.yml + - sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/ + exclude: + - sdk/graphservicesprod/pom.xml + - sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/graphservicesprod/ci.yml + - sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/ + exclude: + - sdk/graphservicesprod/pom.xml + - sdk/graphservicesprod/azure-resourcemanager-graphservicesprod/pom.xml + +parameters: + - name: release_azureresourcemanagergraphservicesprod + displayName: azure-resourcemanager-graphservicesprod + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: graphservicesprod + EnableBatchRelease: true + Artifacts: + - name: azure-resourcemanager-graphservicesprod + groupId: com.azure.resourcemanager + safeName: azureresourcemanagergraphservicesprod + releaseInBatch: ${{ parameters.release_azureresourcemanagergraphservicesprod }} diff --git a/sdk/graphservicesprod/pom.xml b/sdk/graphservicesprod/pom.xml new file mode 100644 index 000000000000..845d24a6d396 --- /dev/null +++ b/sdk/graphservicesprod/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-graphservicesprod-service + pom + 1.0.0 + + + azure-resourcemanager-graphservicesprod + +