diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index f2ebf6c2ebdf..8dd02f6d016f 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-portalservicescopilot;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..4ace2c703c6e 100644 --- a/pom.xml +++ b/pom.xml @@ -173,6 +173,7 @@ sdk/pineconevectordb sdk/playwrighttesting sdk/policyinsights + sdk/portalservices sdk/postgresql sdk/postgresqlflexibleserver sdk/powerbidedicated diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/CHANGELOG.md b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/CHANGELOG.md new file mode 100644 index 000000000000..e6f44c701d71 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2025-04-11) + +- Azure Resource Manager portalservicescopilot client library for Java. This package contains Microsoft Azure SDK for portalservicescopilot Management SDK. Azure Portal Services API Reference. 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-portalservicescopilot Java SDK. diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/README.md b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/README.md new file mode 100644 index 000000000000..d936a1ce27d1 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager portalservicescopilot client library for Java + +Azure Resource Manager portalservicescopilot client library for Java. + +This package contains Microsoft Azure SDK for portalservicescopilot Management SDK. Azure Portal Services API Reference. 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-portalservicescopilot;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-portalservicescopilot + 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(); +PortalservicescopilotManager manager = PortalservicescopilotManager + .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/portalservices/azure-resourcemanager-portalservicescopilot/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/portalservices/azure-resourcemanager-portalservicescopilot/SAMPLE.md b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/SAMPLE.md new file mode 100644 index 000000000000..86d8b60d4e24 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/SAMPLE.md @@ -0,0 +1,135 @@ +# Code snippets and samples + + +## CopilotSettings + +- [CreateOrUpdate](#copilotsettings_createorupdate) +- [Delete](#copilotsettings_delete) +- [Get](#copilotsettings_get) +- [Update](#copilotsettings_update) + +## Operations + +- [List](#operations_list) +### CopilotSettings_CreateOrUpdate + +```java +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdate; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdateProperties; + +/** + * Samples for CopilotSettings Update. + */ +public final class CopilotSettingsUpdateSamples { + /* + * x-ms-original-file: 2024-04-01-preview/CopilotSettings_Update.json + */ + /** + * Sample code: Update Copilot Settings. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void + updateCopilotSettings(com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.copilotSettings() + .updateWithResponse( + new CopilotSettingsResourceUpdate() + .withProperties(new CopilotSettingsResourceUpdateProperties().withAccessControlEnabled(true)), + com.azure.core.util.Context.NONE); + } +} +``` + +### CopilotSettings_Delete + +```java +/** + * Samples for CopilotSettings Delete. + */ +public final class CopilotSettingsDeleteSamples { + /* + * x-ms-original-file: 2024-04-01-preview/CopilotSettings_Delete.json + */ + /** + * Sample code: Delete Copilot Settings. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void + deleteCopilotSettings(com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.copilotSettings().deleteWithResponse(com.azure.core.util.Context.NONE); + } +} +``` + +### CopilotSettings_Get + +```java +/** + * Samples for CopilotSettings Get. + */ +public final class CopilotSettingsGetSamples { + /* + * x-ms-original-file: 2024-04-01-preview/CopilotSettings_Get.json + */ + /** + * Sample code: Get Copilot Settings. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void + getCopilotSettings(com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.copilotSettings().getWithResponse(com.azure.core.util.Context.NONE); + } +} +``` + +### CopilotSettings_Update + +```java +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2024-04-01-preview/Operations_List.json + */ + /** + * Sample code: List the operations for the Microsoft.PortalServices provider. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void listTheOperationsForTheMicrosoftPortalServicesProvider( + com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Operations_List + +```java +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsProperties; + +/** + * Samples for CopilotSettings CreateOrUpdate. + */ +public final class CopilotSettingsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-04-01-preview/CopilotSettings_CreateOrUpdate.json + */ + /** + * Sample code: Create a new Copilot settings or update an existing one. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void createANewCopilotSettingsOrUpdateAnExistingOne( + com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.copilotSettings() + .createOrUpdateWithResponse(new CopilotSettingsResourceInner().withProperties( + new CopilotSettingsProperties().withAccessControlEnabled(true)), com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/pom.xml b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/pom.xml new file mode 100644 index 000000000000..02083d1721ae --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/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-portalservicescopilot + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for portalservicescopilot Management + This package contains Microsoft Azure SDK for portalservicescopilot Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Portal Services API Reference. + 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/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/PortalservicescopilotManager.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/PortalservicescopilotManager.java new file mode 100644 index 000000000000..d41b9c9f2cd5 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/PortalservicescopilotManager.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.portalservicescopilot; + +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.portalservicescopilot.fluent.PortalServicesClient; +import com.azure.resourcemanager.portalservicescopilot.implementation.CopilotSettingsImpl; +import com.azure.resourcemanager.portalservicescopilot.implementation.OperationsImpl; +import com.azure.resourcemanager.portalservicescopilot.implementation.PortalServicesClientBuilder; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettings; +import com.azure.resourcemanager.portalservicescopilot.models.Operations; +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 PortalservicescopilotManager. + * Azure Portal Services API Reference. + */ +public final class PortalservicescopilotManager { + private Operations operations; + + private CopilotSettings copilotSettings; + + private final PortalServicesClient clientObject; + + private PortalservicescopilotManager(HttpPipeline httpPipeline, AzureProfile profile, + Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new PortalServicesClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of portalservicescopilot service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the portalservicescopilot service API instance. + */ + public static PortalservicescopilotManager 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 portalservicescopilot service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the portalservicescopilot service API instance. + */ + public static PortalservicescopilotManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new PortalservicescopilotManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create PortalservicescopilotManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new PortalservicescopilotManager.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-portalservicescopilot.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 portalservicescopilot service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the portalservicescopilot service API instance. + */ + public PortalservicescopilotManager 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.portalservicescopilot") + .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 PortalservicescopilotManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Operations. + * + * @return Resource collection API of Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * Gets the resource collection API of CopilotSettings. + * + * @return Resource collection API of CopilotSettings. + */ + public CopilotSettings copilotSettings() { + if (this.copilotSettings == null) { + this.copilotSettings = new CopilotSettingsImpl(clientObject.getCopilotSettings(), this); + } + return copilotSettings; + } + + /** + * Gets wrapped service client PortalServicesClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client PortalServicesClient. + */ + public PortalServicesClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/CopilotSettingsClient.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/CopilotSettingsClient.java new file mode 100644 index 000000000000..e994eed77668 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/CopilotSettingsClient.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.portalservicescopilot.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdate; + +/** + * An instance of this class provides access to all the operations defined in CopilotSettingsClient. + */ +public interface CopilotSettingsClient { + /** + * Get a CopilotSettingsResource. + * + * @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 CopilotSettingsResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(Context context); + + /** + * Get a CopilotSettingsResource. + * + * @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 CopilotSettingsResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CopilotSettingsResourceInner get(); + + /** + * Create a CopilotSettingsResource. + * + * @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 copilot settings tenant resource definition along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(CopilotSettingsResourceInner resource, + Context context); + + /** + * Create a CopilotSettingsResource. + * + * @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 copilot settings tenant resource definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CopilotSettingsResourceInner createOrUpdate(CopilotSettingsResourceInner resource); + + /** + * Update a CopilotSettingsResource. + * + * @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 the copilot settings tenant resource definition along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(CopilotSettingsResourceUpdate properties, + Context context); + + /** + * Update a CopilotSettingsResource. + * + * @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 the copilot settings tenant resource definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CopilotSettingsResourceInner update(CopilotSettingsResourceUpdate properties); + + /** + * Delete a CopilotSettingsResource. + * + * @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(Context context); + + /** + * Delete a CopilotSettingsResource. + * + * @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(); +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/OperationsClient.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/OperationsClient.java new file mode 100644 index 000000000000..802e3cce1722 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/OperationsClient.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.portalservicescopilot.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.OperationInner; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public interface OperationsClient { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/PortalServicesClient.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/PortalServicesClient.java new file mode 100644 index 000000000000..33429baf6d28 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/PortalServicesClient.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for PortalServicesClient class. + */ +public interface PortalServicesClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the CopilotSettingsClient object to access its operations. + * + * @return the CopilotSettingsClient object. + */ + CopilotSettingsClient getCopilotSettings(); +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/models/CopilotSettingsResourceInner.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/models/CopilotSettingsResourceInner.java new file mode 100644 index 000000000000..abb7245065f0 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/models/CopilotSettingsResourceInner.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.portalservicescopilot.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.portalservicescopilot.models.CopilotSettingsProperties; +import java.io.IOException; + +/** + * The copilot settings tenant resource definition. + */ +@Fluent +public final class CopilotSettingsResourceInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private CopilotSettingsProperties 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 CopilotSettingsResourceInner class. + */ + public CopilotSettingsResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public CopilotSettingsProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the CopilotSettingsResourceInner object itself. + */ + public CopilotSettingsResourceInner withProperties(CopilotSettingsProperties 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 CopilotSettingsResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CopilotSettingsResourceInner 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 CopilotSettingsResourceInner. + */ + public static CopilotSettingsResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CopilotSettingsResourceInner deserializedCopilotSettingsResourceInner = new CopilotSettingsResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedCopilotSettingsResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedCopilotSettingsResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedCopilotSettingsResourceInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedCopilotSettingsResourceInner.properties = CopilotSettingsProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedCopilotSettingsResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedCopilotSettingsResourceInner; + }); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/models/OperationInner.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/models/OperationInner.java new file mode 100644 index 000000000000..8890b60234cc --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/models/OperationInner.java @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.portalservicescopilot.models.ActionType; +import com.azure.resourcemanager.portalservicescopilot.models.OperationDisplay; +import com.azure.resourcemanager.portalservicescopilot.models.Origin; +import java.io.IOException; + +/** + * Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Immutable +public final class OperationInner implements JsonSerializable { + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + */ + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + * Resource Manager/control-plane operations. + */ + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + * value is "user,system" + */ + private Origin origin; + + /* + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + private ActionType actionType; + + /** + * Creates an instance of OperationInner class. + */ + private OperationInner() { + } + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("display", this.display); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationInner 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 OperationInner. + */ + public static OperationInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationInner deserializedOperationInner = new OperationInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOperationInner.name = reader.getString(); + } else if ("isDataAction".equals(fieldName)) { + deserializedOperationInner.isDataAction = reader.getNullable(JsonReader::getBoolean); + } else if ("display".equals(fieldName)) { + deserializedOperationInner.display = OperationDisplay.fromJson(reader); + } else if ("origin".equals(fieldName)) { + deserializedOperationInner.origin = Origin.fromString(reader.getString()); + } else if ("actionType".equals(fieldName)) { + deserializedOperationInner.actionType = ActionType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationInner; + }); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/models/package-info.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/models/package-info.java new file mode 100644 index 000000000000..345afec6a9de --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/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 Portalservicescopilot. + * Azure Portal Services API Reference. + */ +package com.azure.resourcemanager.portalservicescopilot.fluent.models; diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/package-info.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/fluent/package-info.java new file mode 100644 index 000000000000..5a379ad64ff8 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/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 Portalservicescopilot. + * Azure Portal Services API Reference. + */ +package com.azure.resourcemanager.portalservicescopilot.fluent; diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/CopilotSettingsClientImpl.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/CopilotSettingsClientImpl.java new file mode 100644 index 000000000000..b55bfbdec147 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/CopilotSettingsClientImpl.java @@ -0,0 +1,457 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.portalservicescopilot.fluent.CopilotSettingsClient; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdate; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in CopilotSettingsClient. + */ +public final class CopilotSettingsClientImpl implements CopilotSettingsClient { + /** + * The proxy service used to perform REST calls. + */ + private final CopilotSettingsService service; + + /** + * The service client containing this operation class. + */ + private final PortalServicesClientImpl client; + + /** + * Initializes an instance of CopilotSettingsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CopilotSettingsClientImpl(PortalServicesClientImpl client) { + this.service + = RestProxy.create(CopilotSettingsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for PortalServicesClientCopilotSettings to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PortalServicesClient") + public interface CopilotSettingsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.PortalServices/copilotSettings/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Put("/providers/Microsoft.PortalServices/copilotSettings/default") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") CopilotSettingsResourceInner resource, + Context context); + + @Patch("/providers/Microsoft.PortalServices/copilotSettings/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, + @BodyParam("application/json") CopilotSettingsResourceUpdate properties, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/providers/Microsoft.PortalServices/copilotSettings/default") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a CopilotSettingsResource. + * + * @throws 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 CopilotSettingsResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync() { + 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.get(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a CopilotSettingsResource. + * + * @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 CopilotSettingsResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), accept, context); + } + + /** + * Get a CopilotSettingsResource. + * + * @throws 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 CopilotSettingsResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync() { + return getWithResponseAsync().flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a CopilotSettingsResource. + * + * @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 CopilotSettingsResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(Context context) { + return getWithResponseAsync(context).block(); + } + + /** + * Get a CopilotSettingsResource. + * + * @throws 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 CopilotSettingsResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CopilotSettingsResourceInner get() { + return getWithResponse(Context.NONE).getValue(); + } + + /** + * Create a CopilotSettingsResource. + * + * @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 copilot settings tenant resource definition along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + createOrUpdateWithResponseAsync(CopilotSettingsResourceInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() 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(), + contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a CopilotSettingsResource. + * + * @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 copilot settings tenant resource definition along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + createOrUpdateWithResponseAsync(CopilotSettingsResourceInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() 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(), contentType, accept, + resource, context); + } + + /** + * Create a CopilotSettingsResource. + * + * @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 copilot settings tenant resource definition on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(CopilotSettingsResourceInner resource) { + return createOrUpdateWithResponseAsync(resource).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a CopilotSettingsResource. + * + * @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 copilot settings tenant resource definition along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(CopilotSettingsResourceInner resource, + Context context) { + return createOrUpdateWithResponseAsync(resource, context).block(); + } + + /** + * Create a CopilotSettingsResource. + * + * @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 copilot settings tenant resource definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CopilotSettingsResourceInner createOrUpdate(CopilotSettingsResourceInner resource) { + return createOrUpdateWithResponse(resource, Context.NONE).getValue(); + } + + /** + * Update a CopilotSettingsResource. + * + * @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 the copilot settings tenant resource definition along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + updateWithResponseAsync(CopilotSettingsResourceUpdate properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() 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(), contentType, + accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a CopilotSettingsResource. + * + * @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 the copilot settings tenant resource definition along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + updateWithResponseAsync(CopilotSettingsResourceUpdate properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() 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(), contentType, accept, properties, + context); + } + + /** + * Update a CopilotSettingsResource. + * + * @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 the copilot settings tenant resource definition on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(CopilotSettingsResourceUpdate properties) { + return updateWithResponseAsync(properties).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a CopilotSettingsResource. + * + * @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 the copilot settings tenant resource definition along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(CopilotSettingsResourceUpdate properties, + Context context) { + return updateWithResponseAsync(properties, context).block(); + } + + /** + * Update a CopilotSettingsResource. + * + * @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 the copilot settings tenant resource definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CopilotSettingsResourceInner update(CopilotSettingsResourceUpdate properties) { + return updateWithResponse(properties, Context.NONE).getValue(); + } + + /** + * Delete a CopilotSettingsResource. + * + * @throws 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() { + 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.delete(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a CopilotSettingsResource. + * + * @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(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), accept, context); + } + + /** + * Delete a CopilotSettingsResource. + * + * @throws 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() { + return deleteWithResponseAsync().flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a CopilotSettingsResource. + * + * @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(Context context) { + return deleteWithResponseAsync(context).block(); + } + + /** + * Delete a CopilotSettingsResource. + * + * @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() { + deleteWithResponse(Context.NONE); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/CopilotSettingsImpl.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/CopilotSettingsImpl.java new file mode 100644 index 000000000000..3b7bf054671c --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/CopilotSettingsImpl.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.implementation; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.portalservicescopilot.fluent.CopilotSettingsClient; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettings; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResource; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdate; + +public final class CopilotSettingsImpl implements CopilotSettings { + private static final ClientLogger LOGGER = new ClientLogger(CopilotSettingsImpl.class); + + private final CopilotSettingsClient innerClient; + + private final com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager serviceManager; + + public CopilotSettingsImpl(CopilotSettingsClient innerClient, + com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(Context context) { + Response inner = this.serviceClient().getWithResponse(context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new CopilotSettingsResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public CopilotSettingsResource get() { + CopilotSettingsResourceInner inner = this.serviceClient().get(); + if (inner != null) { + return new CopilotSettingsResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response createOrUpdateWithResponse(CopilotSettingsResourceInner resource, + Context context) { + Response inner + = this.serviceClient().createOrUpdateWithResponse(resource, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new CopilotSettingsResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public CopilotSettingsResource createOrUpdate(CopilotSettingsResourceInner resource) { + CopilotSettingsResourceInner inner = this.serviceClient().createOrUpdate(resource); + if (inner != null) { + return new CopilotSettingsResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response updateWithResponse(CopilotSettingsResourceUpdate properties, + Context context) { + Response inner = this.serviceClient().updateWithResponse(properties, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new CopilotSettingsResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public CopilotSettingsResource update(CopilotSettingsResourceUpdate properties) { + CopilotSettingsResourceInner inner = this.serviceClient().update(properties); + if (inner != null) { + return new CopilotSettingsResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(Context context) { + return this.serviceClient().deleteWithResponse(context); + } + + public void delete() { + this.serviceClient().delete(); + } + + private CopilotSettingsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/CopilotSettingsResourceImpl.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/CopilotSettingsResourceImpl.java new file mode 100644 index 000000000000..8a18effd10ac --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/CopilotSettingsResourceImpl.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.implementation; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsProperties; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResource; + +public final class CopilotSettingsResourceImpl implements CopilotSettingsResource { + private CopilotSettingsResourceInner innerObject; + + private final com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager serviceManager; + + CopilotSettingsResourceImpl(CopilotSettingsResourceInner innerObject, + com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public CopilotSettingsProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public CopilotSettingsResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/OperationImpl.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/OperationImpl.java new file mode 100644 index 000000000000..338144ced15c --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/OperationImpl.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.implementation; + +import com.azure.resourcemanager.portalservicescopilot.fluent.models.OperationInner; +import com.azure.resourcemanager.portalservicescopilot.models.ActionType; +import com.azure.resourcemanager.portalservicescopilot.models.Operation; +import com.azure.resourcemanager.portalservicescopilot.models.OperationDisplay; +import com.azure.resourcemanager.portalservicescopilot.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager serviceManager; + + OperationImpl(OperationInner innerObject, + com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/OperationsClientImpl.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..b2237f3885d0 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/OperationsClientImpl.java @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.portalservicescopilot.fluent.OperationsClient; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.OperationInner; +import com.azure.resourcemanager.portalservicescopilot.implementation.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public final class OperationsClientImpl implements OperationsClient { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final PortalServicesClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(PortalServicesClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for PortalServicesClientOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PortalServicesClient") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.PortalServices/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/OperationsImpl.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/OperationsImpl.java new file mode 100644 index 000000000000..5c049d632e03 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.portalservicescopilot.fluent.OperationsClient; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.OperationInner; +import com.azure.resourcemanager.portalservicescopilot.models.Operation; +import com.azure.resourcemanager.portalservicescopilot.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, + com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/PortalServicesClientBuilder.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/PortalServicesClientBuilder.java new file mode 100644 index 000000000000..a9a99ca85943 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/PortalServicesClientBuilder.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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 PortalServicesClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { PortalServicesClientImpl.class }) +public final class PortalServicesClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the PortalServicesClientBuilder. + */ + public PortalServicesClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the PortalServicesClientBuilder. + */ + public PortalServicesClientBuilder 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 PortalServicesClientBuilder. + */ + public PortalServicesClientBuilder 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 PortalServicesClientBuilder. + */ + public PortalServicesClientBuilder 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 PortalServicesClientBuilder. + */ + public PortalServicesClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of PortalServicesClientImpl with the provided parameters. + * + * @return an instance of PortalServicesClientImpl. + */ + public PortalServicesClientImpl 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(); + PortalServicesClientImpl client = new PortalServicesClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint); + return client; + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/PortalServicesClientImpl.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/PortalServicesClientImpl.java new file mode 100644 index 000000000000..3cf8a4a8aa3d --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/PortalServicesClientImpl.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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.portalservicescopilot.fluent.CopilotSettingsClient; +import com.azure.resourcemanager.portalservicescopilot.fluent.OperationsClient; +import com.azure.resourcemanager.portalservicescopilot.fluent.PortalServicesClient; +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 PortalServicesClientImpl type. + */ +@ServiceClient(builder = PortalServicesClientBuilder.class) +public final class PortalServicesClientImpl implements PortalServicesClient { + /** + * 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 HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The OperationsClient object to access its operations. + */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * The CopilotSettingsClient object to access its operations. + */ + private final CopilotSettingsClient copilotSettings; + + /** + * Gets the CopilotSettingsClient object to access its operations. + * + * @return the CopilotSettingsClient object. + */ + public CopilotSettingsClient getCopilotSettings() { + return this.copilotSettings; + } + + /** + * Initializes an instance of PortalServicesClient 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. + */ + PortalServicesClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.apiVersion = "2024-04-01-preview"; + this.operations = new OperationsClientImpl(this); + this.copilotSettings = new CopilotSettingsClientImpl(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(PortalServicesClientImpl.class); +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/ResourceManagerUtils.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000000..a3a76950be00 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/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.portalservicescopilot.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/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/models/OperationListResult.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/models/OperationListResult.java new file mode 100644 index 000000000000..ed5191c62f68 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/models/OperationListResult.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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.portalservicescopilot.fluent.models.OperationInner; +import java.io.IOException; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult implements JsonSerializable { + /* + * The Operation items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of OperationListResult class. + */ + private OperationListResult() { + } + + /** + * Get the value property: The Operation 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 OperationListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OperationListResult.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 OperationListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationListResult 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 OperationListResult. + */ + public static OperationListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationListResult deserializedOperationListResult = new OperationListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> OperationInner.fromJson(reader1)); + deserializedOperationListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedOperationListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationListResult; + }); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/package-info.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/implementation/package-info.java new file mode 100644 index 000000000000..6e62671c6229 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/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 Portalservicescopilot. + * Azure Portal Services API Reference. + */ +package com.azure.resourcemanager.portalservicescopilot.implementation; diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/ActionType.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/ActionType.java new file mode 100644 index 000000000000..6243ee5dd983 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/ActionType.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.portalservicescopilot.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ +public final class ActionType extends ExpandableStringEnum { + /** + * Actions are for internal-only APIs. + */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates a new instance of ActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActionType() { + } + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * Gets known ActionType values. + * + * @return known ActionType values. + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettings.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettings.java new file mode 100644 index 000000000000..c88529b51373 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettings.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; + +/** + * Resource collection API of CopilotSettings. + */ +public interface CopilotSettings { + /** + * Get a CopilotSettingsResource. + * + * @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 CopilotSettingsResource along with {@link Response}. + */ + Response getWithResponse(Context context); + + /** + * Get a CopilotSettingsResource. + * + * @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 CopilotSettingsResource. + */ + CopilotSettingsResource get(); + + /** + * Create a CopilotSettingsResource. + * + * @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 copilot settings tenant resource definition along with {@link Response}. + */ + Response createOrUpdateWithResponse(CopilotSettingsResourceInner resource, + Context context); + + /** + * Create a CopilotSettingsResource. + * + * @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 copilot settings tenant resource definition. + */ + CopilotSettingsResource createOrUpdate(CopilotSettingsResourceInner resource); + + /** + * Update a CopilotSettingsResource. + * + * @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 the copilot settings tenant resource definition along with {@link Response}. + */ + Response updateWithResponse(CopilotSettingsResourceUpdate properties, Context context); + + /** + * Update a CopilotSettingsResource. + * + * @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 the copilot settings tenant resource definition. + */ + CopilotSettingsResource update(CopilotSettingsResourceUpdate properties); + + /** + * Delete a CopilotSettingsResource. + * + * @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(Context context); + + /** + * Delete a CopilotSettingsResource. + * + * @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(); +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsProperties.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsProperties.java new file mode 100644 index 000000000000..cedb4ea4015a --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsProperties.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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 Copilot Settings properties. + */ +@Fluent +public final class CopilotSettingsProperties implements JsonSerializable { + /* + * Boolean indicating if role-based access control is enabled for copilot in this tenant. + */ + private boolean accessControlEnabled; + + /* + * The status of the last provisioning operation performed on the resource. + */ + private ResourceProvisioningState provisioningState; + + /** + * Creates an instance of CopilotSettingsProperties class. + */ + public CopilotSettingsProperties() { + } + + /** + * Get the accessControlEnabled property: Boolean indicating if role-based access control is enabled for copilot in + * this tenant. + * + * @return the accessControlEnabled value. + */ + public boolean accessControlEnabled() { + return this.accessControlEnabled; + } + + /** + * Set the accessControlEnabled property: Boolean indicating if role-based access control is enabled for copilot in + * this tenant. + * + * @param accessControlEnabled the accessControlEnabled value to set. + * @return the CopilotSettingsProperties object itself. + */ + public CopilotSettingsProperties withAccessControlEnabled(boolean accessControlEnabled) { + this.accessControlEnabled = accessControlEnabled; + return this; + } + + /** + * Get the provisioningState property: The status of the last provisioning operation performed on the resource. + * + * @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.writeBooleanField("accessControlEnabled", this.accessControlEnabled); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CopilotSettingsProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CopilotSettingsProperties 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 CopilotSettingsProperties. + */ + public static CopilotSettingsProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CopilotSettingsProperties deserializedCopilotSettingsProperties = new CopilotSettingsProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("accessControlEnabled".equals(fieldName)) { + deserializedCopilotSettingsProperties.accessControlEnabled = reader.getBoolean(); + } else if ("provisioningState".equals(fieldName)) { + deserializedCopilotSettingsProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCopilotSettingsProperties; + }); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsResource.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsResource.java new file mode 100644 index 000000000000..660c9e20306e --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsResource.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.models; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; + +/** + * An immutable client-side representation of CopilotSettingsResource. + */ +public interface CopilotSettingsResource { + /** + * 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. + */ + CopilotSettingsProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the inner com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner object. + * + * @return the inner object. + */ + CopilotSettingsResourceInner innerModel(); +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsResourceUpdate.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsResourceUpdate.java new file mode 100644 index 000000000000..9cc60a809c92 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsResourceUpdate.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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 CopilotSettingsResource. + */ +@Fluent +public final class CopilotSettingsResourceUpdate implements JsonSerializable { + /* + * The resource-specific properties for this resource. + */ + private CopilotSettingsResourceUpdateProperties properties; + + /** + * Creates an instance of CopilotSettingsResourceUpdate class. + */ + public CopilotSettingsResourceUpdate() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public CopilotSettingsResourceUpdateProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the CopilotSettingsResourceUpdate object itself. + */ + public CopilotSettingsResourceUpdate withProperties(CopilotSettingsResourceUpdateProperties 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 CopilotSettingsResourceUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CopilotSettingsResourceUpdate 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 CopilotSettingsResourceUpdate. + */ + public static CopilotSettingsResourceUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CopilotSettingsResourceUpdate deserializedCopilotSettingsResourceUpdate + = new CopilotSettingsResourceUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("properties".equals(fieldName)) { + deserializedCopilotSettingsResourceUpdate.properties + = CopilotSettingsResourceUpdateProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedCopilotSettingsResourceUpdate; + }); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsResourceUpdateProperties.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsResourceUpdateProperties.java new file mode 100644 index 000000000000..f2016155330d --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/CopilotSettingsResourceUpdateProperties.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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 CopilotSettingsResource. + */ +@Fluent +public final class CopilotSettingsResourceUpdateProperties + implements JsonSerializable { + /* + * Boolean indicating if role-based access control is enabled for copilot in this tenant. + */ + private Boolean accessControlEnabled; + + /** + * Creates an instance of CopilotSettingsResourceUpdateProperties class. + */ + public CopilotSettingsResourceUpdateProperties() { + } + + /** + * Get the accessControlEnabled property: Boolean indicating if role-based access control is enabled for copilot in + * this tenant. + * + * @return the accessControlEnabled value. + */ + public Boolean accessControlEnabled() { + return this.accessControlEnabled; + } + + /** + * Set the accessControlEnabled property: Boolean indicating if role-based access control is enabled for copilot in + * this tenant. + * + * @param accessControlEnabled the accessControlEnabled value to set. + * @return the CopilotSettingsResourceUpdateProperties object itself. + */ + public CopilotSettingsResourceUpdateProperties withAccessControlEnabled(Boolean accessControlEnabled) { + this.accessControlEnabled = accessControlEnabled; + 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.writeBooleanField("accessControlEnabled", this.accessControlEnabled); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CopilotSettingsResourceUpdateProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CopilotSettingsResourceUpdateProperties 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 CopilotSettingsResourceUpdateProperties. + */ + public static CopilotSettingsResourceUpdateProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CopilotSettingsResourceUpdateProperties deserializedCopilotSettingsResourceUpdateProperties + = new CopilotSettingsResourceUpdateProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("accessControlEnabled".equals(fieldName)) { + deserializedCopilotSettingsResourceUpdateProperties.accessControlEnabled + = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedCopilotSettingsResourceUpdateProperties; + }); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/Operation.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/Operation.java new file mode 100644 index 000000000000..02f3cb01b0d8 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/Operation.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.models; + +import com.azure.resourcemanager.portalservicescopilot.fluent.models.OperationInner; + +/** + * An immutable client-side representation of Operation. + */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.azure.resourcemanager.portalservicescopilot.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/OperationDisplay.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/OperationDisplay.java new file mode 100644 index 000000000000..efa2fd3e6907 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/OperationDisplay.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.portalservicescopilot.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Localized display information for and operation. + */ +@Immutable +public final class OperationDisplay implements JsonSerializable { + /* + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or + * "Microsoft Compute". + */ + private String provider; + + /* + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or + * "Job Schedule Collections". + */ + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + */ + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + */ + private String description; + + /** + * Creates an instance of OperationDisplay class. + */ + private OperationDisplay() { + } + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationDisplay from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDisplay 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 OperationDisplay. + */ + public static OperationDisplay fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationDisplay deserializedOperationDisplay = new OperationDisplay(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provider".equals(fieldName)) { + deserializedOperationDisplay.provider = reader.getString(); + } else if ("resource".equals(fieldName)) { + deserializedOperationDisplay.resource = reader.getString(); + } else if ("operation".equals(fieldName)) { + deserializedOperationDisplay.operation = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedOperationDisplay.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationDisplay; + }); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/Operations.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/Operations.java new file mode 100644 index 000000000000..be568d5c30a9 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/Operations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** + * Resource collection API of Operations. + */ +public interface Operations { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/Origin.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/Origin.java new file mode 100644 index 000000000000..8354a51c898e --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/Origin.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value + * is "user,system". + */ +public final class Origin extends ExpandableStringEnum { + /** + * Indicates the operation is initiated by a user. + */ + public static final Origin USER = fromString("user"); + + /** + * Indicates the operation is initiated by a system. + */ + public static final Origin SYSTEM = fromString("system"); + + /** + * Indicates the operation is initiated by a user or system. + */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates a new instance of Origin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Origin() { + } + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** + * Gets known Origin values. + * + * @return known Origin values. + */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/ResourceProvisioningState.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/ResourceProvisioningState.java new file mode 100644 index 000000000000..bf7440281991 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/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.portalservicescopilot.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/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/package-info.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/models/package-info.java new file mode 100644 index 000000000000..ee4eb6928829 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/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 Portalservicescopilot. + * Azure Portal Services API Reference. + */ +package com.azure.resourcemanager.portalservicescopilot.models; diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/package-info.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/package-info.java new file mode 100644 index 000000000000..a3cd070603d8 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/com/azure/resourcemanager/portalservicescopilot/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 Portalservicescopilot. + * Azure Portal Services API Reference. + */ +package com.azure.resourcemanager.portalservicescopilot; diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/module-info.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/java/module-info.java new file mode 100644 index 000000000000..b5773371b20d --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/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.portalservicescopilot { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.portalservicescopilot; + exports com.azure.resourcemanager.portalservicescopilot.fluent; + exports com.azure.resourcemanager.portalservicescopilot.fluent.models; + exports com.azure.resourcemanager.portalservicescopilot.models; + + opens com.azure.resourcemanager.portalservicescopilot.fluent.models to com.azure.core; + opens com.azure.resourcemanager.portalservicescopilot.models to com.azure.core; + opens com.azure.resourcemanager.portalservicescopilot.implementation.models to com.azure.core; +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-portalservicescopilot/proxy-config.json b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-portalservicescopilot/proxy-config.json new file mode 100644 index 000000000000..49e81dd0fcc1 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-portalservicescopilot/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.portalservicescopilot.implementation.CopilotSettingsClientImpl$CopilotSettingsService"],["com.azure.resourcemanager.portalservicescopilot.implementation.OperationsClientImpl$OperationsService"]] \ No newline at end of file diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-portalservicescopilot/reflect-config.json b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-portalservicescopilot/reflect-config.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-portalservicescopilot/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/resources/azure-resourcemanager-portalservicescopilot.properties b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/resources/azure-resourcemanager-portalservicescopilot.properties new file mode 100644 index 000000000000..defbd48204e4 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/main/resources/azure-resourcemanager-portalservicescopilot.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsCreateOrUpdateSamples.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..e1e39041e3d2 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsCreateOrUpdateSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsProperties; + +/** + * Samples for CopilotSettings CreateOrUpdate. + */ +public final class CopilotSettingsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-04-01-preview/CopilotSettings_CreateOrUpdate.json + */ + /** + * Sample code: Create a new Copilot settings or update an existing one. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void createANewCopilotSettingsOrUpdateAnExistingOne( + com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.copilotSettings() + .createOrUpdateWithResponse(new CopilotSettingsResourceInner().withProperties( + new CopilotSettingsProperties().withAccessControlEnabled(true)), com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsDeleteSamples.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsDeleteSamples.java new file mode 100644 index 000000000000..4c34fab0824d --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsDeleteSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +/** + * Samples for CopilotSettings Delete. + */ +public final class CopilotSettingsDeleteSamples { + /* + * x-ms-original-file: 2024-04-01-preview/CopilotSettings_Delete.json + */ + /** + * Sample code: Delete Copilot Settings. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void + deleteCopilotSettings(com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.copilotSettings().deleteWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsGetSamples.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsGetSamples.java new file mode 100644 index 000000000000..9251d0f31ccf --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsGetSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +/** + * Samples for CopilotSettings Get. + */ +public final class CopilotSettingsGetSamples { + /* + * x-ms-original-file: 2024-04-01-preview/CopilotSettings_Get.json + */ + /** + * Sample code: Get Copilot Settings. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void + getCopilotSettings(com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.copilotSettings().getWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsUpdateSamples.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsUpdateSamples.java new file mode 100644 index 000000000000..241713bd7626 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsUpdateSamples.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.portalservicescopilot.generated; + +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdate; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdateProperties; + +/** + * Samples for CopilotSettings Update. + */ +public final class CopilotSettingsUpdateSamples { + /* + * x-ms-original-file: 2024-04-01-preview/CopilotSettings_Update.json + */ + /** + * Sample code: Update Copilot Settings. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void + updateCopilotSettings(com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.copilotSettings() + .updateWithResponse( + new CopilotSettingsResourceUpdate() + .withProperties(new CopilotSettingsResourceUpdateProperties().withAccessControlEnabled(true)), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationsListSamples.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationsListSamples.java new file mode 100644 index 000000000000..3c84766930ba --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/samples/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationsListSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2024-04-01-preview/Operations_List.json + */ + /** + * Sample code: List the operations for the Microsoft.PortalServices provider. + * + * @param manager Entry point to PortalservicescopilotManager. + */ + public static void listTheOperationsForTheMicrosoftPortalServicesProvider( + com.azure.resourcemanager.portalservicescopilot.PortalservicescopilotManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsCreateOrUpdateWithResponseMockTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsCreateOrUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..cca4de0a6da2 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsCreateOrUpdateWithResponseMockTests.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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.portalservicescopilot.PortalservicescopilotManager; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsProperties; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResource; +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 CopilotSettingsCreateOrUpdateWithResponseMockTests { + @Test + public void testCreateOrUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"accessControlEnabled\":true,\"provisioningState\":\"Canceled\"},\"id\":\"uxinpmqnjaq\",\"name\":\"ixjsprozvcputeg\",\"type\":\"vwmf\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + PortalservicescopilotManager manager = PortalservicescopilotManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + CopilotSettingsResource response = manager.copilotSettings() + .createOrUpdateWithResponse(new CopilotSettingsResourceInner().withProperties( + new CopilotSettingsProperties().withAccessControlEnabled(true)), com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals(true, response.properties().accessControlEnabled()); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsDeleteWithResponseMockTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsDeleteWithResponseMockTests.java new file mode 100644 index 000000000000..bb745cc91d38 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsDeleteWithResponseMockTests.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.portalservicescopilot.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.portalservicescopilot.PortalservicescopilotManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class CopilotSettingsDeleteWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + PortalservicescopilotManager manager = PortalservicescopilotManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.copilotSettings().deleteWithResponse(com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsGetWithResponseMockTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsGetWithResponseMockTests.java new file mode 100644 index 000000000000..3ea3b99fcae4 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsGetWithResponseMockTests.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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.portalservicescopilot.PortalservicescopilotManager; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResource; +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 CopilotSettingsGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"accessControlEnabled\":false,\"provisioningState\":\"Succeeded\"},\"id\":\"s\",\"name\":\"cnyejhkryhtnapcz\",\"type\":\"lokjyemkk\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + PortalservicescopilotManager manager = PortalservicescopilotManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + CopilotSettingsResource response + = manager.copilotSettings().getWithResponse(com.azure.core.util.Context.NONE).getValue(); + + Assertions.assertEquals(false, response.properties().accessControlEnabled()); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsPropertiesTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsPropertiesTests.java new file mode 100644 index 000000000000..4d428607755b --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsPropertiesTests.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsProperties; +import org.junit.jupiter.api.Assertions; + +public final class CopilotSettingsPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CopilotSettingsProperties model + = BinaryData.fromString("{\"accessControlEnabled\":true,\"provisioningState\":\"Failed\"}") + .toObject(CopilotSettingsProperties.class); + Assertions.assertEquals(true, model.accessControlEnabled()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + CopilotSettingsProperties model = new CopilotSettingsProperties().withAccessControlEnabled(true); + model = BinaryData.fromObject(model).toObject(CopilotSettingsProperties.class); + Assertions.assertEquals(true, model.accessControlEnabled()); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsResourceInnerTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsResourceInnerTests.java new file mode 100644 index 000000000000..f9b7ec92a7c9 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsResourceInnerTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.CopilotSettingsResourceInner; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsProperties; +import org.junit.jupiter.api.Assertions; + +public final class CopilotSettingsResourceInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CopilotSettingsResourceInner model = BinaryData.fromString( + "{\"properties\":{\"accessControlEnabled\":true,\"provisioningState\":\"Failed\"},\"id\":\"zvgnwzs\",\"name\":\"mglzufcy\",\"type\":\"kohdbiha\"}") + .toObject(CopilotSettingsResourceInner.class); + Assertions.assertEquals(true, model.properties().accessControlEnabled()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + CopilotSettingsResourceInner model = new CopilotSettingsResourceInner() + .withProperties(new CopilotSettingsProperties().withAccessControlEnabled(true)); + model = BinaryData.fromObject(model).toObject(CopilotSettingsResourceInner.class); + Assertions.assertEquals(true, model.properties().accessControlEnabled()); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsResourceUpdatePropertiesTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsResourceUpdatePropertiesTests.java new file mode 100644 index 000000000000..5d8627a12139 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsResourceUpdatePropertiesTests.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdateProperties; +import org.junit.jupiter.api.Assertions; + +public final class CopilotSettingsResourceUpdatePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CopilotSettingsResourceUpdateProperties model = BinaryData.fromString("{\"accessControlEnabled\":false}") + .toObject(CopilotSettingsResourceUpdateProperties.class); + Assertions.assertEquals(false, model.accessControlEnabled()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + CopilotSettingsResourceUpdateProperties model + = new CopilotSettingsResourceUpdateProperties().withAccessControlEnabled(false); + model = BinaryData.fromObject(model).toObject(CopilotSettingsResourceUpdateProperties.class); + Assertions.assertEquals(false, model.accessControlEnabled()); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsResourceUpdateTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsResourceUpdateTests.java new file mode 100644 index 000000000000..1969cffc02bd --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsResourceUpdateTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdate; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdateProperties; +import org.junit.jupiter.api.Assertions; + +public final class CopilotSettingsResourceUpdateTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + CopilotSettingsResourceUpdate model = BinaryData.fromString("{\"properties\":{\"accessControlEnabled\":false}}") + .toObject(CopilotSettingsResourceUpdate.class); + Assertions.assertEquals(false, model.properties().accessControlEnabled()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + CopilotSettingsResourceUpdate model = new CopilotSettingsResourceUpdate() + .withProperties(new CopilotSettingsResourceUpdateProperties().withAccessControlEnabled(false)); + model = BinaryData.fromObject(model).toObject(CopilotSettingsResourceUpdate.class); + Assertions.assertEquals(false, model.properties().accessControlEnabled()); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsUpdateWithResponseMockTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..46b00ffbd8c3 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/CopilotSettingsUpdateWithResponseMockTests.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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.portalservicescopilot.PortalservicescopilotManager; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResource; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdate; +import com.azure.resourcemanager.portalservicescopilot.models.CopilotSettingsResourceUpdateProperties; +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 CopilotSettingsUpdateWithResponseMockTests { + @Test + public void testUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"accessControlEnabled\":true,\"provisioningState\":\"Failed\"},\"id\":\"jhulsuuvmkjo\",\"name\":\"k\",\"type\":\"wfndiodjpsl\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + PortalservicescopilotManager manager = PortalservicescopilotManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + CopilotSettingsResource response = manager.copilotSettings() + .updateWithResponse( + new CopilotSettingsResourceUpdate() + .withProperties(new CopilotSettingsResourceUpdateProperties().withAccessControlEnabled(true)), + com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals(true, response.properties().accessControlEnabled()); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationDisplayTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationDisplayTests.java new file mode 100644 index 000000000000..eef068f7788e --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationDisplayTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.portalservicescopilot.models.OperationDisplay; + +public final class OperationDisplayTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationDisplay model = BinaryData.fromString( + "{\"provider\":\"cdm\",\"resource\":\"rcryuanzwuxzdxta\",\"operation\":\"lhmwhfpmrqobm\",\"description\":\"kknryrtihf\"}") + .toObject(OperationDisplay.class); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationInnerTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationInnerTests.java new file mode 100644 index 000000000000..1e03f050945d --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationInnerTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.portalservicescopilot.fluent.models.OperationInner; + +public final class OperationInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationInner model = BinaryData.fromString( + "{\"name\":\"nygj\",\"isDataAction\":true,\"display\":{\"provider\":\"eqsrdeupewnwreit\",\"resource\":\"yflusarhmofc\",\"operation\":\"smy\",\"description\":\"kdtmlxhekuk\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}") + .toObject(OperationInner.class); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationListResultTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationListResultTests.java new file mode 100644 index 000000000000..ed0982644c5a --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationListResultTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.portalservicescopilot.implementation.models.OperationListResult; +import org.junit.jupiter.api.Assertions; + +public final class OperationListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationListResult model = BinaryData.fromString( + "{\"value\":[{\"name\":\"hq\",\"isDataAction\":true,\"display\":{\"provider\":\"pybczmehmtzopb\",\"resource\":\"h\",\"operation\":\"pidgsybbejhphoyc\",\"description\":\"xaobhdxbmtqioqjz\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"fpownoizhwlr\",\"isDataAction\":false,\"display\":{\"provider\":\"oqijgkdmbpaz\",\"resource\":\"bc\",\"operation\":\"pdznrbtcqqjnqgl\",\"description\":\"gnufoooj\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"esaagdfm\",\"isDataAction\":true,\"display\":{\"provider\":\"j\",\"resource\":\"ifkwmrvktsizntoc\",\"operation\":\"a\",\"description\":\"ajpsquc\"},\"origin\":\"system\",\"actionType\":\"Internal\"}],\"nextLink\":\"kfo\"}") + .toObject(OperationListResult.class); + Assertions.assertEquals("kfo", model.nextLink()); + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationsListMockTests.java b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationsListMockTests.java new file mode 100644 index 000000000000..2d7d7c9918c1 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/src/test/java/com/azure/resourcemanager/portalservicescopilot/generated/OperationsListMockTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.portalservicescopilot.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.portalservicescopilot.PortalservicescopilotManager; +import com.azure.resourcemanager.portalservicescopilot.models.Operation; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class OperationsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"name\":\"a\",\"isDataAction\":false,\"display\":{\"provider\":\"qhabifpikxwcz\",\"resource\":\"scnpqxuhivy\",\"operation\":\"iwbybrkxvdumjg\",\"description\":\"fwvuk\"},\"origin\":\"user\",\"actionType\":\"Internal\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + PortalservicescopilotManager manager = PortalservicescopilotManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.operations().list(com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/portalservices/azure-resourcemanager-portalservicescopilot/tsp-location.yaml b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/tsp-location.yaml new file mode 100644 index 000000000000..0f2dfa7f44f5 --- /dev/null +++ b/sdk/portalservices/azure-resourcemanager-portalservicescopilot/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/portalservices/CopilotSettings.Management +commit: fb3121d71772eeefc59f86d5ec6addb46e1b752c +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/portalservices/ci.yml b/sdk/portalservices/ci.yml new file mode 100644 index 000000000000..251b1d6cfe4b --- /dev/null +++ b/sdk/portalservices/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/portalservices/ci.yml + - sdk/portalservices/azure-resourcemanager-portalservicescopilot/ + exclude: + - sdk/portalservices/pom.xml + - sdk/portalservices/azure-resourcemanager-portalservicescopilot/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/portalservices/ci.yml + - sdk/portalservices/azure-resourcemanager-portalservicescopilot/ + exclude: + - sdk/portalservices/pom.xml + - sdk/portalservices/azure-resourcemanager-portalservicescopilot/pom.xml + +parameters: + - name: release_azureresourcemanagerportalservicescopilot + displayName: azure-resourcemanager-portalservicescopilot + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: portalservices + Artifacts: + - name: azure-resourcemanager-portalservicescopilot + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerportalservicescopilot + releaseInBatch: ${{ parameters.release_azureresourcemanagerportalservicescopilot }} diff --git a/sdk/portalservices/pom.xml b/sdk/portalservices/pom.xml new file mode 100644 index 000000000000..3b02ece1ddf3 --- /dev/null +++ b/sdk/portalservices/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-portalservices-service + pom + 1.0.0 + + + azure-resourcemanager-portalservicescopilot + +