diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 92dbd2e57617..ac1da19ae51f 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -473,6 +473,7 @@ com.azure.resourcemanager:azure-resourcemanager-databasewatcher;1.0.0-beta.1;1.0 com.azure.resourcemanager:azure-resourcemanager-durabletask;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-arizeaiobservabilityeval;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-weightsandbiases;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-sitemanager;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;1.1.0-beta.1 com.azure.v2:azure-client-sdk-parent;2.0.0-beta.1;2.0.0-beta.1 diff --git a/pom.xml b/pom.xml index ff71d092c5bb..942aa622cb46 100644 --- a/pom.xml +++ b/pom.xml @@ -209,6 +209,7 @@ sdk/servicelinker sdk/servicenetworking sdk/signalr + sdk/sitemanager sdk/sphere sdk/spring sdk/spring-experimental diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/CHANGELOG.md b/sdk/sitemanager/azure-resourcemanager-sitemanager/CHANGELOG.md new file mode 100644 index 000000000000..d36c9d1d1ae4 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2025-04-15) + +- Azure Resource Manager sitemanager client library for Java. This package contains Microsoft Azure SDK for sitemanager Management SDK. Azure Edge Sites Resource Provider management API. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). +### Features Added + +- Initial release for the azure-resourcemanager-sitemanager Java SDK. diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/README.md b/sdk/sitemanager/azure-resourcemanager-sitemanager/README.md new file mode 100644 index 000000000000..87d29d548770 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager sitemanager client library for Java + +Azure Resource Manager sitemanager client library for Java. + +This package contains Microsoft Azure SDK for sitemanager Management SDK. Azure Edge Sites Resource Provider management API. 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-sitemanager;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-sitemanager + 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 + +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. + +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. + +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureCloud.AZURE_PUBLIC_CLOUD); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +SitemanagerManager manager = SitemanagerManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change the `AzureCloud.AZURE_PUBLIC_CLOUD` 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/sitemanager/azure-resourcemanager-sitemanager/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://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[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/sitemanager/azure-resourcemanager-sitemanager/SAMPLE.md b/sdk/sitemanager/azure-resourcemanager-sitemanager/SAMPLE.md new file mode 100644 index 000000000000..617bcb3bf887 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/SAMPLE.md @@ -0,0 +1,265 @@ +# Code snippets and samples + + +## Sites + +- [CreateOrUpdate](#sites_createorupdate) +- [Delete](#sites_delete) +- [GetByResourceGroup](#sites_getbyresourcegroup) +- [ListByResourceGroup](#sites_listbyresourcegroup) +- [Update](#sites_update) + +## SitesBySubscription + +- [CreateOrUpdate](#sitesbysubscription_createorupdate) +- [Delete](#sitesbysubscription_delete) +- [Get](#sitesbysubscription_get) +- [List](#sitesbysubscription_list) +- [Update](#sitesbysubscription_update) +### Sites_CreateOrUpdate + +```java +/** + * Samples for SitesBySubscription Get. + */ +public final class SitesBySubscriptionGetSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_Get.json + */ + /** + * Sample code: Get Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void getSiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions().getWithResponse("string", com.azure.core.util.Context.NONE); + } +} +``` + +### Sites_Delete + +```java +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.models.SiteProperties; + +/** + * Samples for SitesBySubscription CreateOrUpdate. + */ +public final class SitesBySubscriptionCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_CreateOrUpdate.json + */ + /** + * Sample code: Create Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void createSiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions() + .createOrUpdate("string", new SiteInner().withProperties(new SiteProperties().withDisplayName("string") + .withDescription("string") + .withAddressResourceId( + "/subscriptions/680d0dad-59aa-4464-3df3-b34b2b42738c/resourceGroups/us-site-rg/providers/Microsoft.EdgeOrder/addresses/12343213")), + com.azure.core.util.Context.NONE); + } +} +``` + +### Sites_GetByResourceGroup + +```java +import com.azure.resourcemanager.sitemanager.models.SiteProperties; + +/** + * Samples for Sites CreateOrUpdate. + */ +public final class SitesCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_CreateOrUpdate.json + */ + /** + * Sample code: Create or update Site. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void createOrUpdateSite(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sites() + .define("string") + .withExistingResourceGroup("string") + .withProperties(new SiteProperties().withDisplayName("string") + .withDescription("string") + .withAddressResourceId( + "/subscriptions/680d0dad-59aa-4464-3df3-b34b2b42738c/resourceGroups/us-site-rg/providers/Microsoft.EdgeOrder/addresses/12343213")) + .create(); + } +} +``` + +### Sites_ListByResourceGroup + +```java +/** + * Samples for SitesBySubscription List. + */ +public final class SitesBySubscriptionListSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_List.json + */ + /** + * Sample code: List by Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void listBySubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Sites_Update + +```java +/** + * Samples for Sites Delete. + */ +public final class SitesDeleteSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_Delete.json + */ + /** + * Sample code: Delete Site. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void deleteSite(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sites().deleteByResourceGroupWithResponse("string", "string", com.azure.core.util.Context.NONE); + } +} +``` + +### SitesBySubscription_CreateOrUpdate + +```java +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; +import com.azure.resourcemanager.sitemanager.models.SiteUpdateProperties; + +/** + * Samples for SitesBySubscription Update. + */ +public final class SitesBySubscriptionUpdateSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_Update.json + */ + /** + * Sample code: Patch Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void patchSiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions() + .updateWithResponse("string", new SiteUpdate().withProperties(new SiteUpdateProperties() + .withDisplayName("string") + .withDescription("string") + .withAddressResourceId( + "/subscriptions/0154f7fe-df09-4981-bf82-7ad5c1f596eb/resourceGroups/us-site-rg/providers/Microsoft.EdgeOrder/addresses/12343213")), + com.azure.core.util.Context.NONE); + } +} +``` + +### SitesBySubscription_Delete + +```java +import com.azure.resourcemanager.sitemanager.models.Site; +import com.azure.resourcemanager.sitemanager.models.SiteUpdateProperties; + +/** + * Samples for Sites Update. + */ +public final class SitesUpdateSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_Update.json + */ + /** + * Sample code: Update Site. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void updateSite(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + Site resource = manager.sites() + .getByResourceGroupWithResponse("string", "string", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withProperties(new SiteUpdateProperties().withDisplayName("string") + .withDescription("string") + .withAddressResourceId( + "/subscriptions/11111111-2222-3333-4444-55555555/resourceGroups/us-site-rg/providers/Microsoft.EdgeOrder/addresses/12343213")) + .apply(); + } +} +``` + +### SitesBySubscription_Get + +```java +/** + * Samples for Sites GetByResourceGroup. + */ +public final class SitesGetByResourceGroupSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_Get.json + */ + /** + * Sample code: Get Site. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void getSite(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sites().getByResourceGroupWithResponse("string", "string", com.azure.core.util.Context.NONE); + } +} +``` + +### SitesBySubscription_List + +```java +/** + * Samples for Sites ListByResourceGroup. + */ +public final class SitesListByResourceGroupSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_ListByResourceGroup.json + */ + /** + * Sample code: List by Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void listBySiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sites().listByResourceGroup("string", com.azure.core.util.Context.NONE); + } +} +``` + +### SitesBySubscription_Update + +```java +/** + * Samples for SitesBySubscription Delete. + */ +public final class SitesBySubscriptionDeleteSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_Delete.json + */ + /** + * Sample code: Delete Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void deleteSiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions().deleteWithResponse("string", com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/pom.xml b/sdk/sitemanager/azure-resourcemanager-sitemanager/pom.xml new file mode 100644 index 000000000000..28bac49735b7 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-sitemanager + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for sitemanager Management + This package contains Microsoft Azure SDK for sitemanager Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Edge Sites Resource Provider management API. + 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 + true + + + + com.azure + azure-core + 1.55.3 + + + com.azure + azure-core-management + 1.17.0 + + + com.azure + azure-core-test + 1.27.0-beta.8 + test + + + com.azure + azure-identity + 1.15.4 + test + + + diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/SitemanagerManager.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/SitemanagerManager.java new file mode 100644 index 000000000000..eb1ab36210bf --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/SitemanagerManager.java @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager; + +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.BearerTokenAuthenticationPolicy; +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.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.sitemanager.fluent.EdgeClient; +import com.azure.resourcemanager.sitemanager.implementation.EdgeClientBuilder; +import com.azure.resourcemanager.sitemanager.implementation.SitesBySubscriptionsImpl; +import com.azure.resourcemanager.sitemanager.implementation.SitesImpl; +import com.azure.resourcemanager.sitemanager.models.Sites; +import com.azure.resourcemanager.sitemanager.models.SitesBySubscriptions; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to SitemanagerManager. + * Azure Edge Sites Resource Provider management API. + */ +public final class SitemanagerManager { + private Sites sites; + + private SitesBySubscriptions sitesBySubscriptions; + + private final EdgeClient clientObject; + + private SitemanagerManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new EdgeClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of sitemanager service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the sitemanager service API instance. + */ + public static SitemanagerManager 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 sitemanager service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the sitemanager service API instance. + */ + public static SitemanagerManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new SitemanagerManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create SitemanagerManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new SitemanagerManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-sitemanager.properties"); + + 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 sitemanager service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the sitemanager service API instance. + */ + public SitemanagerManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.sitemanager") + .append("/") + .append(clientVersion); + 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 BearerTokenAuthenticationPolicy(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 SitemanagerManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Sites. It manages Site. + * + * @return Resource collection API of Sites. + */ + public Sites sites() { + if (this.sites == null) { + this.sites = new SitesImpl(clientObject.getSites(), this); + } + return sites; + } + + /** + * Gets the resource collection API of SitesBySubscriptions. + * + * @return Resource collection API of SitesBySubscriptions. + */ + public SitesBySubscriptions sitesBySubscriptions() { + if (this.sitesBySubscriptions == null) { + this.sitesBySubscriptions = new SitesBySubscriptionsImpl(clientObject.getSitesBySubscriptions(), this); + } + return sitesBySubscriptions; + } + + /** + * Gets wrapped service client EdgeClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client EdgeClient. + */ + public EdgeClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/EdgeClient.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/EdgeClient.java new file mode 100644 index 000000000000..d669e7e5dc15 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/EdgeClient.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for EdgeClient class. + */ +public interface EdgeClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * 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 SitesClient object to access its operations. + * + * @return the SitesClient object. + */ + SitesClient getSites(); + + /** + * Gets the SitesBySubscriptionsClient object to access its operations. + * + * @return the SitesBySubscriptionsClient object. + */ + SitesBySubscriptionsClient getSitesBySubscriptions(); +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/SitesBySubscriptionsClient.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/SitesBySubscriptionsClient.java new file mode 100644 index 000000000000..37477bcc0709 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/SitesBySubscriptionsClient.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; + +/** + * An instance of this class provides access to all the operations defined in SitesBySubscriptionsClient. + */ +public interface SitesBySubscriptionsClient { + /** + * List Site resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List Site resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * Get a Site. + * + * @param siteName Name of Site resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String siteName, Context context); + + /** + * Get a Site. + * + * @param siteName Name of Site resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SiteInner get(String siteName); + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SiteInner> beginCreateOrUpdate(String siteName, SiteInner resource); + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SiteInner> beginCreateOrUpdate(String siteName, SiteInner resource, + Context context); + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SiteInner createOrUpdate(String siteName, SiteInner resource); + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SiteInner createOrUpdate(String siteName, SiteInner resource, Context context); + + /** + * Update a Site. + * + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(String siteName, SiteUpdate properties, Context context); + + /** + * Update a Site. + * + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SiteInner update(String siteName, SiteUpdate properties); + + /** + * Delete a Site. + * + * @param siteName Name of Site 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 siteName, Context context); + + /** + * Delete a Site. + * + * @param siteName Name of Site 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 siteName); +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/SitesClient.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/SitesClient.java new file mode 100644 index 000000000000..df157ce00200 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/SitesClient.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; + +/** + * An instance of this class provides access to all the operations defined in SitesClient. + */ +public interface SitesClient { + /** + * Get a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String siteName, Context context); + + /** + * Get a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SiteInner getByResourceGroup(String resourceGroupName, String siteName); + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SiteInner> beginCreateOrUpdate(String resourceGroupName, String siteName, + SiteInner resource); + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SiteInner> beginCreateOrUpdate(String resourceGroupName, String siteName, + SiteInner resource, Context context); + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SiteInner createOrUpdate(String resourceGroupName, String siteName, SiteInner resource); + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SiteInner createOrUpdate(String resourceGroupName, String siteName, SiteInner resource, Context context); + + /** + * Update a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(String resourceGroupName, String siteName, SiteUpdate properties, + Context context); + + /** + * Update a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SiteInner update(String resourceGroupName, String siteName, SiteUpdate properties); + + /** + * Delete a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 siteName, Context context); + + /** + * Delete a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 siteName); + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/models/SiteInner.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/models/SiteInner.java new file mode 100644 index 000000000000..9b7b6fbcb09a --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/models/SiteInner.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.sitemanager.models.SiteProperties; +import java.io.IOException; + +/** + * Site as ARM Resource. + */ +@Fluent +public final class SiteInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private SiteProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of SiteInner class. + */ + public SiteInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public SiteProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the SiteInner object itself. + */ + public SiteInner withProperties(SiteProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SiteInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SiteInner if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SiteInner. + */ + public static SiteInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SiteInner deserializedSiteInner = new SiteInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSiteInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedSiteInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedSiteInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedSiteInner.properties = SiteProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedSiteInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSiteInner; + }); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/models/package-info.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/models/package-info.java new file mode 100644 index 000000000000..f1f0a7a52922 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/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) TypeSpec Code Generator. + +/** + * Package containing the inner data models for Edge. + * Azure Edge Sites Resource Provider management API. + */ +package com.azure.resourcemanager.sitemanager.fluent.models; diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/package-info.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/fluent/package-info.java new file mode 100644 index 000000000000..486aecce2e74 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/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) TypeSpec Code Generator. + +/** + * Package containing the service clients for Edge. + * Azure Edge Sites Resource Provider management API. + */ +package com.azure.resourcemanager.sitemanager.fluent; diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/EdgeClientBuilder.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/EdgeClientBuilder.java new file mode 100644 index 000000000000..eade3ed58efb --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/EdgeClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.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 EdgeClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { EdgeClientImpl.class }) +public final class EdgeClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the EdgeClientBuilder. + */ + public EdgeClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the EdgeClientBuilder. + */ + public EdgeClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the EdgeClientBuilder. + */ + public EdgeClientBuilder 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 EdgeClientBuilder. + */ + public EdgeClientBuilder 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 EdgeClientBuilder. + */ + public EdgeClientBuilder 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 EdgeClientBuilder. + */ + public EdgeClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of EdgeClientImpl with the provided parameters. + * + * @return an instance of EdgeClientImpl. + */ + public EdgeClientImpl 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(); + EdgeClientImpl client = new EdgeClientImpl(localPipeline, localSerializerAdapter, localDefaultPollInterval, + localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/EdgeClientImpl.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/EdgeClientImpl.java new file mode 100644 index 000000000000..aa07ab75a633 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/EdgeClientImpl.java @@ -0,0 +1,304 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +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.sitemanager.fluent.EdgeClient; +import com.azure.resourcemanager.sitemanager.fluent.SitesBySubscriptionsClient; +import com.azure.resourcemanager.sitemanager.fluent.SitesClient; +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 EdgeClientImpl type. + */ +@ServiceClient(builder = EdgeClientBuilder.class) +public final class EdgeClientImpl implements EdgeClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * 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 SitesClient object to access its operations. + */ + private final SitesClient sites; + + /** + * Gets the SitesClient object to access its operations. + * + * @return the SitesClient object. + */ + public SitesClient getSites() { + return this.sites; + } + + /** + * The SitesBySubscriptionsClient object to access its operations. + */ + private final SitesBySubscriptionsClient sitesBySubscriptions; + + /** + * Gets the SitesBySubscriptionsClient object to access its operations. + * + * @return the SitesBySubscriptionsClient object. + */ + public SitesBySubscriptionsClient getSitesBySubscriptions() { + return this.sitesBySubscriptions; + } + + /** + * Initializes an instance of EdgeClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + EdgeClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2024-02-01-preview"; + this.sites = new SitesClientImpl(this); + this.sitesBySubscriptions = new SitesBySubscriptionsClientImpl(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(HttpHeaderName.fromString(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(EdgeClientImpl.class); +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/ResourceManagerUtils.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000000..e35ab5e5b1b8 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.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 ResourceManagerUtils { + private ResourceManagerUtils() { + } + + 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.isEmpty() && 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<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(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/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SiteImpl.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SiteImpl.java new file mode 100644 index 000000000000..a603660c0b9c --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SiteImpl.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.models.Site; +import com.azure.resourcemanager.sitemanager.models.SiteProperties; +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; +import com.azure.resourcemanager.sitemanager.models.SiteUpdateProperties; + +public final class SiteImpl implements Site, Site.Definition, Site.Update { + private SiteInner innerObject; + + private final com.azure.resourcemanager.sitemanager.SitemanagerManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public SiteProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public SiteInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.sitemanager.SitemanagerManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String siteName; + + private SiteUpdate updateProperties; + + public SiteImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public Site create() { + this.innerObject = serviceManager.serviceClient() + .getSites() + .createOrUpdate(resourceGroupName, siteName, this.innerModel(), Context.NONE); + return this; + } + + public Site create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSites() + .createOrUpdate(resourceGroupName, siteName, this.innerModel(), context); + return this; + } + + SiteImpl(String name, com.azure.resourcemanager.sitemanager.SitemanagerManager serviceManager) { + this.innerObject = new SiteInner(); + this.serviceManager = serviceManager; + this.siteName = name; + } + + public SiteImpl update() { + this.updateProperties = new SiteUpdate(); + return this; + } + + public Site apply() { + this.innerObject = serviceManager.serviceClient() + .getSites() + .updateWithResponse(resourceGroupName, siteName, updateProperties, Context.NONE) + .getValue(); + return this; + } + + public Site apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSites() + .updateWithResponse(resourceGroupName, siteName, updateProperties, context) + .getValue(); + return this; + } + + SiteImpl(SiteInner innerObject, com.azure.resourcemanager.sitemanager.SitemanagerManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.siteName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "sites"); + } + + public Site refresh() { + this.innerObject = serviceManager.serviceClient() + .getSites() + .getByResourceGroupWithResponse(resourceGroupName, siteName, Context.NONE) + .getValue(); + return this; + } + + public Site refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSites() + .getByResourceGroupWithResponse(resourceGroupName, siteName, context) + .getValue(); + return this; + } + + public SiteImpl withProperties(SiteProperties properties) { + this.innerModel().withProperties(properties); + return this; + } + + public SiteImpl withProperties(SiteUpdateProperties properties) { + this.updateProperties.withProperties(properties); + return this; + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesBySubscriptionsClientImpl.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesBySubscriptionsClientImpl.java new file mode 100644 index 000000000000..7c0ccff8b18d --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesBySubscriptionsClientImpl.java @@ -0,0 +1,809 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.sitemanager.fluent.SitesBySubscriptionsClient; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.implementation.models.SiteListResult; +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; +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 SitesBySubscriptionsClient. + */ +public final class SitesBySubscriptionsClientImpl implements SitesBySubscriptionsClient { + /** + * The proxy service used to perform REST calls. + */ + private final SitesBySubscriptionsService service; + + /** + * The service client containing this operation class. + */ + private final EdgeClientImpl client; + + /** + * Initializes an instance of SitesBySubscriptionsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SitesBySubscriptionsClientImpl(EdgeClientImpl client) { + this.service = RestProxy.create(SitesBySubscriptionsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for EdgeClientSitesBySubscriptions to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "EdgeClientSitesBySub") + public interface SitesBySubscriptionsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("siteName") String siteName, @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("siteName") String siteName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") SiteInner resource, Context context); + + @Patch("/subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("siteName") String siteName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") SiteUpdate properties, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("siteName") String siteName, @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("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * List Site resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation 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())); + } + + /** + * List Site resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation 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)); + } + + /** + * List Site resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List Site resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List Site resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List Site resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get a Site. + * + * @param siteName Name of Site 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 Site along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String siteName) { + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), siteName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a Site. + * + * @param siteName Name of Site resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String siteName, 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + siteName, accept, context); + } + + /** + * Get a Site. + * + * @param siteName Name of Site 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 Site on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String siteName) { + return getWithResponseAsync(siteName).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a Site. + * + * @param siteName Name of Site resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String siteName, Context context) { + return getWithResponseAsync(siteName, context).block(); + } + + /** + * Get a Site. + * + * @param siteName Name of Site 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 Site. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SiteInner get(String siteName) { + return getWithResponse(siteName, Context.NONE).getValue(); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String siteName, SiteInner resource) { + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), siteName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String siteName, SiteInner resource, + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), siteName, contentType, accept, resource, context); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SiteInner> beginCreateOrUpdateAsync(String siteName, SiteInner resource) { + Mono>> mono = createOrUpdateWithResponseAsync(siteName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), SiteInner.class, + SiteInner.class, this.client.getContext()); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SiteInner> beginCreateOrUpdateAsync(String siteName, SiteInner resource, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono = createOrUpdateWithResponseAsync(siteName, resource, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), SiteInner.class, + SiteInner.class, context); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SiteInner> beginCreateOrUpdate(String siteName, SiteInner resource) { + return this.beginCreateOrUpdateAsync(siteName, resource).getSyncPoller(); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SiteInner> beginCreateOrUpdate(String siteName, SiteInner resource, + Context context) { + return this.beginCreateOrUpdateAsync(siteName, resource, context).getSyncPoller(); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String siteName, SiteInner resource) { + return beginCreateOrUpdateAsync(siteName, resource).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String siteName, SiteInner resource, Context context) { + return beginCreateOrUpdateAsync(siteName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SiteInner createOrUpdate(String siteName, SiteInner resource) { + return createOrUpdateAsync(siteName, resource).block(); + } + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SiteInner createOrUpdate(String siteName, SiteInner resource, Context context) { + return createOrUpdateAsync(siteName, resource, context).block(); + } + + /** + * Update a Site. + * + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String siteName, SiteUpdate properties) { + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), siteName, contentType, accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a Site. + * + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String siteName, SiteUpdate properties, 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + siteName, contentType, accept, properties, context); + } + + /** + * Update a Site. + * + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String siteName, SiteUpdate properties) { + return updateWithResponseAsync(siteName, properties).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a Site. + * + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(String siteName, SiteUpdate properties, Context context) { + return updateWithResponseAsync(siteName, properties, context).block(); + } + + /** + * Update a Site. + * + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SiteInner update(String siteName, SiteUpdate properties) { + return updateWithResponse(siteName, properties, Context.NONE).getValue(); + } + + /** + * Delete a Site. + * + * @param siteName Name of Site 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 siteName) { + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName 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(), siteName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Site. + * + * @param siteName Name of Site 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 siteName, 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName 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(), + siteName, accept, context); + } + + /** + * Delete a Site. + * + * @param siteName Name of Site 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 siteName) { + return deleteWithResponseAsync(siteName).flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a Site. + * + * @param siteName Name of Site 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 siteName, Context context) { + return deleteWithResponseAsync(siteName, context).block(); + } + + /** + * Delete a Site. + * + * @param siteName Name of Site 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 siteName) { + deleteWithResponse(siteName, Context.NONE); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation 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. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation 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/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesBySubscriptionsImpl.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesBySubscriptionsImpl.java new file mode 100644 index 000000000000..2126b46f9c9a --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesBySubscriptionsImpl.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.sitemanager.fluent.SitesBySubscriptionsClient; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.models.Site; +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; +import com.azure.resourcemanager.sitemanager.models.SitesBySubscriptions; + +public final class SitesBySubscriptionsImpl implements SitesBySubscriptions { + private static final ClientLogger LOGGER = new ClientLogger(SitesBySubscriptionsImpl.class); + + private final SitesBySubscriptionsClient innerClient; + + private final com.azure.resourcemanager.sitemanager.SitemanagerManager serviceManager; + + public SitesBySubscriptionsImpl(SitesBySubscriptionsClient innerClient, + com.azure.resourcemanager.sitemanager.SitemanagerManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SiteImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SiteImpl(inner1, this.manager())); + } + + public Response getWithResponse(String siteName, Context context) { + Response inner = this.serviceClient().getWithResponse(siteName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SiteImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Site get(String siteName) { + SiteInner inner = this.serviceClient().get(siteName); + if (inner != null) { + return new SiteImpl(inner, this.manager()); + } else { + return null; + } + } + + public Site createOrUpdate(String siteName, SiteInner resource) { + SiteInner inner = this.serviceClient().createOrUpdate(siteName, resource); + if (inner != null) { + return new SiteImpl(inner, this.manager()); + } else { + return null; + } + } + + public Site createOrUpdate(String siteName, SiteInner resource, Context context) { + SiteInner inner = this.serviceClient().createOrUpdate(siteName, resource, context); + if (inner != null) { + return new SiteImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response updateWithResponse(String siteName, SiteUpdate properties, Context context) { + Response inner = this.serviceClient().updateWithResponse(siteName, properties, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SiteImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Site update(String siteName, SiteUpdate properties) { + SiteInner inner = this.serviceClient().update(siteName, properties); + if (inner != null) { + return new SiteImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(String siteName, Context context) { + return this.serviceClient().deleteWithResponse(siteName, context); + } + + public void delete(String siteName) { + this.serviceClient().delete(siteName); + } + + private SitesBySubscriptionsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.sitemanager.SitemanagerManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesClientImpl.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesClientImpl.java new file mode 100644 index 000000000000..cff6774cf502 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesClientImpl.java @@ -0,0 +1,904 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.sitemanager.fluent.SitesClient; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.implementation.models.SiteListResult; +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; +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 SitesClient. + */ +public final class SitesClientImpl implements SitesClient { + /** + * The proxy service used to perform REST calls. + */ + private final SitesService service; + + /** + * The service client containing this operation class. + */ + private final EdgeClientImpl client; + + /** + * Initializes an instance of SitesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SitesClientImpl(EdgeClientImpl client) { + this.service = RestProxy.create(SitesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for EdgeClientSites to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "EdgeClientSites") + public interface SitesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("siteName") String siteName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("siteName") String siteName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") SiteInner resource, Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("siteName") String siteName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") SiteUpdate properties, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("siteName") String siteName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("endpoint") 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("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 Site along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, String siteName) { + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName 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, siteName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, String siteName, + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName 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, siteName, accept, context); + } + + /** + * Get a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 Site on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String siteName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, siteName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, String siteName, + Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, siteName, context).block(); + } + + /** + * Get a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 Site. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SiteInner getByResourceGroup(String resourceGroupName, String siteName) { + return getByResourceGroupWithResponse(resourceGroupName, siteName, Context.NONE).getValue(); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String siteName, + SiteInner resource) { + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, siteName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String siteName, + SiteInner resource, 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, siteName, contentType, accept, resource, context); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SiteInner> beginCreateOrUpdateAsync(String resourceGroupName, + String siteName, SiteInner resource) { + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, siteName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), SiteInner.class, + SiteInner.class, this.client.getContext()); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SiteInner> beginCreateOrUpdateAsync(String resourceGroupName, + String siteName, SiteInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, siteName, resource, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), SiteInner.class, + SiteInner.class, context); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SiteInner> beginCreateOrUpdate(String resourceGroupName, String siteName, + SiteInner resource) { + return this.beginCreateOrUpdateAsync(resourceGroupName, siteName, resource).getSyncPoller(); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SiteInner> beginCreateOrUpdate(String resourceGroupName, String siteName, + SiteInner resource, Context context) { + return this.beginCreateOrUpdateAsync(resourceGroupName, siteName, resource, context).getSyncPoller(); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String siteName, SiteInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, siteName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String siteName, SiteInner resource, + Context context) { + return beginCreateOrUpdateAsync(resourceGroupName, siteName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SiteInner createOrUpdate(String resourceGroupName, String siteName, SiteInner resource) { + return createOrUpdateAsync(resourceGroupName, siteName, resource).block(); + } + + /** + * Create a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SiteInner createOrUpdate(String resourceGroupName, String siteName, SiteInner resource, Context context) { + return createOrUpdateAsync(resourceGroupName, siteName, resource, context).block(); + } + + /** + * Update a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceGroupName, String siteName, + SiteUpdate properties) { + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, siteName, contentType, accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceGroupName, String siteName, + SiteUpdate properties, 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, siteName, contentType, accept, properties, context); + } + + /** + * Update a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String siteName, SiteUpdate properties) { + return updateWithResponseAsync(resourceGroupName, siteName, properties) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(String resourceGroupName, String siteName, SiteUpdate properties, + Context context) { + return updateWithResponseAsync(resourceGroupName, siteName, properties, context).block(); + } + + /** + * Update a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SiteInner update(String resourceGroupName, String siteName, SiteUpdate properties) { + return updateWithResponse(resourceGroupName, siteName, properties, Context.NONE).getValue(); + } + + /** + * Delete a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 siteName) { + 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName 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, siteName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 siteName, 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 (siteName == null) { + return Mono.error(new IllegalArgumentException("Parameter siteName 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, siteName, accept, context); + } + + /** + * Delete a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 siteName) { + return deleteWithResponseAsync(resourceGroupName, siteName).flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 siteName, Context context) { + return deleteWithResponseAsync(resourceGroupName, siteName, context).block(); + } + + /** + * Delete a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 siteName) { + deleteWithResponse(resourceGroupName, siteName, Context.NONE); + } + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation 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())); + } + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation 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)); + } + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation 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)); + } + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation 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. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation 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)); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesImpl.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesImpl.java new file mode 100644 index 000000000000..0897ef60ba60 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/SitesImpl.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.sitemanager.fluent.SitesClient; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.models.Site; +import com.azure.resourcemanager.sitemanager.models.Sites; + +public final class SitesImpl implements Sites { + private static final ClientLogger LOGGER = new ClientLogger(SitesImpl.class); + + private final SitesClient innerClient; + + private final com.azure.resourcemanager.sitemanager.SitemanagerManager serviceManager; + + public SitesImpl(SitesClient innerClient, com.azure.resourcemanager.sitemanager.SitemanagerManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, String siteName, Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, siteName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SiteImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Site getByResourceGroup(String resourceGroupName, String siteName) { + SiteInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, siteName); + if (inner != null) { + return new SiteImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteByResourceGroupWithResponse(String resourceGroupName, String siteName, + Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, siteName, context); + } + + public void deleteByResourceGroup(String resourceGroupName, String siteName) { + this.serviceClient().delete(resourceGroupName, siteName); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SiteImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SiteImpl(inner1, this.manager())); + } + + public Site getById(String id) { + String resourceGroupName = ResourceManagerUtils.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 siteName = ResourceManagerUtils.getValueFromIdByName(id, "sites"); + if (siteName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'sites'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, siteName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.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 siteName = ResourceManagerUtils.getValueFromIdByName(id, "sites"); + if (siteName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'sites'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, siteName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.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 siteName = ResourceManagerUtils.getValueFromIdByName(id, "sites"); + if (siteName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'sites'.", id))); + } + this.deleteByResourceGroupWithResponse(resourceGroupName, siteName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.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 siteName = ResourceManagerUtils.getValueFromIdByName(id, "sites"); + if (siteName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'sites'.", id))); + } + return this.deleteByResourceGroupWithResponse(resourceGroupName, siteName, context); + } + + private SitesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.sitemanager.SitemanagerManager manager() { + return this.serviceManager; + } + + public SiteImpl define(String name) { + return new SiteImpl(name, this.manager()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/models/SiteListResult.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/models/SiteListResult.java new file mode 100644 index 000000000000..3ce12fc50c9b --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/models/SiteListResult.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a Site list operation. + */ +@Immutable +public final class SiteListResult implements JsonSerializable { + /* + * The Site items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of SiteListResult class. + */ + private SiteListResult() { + } + + /** + * Get the value property: The Site items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @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) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model SiteListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SiteListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SiteListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SiteListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SiteListResult. + */ + public static SiteListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SiteListResult deserializedSiteListResult = new SiteListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> SiteInner.fromJson(reader1)); + deserializedSiteListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedSiteListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSiteListResult; + }); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/package-info.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/implementation/package-info.java new file mode 100644 index 000000000000..6bd6d6e72f52 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/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) TypeSpec Code Generator. + +/** + * Package containing the implementations for Edge. + * Azure Edge Sites Resource Provider management API. + */ +package com.azure.resourcemanager.sitemanager.implementation; diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/ResourceProvisioningState.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/ResourceProvisioningState.java new file mode 100644 index 000000000000..11d488447d1b --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/ResourceProvisioningState.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The provisioning state of a resource type. + */ +public final class ResourceProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ResourceProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ResourceProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ResourceProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ResourceProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ResourceProvisioningState() { + } + + /** + * Creates or finds a ResourceProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResourceProvisioningState. + */ + public static ResourceProvisioningState fromString(String name) { + return fromString(name, ResourceProvisioningState.class); + } + + /** + * Gets known ResourceProvisioningState values. + * + * @return known ResourceProvisioningState values. + */ + public static Collection values() { + return values(ResourceProvisioningState.class); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/Site.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/Site.java new file mode 100644 index 000000000000..87f02314c155 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/Site.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; + +/** + * An immutable client-side representation of Site. + */ +public interface Site { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + SiteProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.sitemanager.fluent.models.SiteInner object. + * + * @return the inner object. + */ + SiteInner innerModel(); + + /** + * The entirety of the Site definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The Site definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the Site definition. + */ + interface Blank extends WithResourceGroup { + } + + /** + * The stage of the Site definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the Site definition which contains all the minimum required properties for the resource to be + * created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + Site create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + Site create(Context context); + } + + /** + * The stage of the Site definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(SiteProperties properties); + } + } + + /** + * Begins update for the Site resource. + * + * @return the stage of resource update. + */ + Site.Update update(); + + /** + * The template for Site update. + */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + Site apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + Site apply(Context context); + } + + /** + * The Site update stages. + */ + interface UpdateStages { + /** + * The stage of the Site update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The updatable properties of the Site.. + * + * @param properties The updatable properties of the Site. + * @return the next definition stage. + */ + Update withProperties(SiteUpdateProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + Site refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + Site refresh(Context context); +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SiteProperties.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SiteProperties.java new file mode 100644 index 000000000000..a285fd77fcf1 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SiteProperties.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Site properties. + */ +@Fluent +public final class SiteProperties implements JsonSerializable { + /* + * displayName of Site resource + */ + private String displayName; + + /* + * Description of Site resource + */ + private String description; + + /* + * AddressResource ArmId of Site resource + */ + private String addressResourceId; + + /* + * Provisioning state of last operation + */ + private ResourceProvisioningState provisioningState; + + /** + * Creates an instance of SiteProperties class. + */ + public SiteProperties() { + } + + /** + * Get the displayName property: displayName of Site resource. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: displayName of Site resource. + * + * @param displayName the displayName value to set. + * @return the SiteProperties object itself. + */ + public SiteProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the description property: Description of Site resource. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: Description of Site resource. + * + * @param description the description value to set. + * @return the SiteProperties object itself. + */ + public SiteProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the addressResourceId property: AddressResource ArmId of Site resource. + * + * @return the addressResourceId value. + */ + public String addressResourceId() { + return this.addressResourceId; + } + + /** + * Set the addressResourceId property: AddressResource ArmId of Site resource. + * + * @param addressResourceId the addressResourceId value to set. + * @return the SiteProperties object itself. + */ + public SiteProperties withAddressResourceId(String addressResourceId) { + this.addressResourceId = addressResourceId; + return this; + } + + /** + * Get the provisioningState property: Provisioning state of last operation. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("displayName", this.displayName); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("addressResourceId", this.addressResourceId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SiteProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SiteProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the SiteProperties. + */ + public static SiteProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SiteProperties deserializedSiteProperties = new SiteProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("displayName".equals(fieldName)) { + deserializedSiteProperties.displayName = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedSiteProperties.description = reader.getString(); + } else if ("addressResourceId".equals(fieldName)) { + deserializedSiteProperties.addressResourceId = reader.getString(); + } else if ("provisioningState".equals(fieldName)) { + deserializedSiteProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedSiteProperties; + }); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SiteUpdate.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SiteUpdate.java new file mode 100644 index 000000000000..49129a1361e0 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SiteUpdate.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The type used for update operations of the Site. + */ +@Fluent +public final class SiteUpdate implements JsonSerializable { + /* + * The updatable properties of the Site. + */ + private SiteUpdateProperties properties; + + /** + * Creates an instance of SiteUpdate class. + */ + public SiteUpdate() { + } + + /** + * Get the properties property: The updatable properties of the Site. + * + * @return the properties value. + */ + public SiteUpdateProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The updatable properties of the Site. + * + * @param properties the properties value to set. + * @return the SiteUpdate object itself. + */ + public SiteUpdate withProperties(SiteUpdateProperties properties) { + this.properties = properties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SiteUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SiteUpdate if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the SiteUpdate. + */ + public static SiteUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SiteUpdate deserializedSiteUpdate = new SiteUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("properties".equals(fieldName)) { + deserializedSiteUpdate.properties = SiteUpdateProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSiteUpdate; + }); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SiteUpdateProperties.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SiteUpdateProperties.java new file mode 100644 index 000000000000..35a21903db9b --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SiteUpdateProperties.java @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The updatable properties of the Site. + */ +@Fluent +public final class SiteUpdateProperties implements JsonSerializable { + /* + * displayName of Site resource + */ + private String displayName; + + /* + * Description of Site resource + */ + private String description; + + /* + * AddressResource ArmId of Site resource + */ + private String addressResourceId; + + /** + * Creates an instance of SiteUpdateProperties class. + */ + public SiteUpdateProperties() { + } + + /** + * Get the displayName property: displayName of Site resource. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: displayName of Site resource. + * + * @param displayName the displayName value to set. + * @return the SiteUpdateProperties object itself. + */ + public SiteUpdateProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the description property: Description of Site resource. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: Description of Site resource. + * + * @param description the description value to set. + * @return the SiteUpdateProperties object itself. + */ + public SiteUpdateProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the addressResourceId property: AddressResource ArmId of Site resource. + * + * @return the addressResourceId value. + */ + public String addressResourceId() { + return this.addressResourceId; + } + + /** + * Set the addressResourceId property: AddressResource ArmId of Site resource. + * + * @param addressResourceId the addressResourceId value to set. + * @return the SiteUpdateProperties object itself. + */ + public SiteUpdateProperties withAddressResourceId(String addressResourceId) { + this.addressResourceId = addressResourceId; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("displayName", this.displayName); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("addressResourceId", this.addressResourceId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SiteUpdateProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SiteUpdateProperties if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the SiteUpdateProperties. + */ + public static SiteUpdateProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SiteUpdateProperties deserializedSiteUpdateProperties = new SiteUpdateProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("displayName".equals(fieldName)) { + deserializedSiteUpdateProperties.displayName = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedSiteUpdateProperties.description = reader.getString(); + } else if ("addressResourceId".equals(fieldName)) { + deserializedSiteUpdateProperties.addressResourceId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSiteUpdateProperties; + }); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/Sites.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/Sites.java new file mode 100644 index 000000000000..2320ad32c5b7 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/Sites.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of Sites. + */ +public interface Sites { + /** + * Get a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String siteName, Context context); + + /** + * Get a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site. + */ + Site getByResourceGroup(String resourceGroupName, String siteName); + + /** + * Delete a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 siteName, Context context); + + /** + * Delete a Site. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param siteName Name of Site 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 siteName); + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List Site resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get a Site. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response}. + */ + Site getById(String id); + + /** + * Get a Site. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a Site. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a Site. + * + * @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 Site resource. + * + * @param name resource name. + * @return the first stage of the new Site definition. + */ + Site.DefinitionStages.Blank define(String name); +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SitesBySubscriptions.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SitesBySubscriptions.java new file mode 100644 index 000000000000..8382c3a1e01c --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/SitesBySubscriptions.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; + +/** + * Resource collection API of SitesBySubscriptions. + */ +public interface SitesBySubscriptions { + /** + * List Site resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List Site resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Site list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * Get a Site. + * + * @param siteName Name of Site resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site along with {@link Response}. + */ + Response getWithResponse(String siteName, Context context); + + /** + * Get a Site. + * + * @param siteName Name of Site resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Site. + */ + Site get(String siteName); + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + Site createOrUpdate(String siteName, SiteInner resource); + + /** + * Create a Site. + * + * @param siteName Name of Site resource. + * @param resource Resource create parameters. + * @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 site as ARM Resource. + */ + Site createOrUpdate(String siteName, SiteInner resource, Context context); + + /** + * Update a Site. + * + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource along with {@link Response}. + */ + Response updateWithResponse(String siteName, SiteUpdate properties, Context context); + + /** + * Update a Site. + * + * @param siteName Name of Site resource. + * @param properties The resource properties to be updated. + * @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 site as ARM Resource. + */ + Site update(String siteName, SiteUpdate properties); + + /** + * Delete a Site. + * + * @param siteName Name of Site 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 deleteWithResponse(String siteName, Context context); + + /** + * Delete a Site. + * + * @param siteName Name of Site 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 delete(String siteName); +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/package-info.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/models/package-info.java new file mode 100644 index 000000000000..5ca09a9e7741 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/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) TypeSpec Code Generator. + +/** + * Package containing the data models for Edge. + * Azure Edge Sites Resource Provider management API. + */ +package com.azure.resourcemanager.sitemanager.models; diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/package-info.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/package-info.java new file mode 100644 index 000000000000..9410a98ac2e7 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/com/azure/resourcemanager/sitemanager/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Edge. + * Azure Edge Sites Resource Provider management API. + */ +package com.azure.resourcemanager.sitemanager; diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/module-info.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/module-info.java new file mode 100644 index 000000000000..2f62492bafc9 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/java/module-info.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.resourcemanager.sitemanager { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.sitemanager; + exports com.azure.resourcemanager.sitemanager.fluent; + exports com.azure.resourcemanager.sitemanager.fluent.models; + exports com.azure.resourcemanager.sitemanager.models; + + opens com.azure.resourcemanager.sitemanager.fluent.models to com.azure.core; + opens com.azure.resourcemanager.sitemanager.models to com.azure.core; + opens com.azure.resourcemanager.sitemanager.implementation.models to com.azure.core; +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-sitemanager/proxy-config.json b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-sitemanager/proxy-config.json new file mode 100644 index 000000000000..7d5dd91f6760 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-sitemanager/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.sitemanager.implementation.SitesBySubscriptionsClientImpl$SitesBySubscriptionsService"],["com.azure.resourcemanager.sitemanager.implementation.SitesClientImpl$SitesService"]] \ No newline at end of file diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-sitemanager/reflect-config.json b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-sitemanager/reflect-config.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-sitemanager/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/resources/azure-resourcemanager-sitemanager.properties b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/resources/azure-resourcemanager-sitemanager.properties new file mode 100644 index 000000000000..defbd48204e4 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/main/resources/azure-resourcemanager-sitemanager.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionCreateOrUpdateSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionCreateOrUpdateSamples.java new file mode 100644 index 000000000000..4ef1eac2ab60 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionCreateOrUpdateSamples.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.models.SiteProperties; + +/** + * Samples for SitesBySubscription CreateOrUpdate. + */ +public final class SitesBySubscriptionCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_CreateOrUpdate.json + */ + /** + * Sample code: Create Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void createSiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions() + .createOrUpdate("string", new SiteInner().withProperties(new SiteProperties().withDisplayName("string") + .withDescription("string") + .withAddressResourceId( + "/subscriptions/680d0dad-59aa-4464-3df3-b34b2b42738c/resourceGroups/us-site-rg/providers/Microsoft.EdgeOrder/addresses/12343213")), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionDeleteSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionDeleteSamples.java new file mode 100644 index 000000000000..5aa41e868216 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +/** + * Samples for SitesBySubscription Delete. + */ +public final class SitesBySubscriptionDeleteSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_Delete.json + */ + /** + * Sample code: Delete Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void deleteSiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions().deleteWithResponse("string", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionGetSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionGetSamples.java new file mode 100644 index 000000000000..3f15fb5d6631 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionGetSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +/** + * Samples for SitesBySubscription Get. + */ +public final class SitesBySubscriptionGetSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_Get.json + */ + /** + * Sample code: Get Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void getSiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions().getWithResponse("string", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionListSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionListSamples.java new file mode 100644 index 000000000000..78904d6ebe14 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +/** + * Samples for SitesBySubscription List. + */ +public final class SitesBySubscriptionListSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_List.json + */ + /** + * Sample code: List by Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void listBySubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionUpdateSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionUpdateSamples.java new file mode 100644 index 000000000000..36cac6831824 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionUpdateSamples.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; +import com.azure.resourcemanager.sitemanager.models.SiteUpdateProperties; + +/** + * Samples for SitesBySubscription Update. + */ +public final class SitesBySubscriptionUpdateSamples { + /* + * x-ms-original-file: 2024-02-01-preview/SitesBySubscription_Update.json + */ + /** + * Sample code: Patch Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void patchSiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sitesBySubscriptions() + .updateWithResponse("string", new SiteUpdate().withProperties(new SiteUpdateProperties() + .withDisplayName("string") + .withDescription("string") + .withAddressResourceId( + "/subscriptions/0154f7fe-df09-4981-bf82-7ad5c1f596eb/resourceGroups/us-site-rg/providers/Microsoft.EdgeOrder/addresses/12343213")), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesCreateOrUpdateSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesCreateOrUpdateSamples.java new file mode 100644 index 000000000000..f3680bff7fda --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesCreateOrUpdateSamples.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.resourcemanager.sitemanager.models.SiteProperties; + +/** + * Samples for Sites CreateOrUpdate. + */ +public final class SitesCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_CreateOrUpdate.json + */ + /** + * Sample code: Create or update Site. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void createOrUpdateSite(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sites() + .define("string") + .withExistingResourceGroup("string") + .withProperties(new SiteProperties().withDisplayName("string") + .withDescription("string") + .withAddressResourceId( + "/subscriptions/680d0dad-59aa-4464-3df3-b34b2b42738c/resourceGroups/us-site-rg/providers/Microsoft.EdgeOrder/addresses/12343213")) + .create(); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesDeleteSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesDeleteSamples.java new file mode 100644 index 000000000000..8f67581fcd2e --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +/** + * Samples for Sites Delete. + */ +public final class SitesDeleteSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_Delete.json + */ + /** + * Sample code: Delete Site. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void deleteSite(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sites().deleteByResourceGroupWithResponse("string", "string", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesGetByResourceGroupSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesGetByResourceGroupSamples.java new file mode 100644 index 000000000000..1e4f0c8921d5 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesGetByResourceGroupSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +/** + * Samples for Sites GetByResourceGroup. + */ +public final class SitesGetByResourceGroupSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_Get.json + */ + /** + * Sample code: Get Site. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void getSite(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sites().getByResourceGroupWithResponse("string", "string", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesListByResourceGroupSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesListByResourceGroupSamples.java new file mode 100644 index 000000000000..7303dec4540b --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesListByResourceGroupSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +/** + * Samples for Sites ListByResourceGroup. + */ +public final class SitesListByResourceGroupSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_ListByResourceGroup.json + */ + /** + * Sample code: List by Site Subscription. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void listBySiteSubscription(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + manager.sites().listByResourceGroup("string", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesUpdateSamples.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesUpdateSamples.java new file mode 100644 index 000000000000..c62986489370 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/samples/java/com/azure/resourcemanager/sitemanager/generated/SitesUpdateSamples.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.resourcemanager.sitemanager.models.Site; +import com.azure.resourcemanager.sitemanager.models.SiteUpdateProperties; + +/** + * Samples for Sites Update. + */ +public final class SitesUpdateSamples { + /* + * x-ms-original-file: 2024-02-01-preview/Sites_Update.json + */ + /** + * Sample code: Update Site. + * + * @param manager Entry point to SitemanagerManager. + */ + public static void updateSite(com.azure.resourcemanager.sitemanager.SitemanagerManager manager) { + Site resource = manager.sites() + .getByResourceGroupWithResponse("string", "string", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withProperties(new SiteUpdateProperties().withDisplayName("string") + .withDescription("string") + .withAddressResourceId( + "/subscriptions/11111111-2222-3333-4444-55555555/resourceGroups/us-site-rg/providers/Microsoft.EdgeOrder/addresses/12343213")) + .apply(); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteInnerTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteInnerTests.java new file mode 100644 index 000000000000..73c53ddf1425 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteInnerTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.models.SiteProperties; +import org.junit.jupiter.api.Assertions; + +public final class SiteInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SiteInner model = BinaryData.fromString( + "{\"properties\":{\"displayName\":\"hq\",\"description\":\"gjxpybczmehmt\",\"addressResourceId\":\"pbsphrupidgs\",\"provisioningState\":\"Succeeded\"},\"id\":\"jhphoyc\",\"name\":\"sx\",\"type\":\"obhdxbmtqioqjze\"}") + .toObject(SiteInner.class); + Assertions.assertEquals("hq", model.properties().displayName()); + Assertions.assertEquals("gjxpybczmehmt", model.properties().description()); + Assertions.assertEquals("pbsphrupidgs", model.properties().addressResourceId()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SiteInner model = new SiteInner().withProperties(new SiteProperties().withDisplayName("hq") + .withDescription("gjxpybczmehmt") + .withAddressResourceId("pbsphrupidgs")); + model = BinaryData.fromObject(model).toObject(SiteInner.class); + Assertions.assertEquals("hq", model.properties().displayName()); + Assertions.assertEquals("gjxpybczmehmt", model.properties().description()); + Assertions.assertEquals("pbsphrupidgs", model.properties().addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteListResultTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteListResultTests.java new file mode 100644 index 000000000000..f850591a5cf7 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteListResultTests.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.sitemanager.implementation.models.SiteListResult; +import org.junit.jupiter.api.Assertions; + +public final class SiteListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SiteListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"displayName\":\"qucmpo\",\"description\":\"dkfo\",\"addressResourceId\":\"nygj\",\"provisioningState\":\"Canceled\"},\"id\":\"deqsrdeupewn\",\"name\":\"reitjzyflusar\",\"type\":\"mofcq\"}],\"nextLink\":\"my\"}") + .toObject(SiteListResult.class); + Assertions.assertEquals("qucmpo", model.value().get(0).properties().displayName()); + Assertions.assertEquals("dkfo", model.value().get(0).properties().description()); + Assertions.assertEquals("nygj", model.value().get(0).properties().addressResourceId()); + Assertions.assertEquals("my", model.nextLink()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitePropertiesTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitePropertiesTests.java new file mode 100644 index 000000000000..4e5366026347 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitePropertiesTests.java @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.sitemanager.models.SiteProperties; +import org.junit.jupiter.api.Assertions; + +public final class SitePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SiteProperties model = BinaryData.fromString( + "{\"displayName\":\"bmufpown\",\"description\":\"zhwlrxy\",\"addressResourceId\":\"soqijg\",\"provisioningState\":\"Canceled\"}") + .toObject(SiteProperties.class); + Assertions.assertEquals("bmufpown", model.displayName()); + Assertions.assertEquals("zhwlrxy", model.description()); + Assertions.assertEquals("soqijg", model.addressResourceId()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SiteProperties model = new SiteProperties().withDisplayName("bmufpown") + .withDescription("zhwlrxy") + .withAddressResourceId("soqijg"); + model = BinaryData.fromObject(model).toObject(SiteProperties.class); + Assertions.assertEquals("bmufpown", model.displayName()); + Assertions.assertEquals("zhwlrxy", model.description()); + Assertions.assertEquals("soqijg", model.addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteUpdatePropertiesTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteUpdatePropertiesTests.java new file mode 100644 index 000000000000..e8995fdc48b0 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteUpdatePropertiesTests.java @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.sitemanager.models.SiteUpdateProperties; +import org.junit.jupiter.api.Assertions; + +public final class SiteUpdatePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SiteUpdateProperties model = BinaryData + .fromString("{\"displayName\":\"lhjxr\",\"description\":\"kwm\",\"addressResourceId\":\"ktsizntocipaou\"}") + .toObject(SiteUpdateProperties.class); + Assertions.assertEquals("lhjxr", model.displayName()); + Assertions.assertEquals("kwm", model.description()); + Assertions.assertEquals("ktsizntocipaou", model.addressResourceId()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SiteUpdateProperties model = new SiteUpdateProperties().withDisplayName("lhjxr") + .withDescription("kwm") + .withAddressResourceId("ktsizntocipaou"); + model = BinaryData.fromObject(model).toObject(SiteUpdateProperties.class); + Assertions.assertEquals("lhjxr", model.displayName()); + Assertions.assertEquals("kwm", model.description()); + Assertions.assertEquals("ktsizntocipaou", model.addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteUpdateTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteUpdateTests.java new file mode 100644 index 000000000000..9ffb22c69f87 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SiteUpdateTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; +import com.azure.resourcemanager.sitemanager.models.SiteUpdateProperties; +import org.junit.jupiter.api.Assertions; + +public final class SiteUpdateTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SiteUpdate model = BinaryData.fromString( + "{\"properties\":{\"displayName\":\"azlobcufpdznrbt\",\"description\":\"qjnqglhqgnufoooj\",\"addressResourceId\":\"ifsqesaagdfmg\"}}") + .toObject(SiteUpdate.class); + Assertions.assertEquals("azlobcufpdznrbt", model.properties().displayName()); + Assertions.assertEquals("qjnqglhqgnufoooj", model.properties().description()); + Assertions.assertEquals("ifsqesaagdfmg", model.properties().addressResourceId()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SiteUpdate model = new SiteUpdate().withProperties(new SiteUpdateProperties().withDisplayName("azlobcufpdznrbt") + .withDescription("qjnqglhqgnufoooj") + .withAddressResourceId("ifsqesaagdfmg")); + model = BinaryData.fromObject(model).toObject(SiteUpdate.class); + Assertions.assertEquals("azlobcufpdznrbt", model.properties().displayName()); + Assertions.assertEquals("qjnqglhqgnufoooj", model.properties().description()); + Assertions.assertEquals("ifsqesaagdfmg", model.properties().addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsCreateOrUpdateMockTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsCreateOrUpdateMockTests.java new file mode 100644 index 000000000000..06400e69742d --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsCreateOrUpdateMockTests.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.sitemanager.SitemanagerManager; +import com.azure.resourcemanager.sitemanager.fluent.models.SiteInner; +import com.azure.resourcemanager.sitemanager.models.Site; +import com.azure.resourcemanager.sitemanager.models.SiteProperties; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SitesBySubscriptionsCreateOrUpdateMockTests { + @Test + public void testCreateOrUpdate() throws Exception { + String responseStr + = "{\"properties\":{\"displayName\":\"cqvkocrcjdkwtn\",\"description\":\"bnjbiksqrglssain\",\"addressResourceId\":\"jwnzlljfmp\",\"provisioningState\":\"Succeeded\"},\"id\":\"vmgxsab\",\"name\":\"yqduujit\",\"type\":\"jczdzevndh\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SitemanagerManager manager = SitemanagerManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Site response = manager.sitesBySubscriptions() + .createOrUpdate("nhungbw", + new SiteInner().withProperties(new SiteProperties().withDisplayName("nfygxgispemvtz") + .withDescription("ufubl") + .withAddressResourceId("fxqeof")), + com.azure.core.util.Context.NONE); + + Assertions.assertEquals("cqvkocrcjdkwtn", response.properties().displayName()); + Assertions.assertEquals("bnjbiksqrglssain", response.properties().description()); + Assertions.assertEquals("jwnzlljfmp", response.properties().addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsDeleteWithResponseMockTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsDeleteWithResponseMockTests.java new file mode 100644 index 000000000000..626e08ed503b --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsDeleteWithResponseMockTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.sitemanager.SitemanagerManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SitesBySubscriptionsDeleteWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SitemanagerManager manager = SitemanagerManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.sitesBySubscriptions().deleteWithResponse("pnddhsgcbacphejk", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsGetWithResponseMockTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsGetWithResponseMockTests.java new file mode 100644 index 000000000000..545ca9222c40 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsGetWithResponseMockTests.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.sitemanager.SitemanagerManager; +import com.azure.resourcemanager.sitemanager.models.Site; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SitesBySubscriptionsGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"displayName\":\"eqfpj\",\"description\":\"lxofpdvhpfxxypin\",\"addressResourceId\":\"mayhuybbkpodepoo\",\"provisioningState\":\"Canceled\"},\"id\":\"vamih\",\"name\":\"ognarxzxtheotus\",\"type\":\"vyevcciqi\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SitemanagerManager manager = SitemanagerManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Site response = manager.sitesBySubscriptions() + .getWithResponse("xjtfelluwfzit", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("eqfpj", response.properties().displayName()); + Assertions.assertEquals("lxofpdvhpfxxypin", response.properties().description()); + Assertions.assertEquals("mayhuybbkpodepoo", response.properties().addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsListMockTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsListMockTests.java new file mode 100644 index 000000000000..ee41913e3c85 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsListMockTests.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.sitemanager.SitemanagerManager; +import com.azure.resourcemanager.sitemanager.models.Site; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SitesBySubscriptionsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"displayName\":\"hbcryffdfdosyge\",\"description\":\"aojakhmsbzjhcrz\",\"addressResourceId\":\"dphlxaolt\",\"provisioningState\":\"Succeeded\"},\"id\":\"gqjbpfzfsin\",\"name\":\"gvfcj\",\"type\":\"wzo\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SitemanagerManager manager = SitemanagerManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.sitesBySubscriptions().list(com.azure.core.util.Context.NONE); + + Assertions.assertEquals("hbcryffdfdosyge", response.iterator().next().properties().displayName()); + Assertions.assertEquals("aojakhmsbzjhcrz", response.iterator().next().properties().description()); + Assertions.assertEquals("dphlxaolt", response.iterator().next().properties().addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsUpdateWithResponseMockTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..49e37ee54cdb --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesBySubscriptionsUpdateWithResponseMockTests.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.sitemanager.SitemanagerManager; +import com.azure.resourcemanager.sitemanager.models.Site; +import com.azure.resourcemanager.sitemanager.models.SiteUpdate; +import com.azure.resourcemanager.sitemanager.models.SiteUpdateProperties; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SitesBySubscriptionsUpdateWithResponseMockTests { + @Test + public void testUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"displayName\":\"xhocdgeablgphuti\",\"description\":\"dvkaozw\",\"addressResourceId\":\"ftyhxhurokf\",\"provisioningState\":\"Canceled\"},\"id\":\"lniwpwcukjfkgiaw\",\"name\":\"klryplwck\",\"type\":\"asy\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SitemanagerManager manager = SitemanagerManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Site response = manager.sitesBySubscriptions() + .updateWithResponse("rwpdappdsbdkvwrw", + new SiteUpdate().withProperties(new SiteUpdateProperties().withDisplayName("usnhutje") + .withDescription("mrldhu") + .withAddressResourceId("zzd")), + com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("xhocdgeablgphuti", response.properties().displayName()); + Assertions.assertEquals("dvkaozw", response.properties().description()); + Assertions.assertEquals("ftyhxhurokf", response.properties().addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesCreateOrUpdateMockTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesCreateOrUpdateMockTests.java new file mode 100644 index 000000000000..f13b75bb69c2 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesCreateOrUpdateMockTests.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.sitemanager.SitemanagerManager; +import com.azure.resourcemanager.sitemanager.models.Site; +import com.azure.resourcemanager.sitemanager.models.SiteProperties; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SitesCreateOrUpdateMockTests { + @Test + public void testCreateOrUpdate() throws Exception { + String responseStr + = "{\"properties\":{\"displayName\":\"putegjvwmfd\",\"description\":\"scmdvpjhulsuu\",\"addressResourceId\":\"kjozkrwfnd\",\"provisioningState\":\"Succeeded\"},\"id\":\"pslwejdpvw\",\"name\":\"yoqpsoaccta\",\"type\":\"akl\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SitemanagerManager manager = SitemanagerManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Site response = manager.sites() + .define("nhsjcnyej") + .withExistingResourceGroup("gaudcc") + .withProperties(new SiteProperties().withDisplayName("yhtnapczwlokjye") + .withDescription("kvnipjoxz") + .withAddressResourceId("chgejspodm")) + .create(); + + Assertions.assertEquals("putegjvwmfd", response.properties().displayName()); + Assertions.assertEquals("scmdvpjhulsuu", response.properties().description()); + Assertions.assertEquals("kjozkrwfnd", response.properties().addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesDeleteByResourceGroupWithResponseMockTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesDeleteByResourceGroupWithResponseMockTests.java new file mode 100644 index 000000000000..53acf469ac69 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesDeleteByResourceGroupWithResponseMockTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.sitemanager.SitemanagerManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SitesDeleteByResourceGroupWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SitemanagerManager manager = SitemanagerManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.sites() + .deleteByResourceGroupWithResponse("yzkohdbihanuf", "fcbjysagithxqha", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesGetByResourceGroupWithResponseMockTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesGetByResourceGroupWithResponseMockTests.java new file mode 100644 index 000000000000..dab191dd11f1 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesGetByResourceGroupWithResponseMockTests.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.sitemanager.SitemanagerManager; +import com.azure.resourcemanager.sitemanager.models.Site; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SitesGetByResourceGroupWithResponseMockTests { + @Test + public void testGetByResourceGroupWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"displayName\":\"cryuan\",\"description\":\"uxzdxtay\",\"addressResourceId\":\"hmwhfpmrqo\",\"provisioningState\":\"Failed\"},\"id\":\"kknryrtihf\",\"name\":\"tijbpzvgnwzsymgl\",\"type\":\"uf\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SitemanagerManager manager = SitemanagerManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Site response = manager.sites() + .getByResourceGroupWithResponse("rkdtmlxh", "kuksjtxukcdm", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("cryuan", response.properties().displayName()); + Assertions.assertEquals("uxzdxtay", response.properties().description()); + Assertions.assertEquals("hmwhfpmrqo", response.properties().addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesListByResourceGroupMockTests.java b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesListByResourceGroupMockTests.java new file mode 100644 index 000000000000..a2fb942c9981 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/src/test/java/com/azure/resourcemanager/sitemanager/generated/SitesListByResourceGroupMockTests.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.sitemanager.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.sitemanager.SitemanagerManager; +import com.azure.resourcemanager.sitemanager.models.Site; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SitesListByResourceGroupMockTests { + @Test + public void testListByResourceGroup() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"displayName\":\"pqxu\",\"description\":\"vyq\",\"addressResourceId\":\"wby\",\"provisioningState\":\"Failed\"},\"id\":\"vd\",\"name\":\"mjgr\",\"type\":\"fwvuk\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SitemanagerManager manager = SitemanagerManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response + = manager.sites().listByResourceGroup("ifpikxwczby", com.azure.core.util.Context.NONE); + + Assertions.assertEquals("pqxu", response.iterator().next().properties().displayName()); + Assertions.assertEquals("vyq", response.iterator().next().properties().description()); + Assertions.assertEquals("wby", response.iterator().next().properties().addressResourceId()); + } +} diff --git a/sdk/sitemanager/azure-resourcemanager-sitemanager/tsp-location.yaml b/sdk/sitemanager/azure-resourcemanager-sitemanager/tsp-location.yaml new file mode 100644 index 000000000000..a0c4ea3fe8c2 --- /dev/null +++ b/sdk/sitemanager/azure-resourcemanager-sitemanager/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/edge/Microsoft.Edge.Sites.Management +commit: 6e702986ee542ebd38d0ab2e2f2c00ab48a50b45 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/sitemanager/ci.yml b/sdk/sitemanager/ci.yml new file mode 100644 index 000000000000..3bb6a5cd73c9 --- /dev/null +++ b/sdk/sitemanager/ci.yml @@ -0,0 +1,46 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/sitemanager/ci.yml + - sdk/sitemanager/azure-resourcemanager-sitemanager/ + exclude: + - sdk/sitemanager/pom.xml + - sdk/sitemanager/azure-resourcemanager-sitemanager/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/sitemanager/ci.yml + - sdk/sitemanager/azure-resourcemanager-sitemanager/ + exclude: + - sdk/sitemanager/pom.xml + - sdk/sitemanager/azure-resourcemanager-sitemanager/pom.xml + +parameters: + - name: release_azureresourcemanagersitemanager + displayName: azure-resourcemanager-sitemanager + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: sitemanager + Artifacts: + - name: azure-resourcemanager-sitemanager + groupId: com.azure.resourcemanager + safeName: azureresourcemanagersitemanager + releaseInBatch: ${{ parameters.release_azureresourcemanagersitemanager }} diff --git a/sdk/sitemanager/pom.xml b/sdk/sitemanager/pom.xml new file mode 100644 index 000000000000..d1e803ffa368 --- /dev/null +++ b/sdk/sitemanager/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-sitemanager-service + pom + 1.0.0 + + + azure-resourcemanager-sitemanager + +