diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index ca02b042c717..8f83f65c6e06 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -505,6 +505,7 @@ com.azure.resourcemanager:azure-resourcemanager-kubernetesconfiguration-privatel com.azure.resourcemanager:azure-resourcemanager-resources-bicep;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-playwright;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-storagediscovery;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-containerservicesafeguards;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 dfda8d5790a2..8c0fd9ddd819 100644 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,7 @@ sdk/containerorchestratorruntime sdk/containerregistry sdk/containerservicefleet + sdk/containerservicesafeguards sdk/contentsafety sdk/core sdk/core-v2 diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/CHANGELOG.md b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/CHANGELOG.md new file mode 100644 index 000000000000..24462a689f90 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2025-07-31) + +- Azure Resource Manager Container Service Safeguards client library for Java. This package contains Microsoft Azure SDK for Container Service Safeguards Management SDK. Azure Kubernetes Service Deployment Safeguards API Client. Package api-version 2025-05-02-preview. 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-containerservicesafeguards Java SDK. diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/README.md b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/README.md new file mode 100644 index 000000000000..b2805252403a --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager Container Service Safeguards client library for Java + +Azure Resource Manager Container Service Safeguards client library for Java. + +This package contains Microsoft Azure SDK for Container Service Safeguards Management SDK. Azure Kubernetes Service Deployment Safeguards API Client. Package api-version 2025-05-02-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-containerservicesafeguards;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-containerservicesafeguards + 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(); +ContainerServiceSafeguardsManager manager = ContainerServiceSafeguardsManager + .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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/SAMPLE.md b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/SAMPLE.md new file mode 100644 index 000000000000..e9a2506ebe7a --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/SAMPLE.md @@ -0,0 +1,143 @@ +# Code snippets and samples + + +## DeploymentSafeguards + +- [Create](#deploymentsafeguards_create) +- [Delete](#deploymentsafeguards_delete) +- [Get](#deploymentsafeguards_get) +- [List](#deploymentsafeguards_list) + +## Operations + +- [List](#operations_list) +### DeploymentSafeguards_Create + +```java +/** + * Samples for DeploymentSafeguards Get. + */ +public final class DeploymentSafeguardsGetSamples { + /* + * x-ms-original-file: 2025-05-02-preview/DeploymentSafeguards_Get.json + */ + /** + * Sample code: Gets a DeploymentSafeguard resource. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void getsADeploymentSafeguardResource( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.deploymentSafeguards() + .getWithResponse( + "subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1", + com.azure.core.util.Context.NONE); + } +} +``` + +### DeploymentSafeguards_Delete + +```java +/** + * Samples for DeploymentSafeguards List. + */ +public final class DeploymentSafeguardsListSamples { + /* + * x-ms-original-file: 2025-05-02-preview/DeploymentSafeguards_List.json + */ + /** + * Sample code: Lists DeploymentSafeguards by parent resource. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void listsDeploymentSafeguardsByParentResource( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.deploymentSafeguards() + .list( + "subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1", + com.azure.core.util.Context.NONE); + } +} +``` + +### DeploymentSafeguards_Get + +```java +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2025-05-02-preview/Operations_List.json + */ + /** + * Sample code: List the operations for the provider. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void listTheOperationsForTheProvider( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + +### DeploymentSafeguards_List + +```java +/** + * Samples for DeploymentSafeguards Delete. + */ +public final class DeploymentSafeguardsDeleteSamples { + /* + * x-ms-original-file: 2025-05-02-preview/DeploymentSafeguards_Delete.json + */ + /** + * Sample code: Deletes a DeploymentSafeguard resource asynchronously with a long running operation. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void deletesADeploymentSafeguardResourceAsynchronouslyWithALongRunningOperation( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.deploymentSafeguards() + .delete( + "subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1", + com.azure.core.util.Context.NONE); + } +} +``` + +### Operations_List + +```java +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsLevel; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsProperties; +import com.azure.resourcemanager.containerservicesafeguards.models.PodSecurityStandardsLevel; + +/** + * Samples for DeploymentSafeguards Create. + */ +public final class DeploymentSafeguardsCreateSamples { + /* + * x-ms-original-file: 2025-05-02-preview/DeploymentSafeguards_Create.json + */ + /** + * Sample code: Creates a DeploymentSafeguards resource with a long running operation. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void createsADeploymentSafeguardsResourceWithALongRunningOperation( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.deploymentSafeguards() + .create( + "subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1", + new DeploymentSafeguardInner() + .withProperties(new DeploymentSafeguardsProperties().withLevel(DeploymentSafeguardsLevel.WARN) + .withPodSecurityStandardsLevel(PodSecurityStandardsLevel.POD_SECURITY_STANDARDS_BASELINE)), + com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/pom.xml b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/pom.xml new file mode 100644 index 000000000000..f4c32e4f8d72 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/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-containerservicesafeguards + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Container Service Safeguards Management + This package contains Microsoft Azure SDK for Container Service Safeguards Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Kubernetes Service Deployment Safeguards API Client. Package api-version 2025-05-02-preview. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0 + 0 + true + + + + com.azure + azure-core + 1.55.5 + + + com.azure + azure-core-management + 1.18.1 + + + com.azure + azure-core-test + 1.27.0-beta.10 + test + + + com.azure + azure-identity + 1.16.3 + test + + + diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/ContainerServiceSafeguardsManager.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/ContainerServiceSafeguardsManager.java new file mode 100644 index 000000000000..e2cdf847c4c1 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/ContainerServiceSafeguardsManager.java @@ -0,0 +1,299 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards; + +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.containerservicesafeguards.fluent.ContainerServiceSafeguardsManagementClient; +import com.azure.resourcemanager.containerservicesafeguards.implementation.ContainerServiceSafeguardsManagementClientBuilder; +import com.azure.resourcemanager.containerservicesafeguards.implementation.DeploymentSafeguardsImpl; +import com.azure.resourcemanager.containerservicesafeguards.implementation.OperationsImpl; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguards; +import com.azure.resourcemanager.containerservicesafeguards.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 ContainerServiceSafeguardsManager. + * Azure Kubernetes Service Deployment Safeguards API Client. + */ +public final class ContainerServiceSafeguardsManager { + private Operations operations; + + private DeploymentSafeguards deploymentSafeguards; + + private final ContainerServiceSafeguardsManagementClient clientObject; + + private ContainerServiceSafeguardsManager(HttpPipeline httpPipeline, AzureProfile profile, + Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new ContainerServiceSafeguardsManagementClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Container Service Safeguards service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Container Service Safeguards service API instance. + */ + public static ContainerServiceSafeguardsManager 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 Container Service Safeguards service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Container Service Safeguards service API instance. + */ + public static ContainerServiceSafeguardsManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ContainerServiceSafeguardsManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ContainerServiceSafeguardsManager with optional + * configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ContainerServiceSafeguardsManager.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-containerservicesafeguards.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 Container Service Safeguards service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Container Service Safeguards service API instance. + */ + public ContainerServiceSafeguardsManager 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.containerservicesafeguards") + .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 ContainerServiceSafeguardsManager(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 DeploymentSafeguards. + * + * @return Resource collection API of DeploymentSafeguards. + */ + public DeploymentSafeguards deploymentSafeguards() { + if (this.deploymentSafeguards == null) { + this.deploymentSafeguards = new DeploymentSafeguardsImpl(clientObject.getDeploymentSafeguards(), this); + } + return deploymentSafeguards; + } + + /** + * Gets wrapped service client ContainerServiceSafeguardsManagementClient providing direct access to the underlying + * auto-generated API implementation, based on Azure REST API. + * + * @return Wrapped service client ContainerServiceSafeguardsManagementClient. + */ + public ContainerServiceSafeguardsManagementClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/ContainerServiceSafeguardsManagementClient.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/ContainerServiceSafeguardsManagementClient.java new file mode 100644 index 000000000000..284029a1a389 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/ContainerServiceSafeguardsManagementClient.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.containerservicesafeguards.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for ContainerServiceSafeguardsManagementClient class. + */ +public interface ContainerServiceSafeguardsManagementClient { + /** + * 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 DeploymentSafeguardsClient object to access its operations. + * + * @return the DeploymentSafeguardsClient object. + */ + DeploymentSafeguardsClient getDeploymentSafeguards(); +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/DeploymentSafeguardsClient.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/DeploymentSafeguardsClient.java new file mode 100644 index 000000000000..a6def245c363 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/DeploymentSafeguardsClient.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; + +/** + * An instance of this class provides access to all the operations defined in DeploymentSafeguardsClient. + */ +public interface DeploymentSafeguardsClient { + /** + * Fetch a deployment safeguard by name. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceUri, Context context); + + /** + * Fetch a deployment safeguard by name. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DeploymentSafeguardInner get(String resourceUri); + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, DeploymentSafeguardInner> beginCreate(String resourceUri, + DeploymentSafeguardInner resource); + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, DeploymentSafeguardInner> beginCreate(String resourceUri, + DeploymentSafeguardInner resource, Context context); + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DeploymentSafeguardInner create(String resourceUri, DeploymentSafeguardInner resource); + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DeploymentSafeguardInner create(String resourceUri, DeploymentSafeguardInner resource, Context context); + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceUri); + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceUri, Context context); + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceUri); + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceUri, Context context); + + /** + * List DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String resourceUri); + + /** + * List DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String resourceUri, Context context); +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/OperationsClient.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/OperationsClient.java new file mode 100644 index 000000000000..2ddbdd004eb2 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.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.containerservicesafeguards.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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/models/DeploymentSafeguardInner.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/models/DeploymentSafeguardInner.java new file mode 100644 index 000000000000..cc7fb3857c11 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/models/DeploymentSafeguardInner.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.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.containerservicesafeguards.models.DeploymentSafeguardsProperties; +import java.io.IOException; + +/** + * Deployment Safeguards. + */ +@Fluent +public final class DeploymentSafeguardInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private DeploymentSafeguardsProperties properties; + + /* + * If eTag is provided in the response body, it may also be provided as a header per the normal etag convention. + * Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity + * tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section + * 14.27) header fields. + */ + private String eTag; + + /* + * 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 DeploymentSafeguardInner class. + */ + public DeploymentSafeguardInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public DeploymentSafeguardsProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the DeploymentSafeguardInner object itself. + */ + public DeploymentSafeguardInner withProperties(DeploymentSafeguardsProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the eTag property: If eTag is provided in the response body, it may also be provided as a header per the + * normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. + * HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), + * and If-Range (section 14.27) header fields. + * + * @return the eTag value. + */ + public String eTag() { + return this.eTag; + } + + /** + * 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 DeploymentSafeguardInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DeploymentSafeguardInner 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 DeploymentSafeguardInner. + */ + public static DeploymentSafeguardInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DeploymentSafeguardInner deserializedDeploymentSafeguardInner = new DeploymentSafeguardInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedDeploymentSafeguardInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedDeploymentSafeguardInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedDeploymentSafeguardInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedDeploymentSafeguardInner.properties = DeploymentSafeguardsProperties.fromJson(reader); + } else if ("eTag".equals(fieldName)) { + deserializedDeploymentSafeguardInner.eTag = reader.getString(); + } else if ("systemData".equals(fieldName)) { + deserializedDeploymentSafeguardInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedDeploymentSafeguardInner; + }); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/models/OperationInner.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/models/OperationInner.java new file mode 100644 index 000000000000..4c36f25d24c8 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/models/OperationInner.java @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.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.containerservicesafeguards.models.ActionType; +import com.azure.resourcemanager.containerservicesafeguards.models.OperationDisplay; +import com.azure.resourcemanager.containerservicesafeguards.models.Origin; +import java.io.IOException; + +/** + * REST API Operation + * + * 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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/models/package-info.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/models/package-info.java new file mode 100644 index 000000000000..9dcc8cc3d01b --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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 ContainerServiceSafeguards. + * Azure Kubernetes Service Deployment Safeguards API Client. + */ +package com.azure.resourcemanager.containerservicesafeguards.fluent.models; diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/package-info.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/fluent/package-info.java new file mode 100644 index 000000000000..8262d7294387 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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 ContainerServiceSafeguards. + * Azure Kubernetes Service Deployment Safeguards API Client. + */ +package com.azure.resourcemanager.containerservicesafeguards.fluent; diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/ContainerServiceSafeguardsManagementClientBuilder.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/ContainerServiceSafeguardsManagementClientBuilder.java new file mode 100644 index 000000000000..6ee3ccd1256d --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/ContainerServiceSafeguardsManagementClientBuilder.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.containerservicesafeguards.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 ContainerServiceSafeguardsManagementClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { ContainerServiceSafeguardsManagementClientImpl.class }) +public final class ContainerServiceSafeguardsManagementClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the ContainerServiceSafeguardsManagementClientBuilder. + */ + public ContainerServiceSafeguardsManagementClientBuilder 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 ContainerServiceSafeguardsManagementClientBuilder. + */ + public ContainerServiceSafeguardsManagementClientBuilder 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 ContainerServiceSafeguardsManagementClientBuilder. + */ + public ContainerServiceSafeguardsManagementClientBuilder 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 ContainerServiceSafeguardsManagementClientBuilder. + */ + public ContainerServiceSafeguardsManagementClientBuilder 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 ContainerServiceSafeguardsManagementClientBuilder. + */ + public ContainerServiceSafeguardsManagementClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ContainerServiceSafeguardsManagementClientImpl with the provided parameters. + * + * @return an instance of ContainerServiceSafeguardsManagementClientImpl. + */ + public ContainerServiceSafeguardsManagementClientImpl 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(); + ContainerServiceSafeguardsManagementClientImpl client = new ContainerServiceSafeguardsManagementClientImpl( + localPipeline, localSerializerAdapter, localDefaultPollInterval, localEnvironment, localEndpoint); + return client; + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/ContainerServiceSafeguardsManagementClientImpl.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/ContainerServiceSafeguardsManagementClientImpl.java new file mode 100644 index 000000000000..ff4c15890987 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/ContainerServiceSafeguardsManagementClientImpl.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.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.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +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.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.containerservicesafeguards.fluent.ContainerServiceSafeguardsManagementClient; +import com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient; +import com.azure.resourcemanager.containerservicesafeguards.fluent.OperationsClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ContainerServiceSafeguardsManagementClientImpl type. + */ +@ServiceClient(builder = ContainerServiceSafeguardsManagementClientBuilder.class) +public final class ContainerServiceSafeguardsManagementClientImpl + implements ContainerServiceSafeguardsManagementClient { + /** + * 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 DeploymentSafeguardsClient object to access its operations. + */ + private final DeploymentSafeguardsClient deploymentSafeguards; + + /** + * Gets the DeploymentSafeguardsClient object to access its operations. + * + * @return the DeploymentSafeguardsClient object. + */ + public DeploymentSafeguardsClient getDeploymentSafeguards() { + return this.deploymentSafeguards; + } + + /** + * Initializes an instance of ContainerServiceSafeguardsManagementClient 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. + */ + ContainerServiceSafeguardsManagementClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.apiVersion = "2025-05-02-preview"; + this.operations = new OperationsClientImpl(this); + this.deploymentSafeguards = new DeploymentSafeguardsClientImpl(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 long running operation result. + * + * @param activationResponse the response of activation operation. + * @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 SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.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(ContainerServiceSafeguardsManagementClientImpl.class); +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/DeploymentSafeguardImpl.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/DeploymentSafeguardImpl.java new file mode 100644 index 000000000000..46c8a29349b4 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/DeploymentSafeguardImpl.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.implementation; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguard; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsProperties; + +public final class DeploymentSafeguardImpl implements DeploymentSafeguard { + private DeploymentSafeguardInner innerObject; + + private final com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager serviceManager; + + DeploymentSafeguardImpl(DeploymentSafeguardInner innerObject, + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager 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 DeploymentSafeguardsProperties properties() { + return this.innerModel().properties(); + } + + public String eTag() { + return this.innerModel().eTag(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public DeploymentSafeguardInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/DeploymentSafeguardsClientImpl.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/DeploymentSafeguardsClientImpl.java new file mode 100644 index 000000000000..5315b924f72a --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/DeploymentSafeguardsClientImpl.java @@ -0,0 +1,817 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.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.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient; +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; +import com.azure.resourcemanager.containerservicesafeguards.implementation.models.DeploymentSafeguardListResult; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in DeploymentSafeguardsClient. + */ +public final class DeploymentSafeguardsClientImpl implements DeploymentSafeguardsClient { + /** + * The proxy service used to perform REST calls. + */ + private final DeploymentSafeguardsService service; + + /** + * The service client containing this operation class. + */ + private final ContainerServiceSafeguardsManagementClientImpl client; + + /** + * Initializes an instance of DeploymentSafeguardsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DeploymentSafeguardsClientImpl(ContainerServiceSafeguardsManagementClientImpl client) { + this.service = RestProxy.create(DeploymentSafeguardsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ContainerServiceSafeguardsManagementClientDeploymentSafeguards to be + * used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ContainerServiceSafeguardsManagementClientDeploymentSafeguards") + public interface DeploymentSafeguardsService { + @Headers({ "Content-Type: application/json" }) + @Get("/{resourceUri}/providers/Microsoft.ContainerService/deploymentSafeguards/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "resourceUri", encoded = true) String resourceUri, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/{resourceUri}/providers/Microsoft.ContainerService/deploymentSafeguards/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "resourceUri", encoded = true) String resourceUri, @HeaderParam("Accept") String accept, + Context context); + + @Put("/{resourceUri}/providers/Microsoft.ContainerService/deploymentSafeguards/default") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> create(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "resourceUri", encoded = true) String resourceUri, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") DeploymentSafeguardInner resource, Context context); + + @Put("/{resourceUri}/providers/Microsoft.ContainerService/deploymentSafeguards/default") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "resourceUri", encoded = true) String resourceUri, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") DeploymentSafeguardInner resource, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/{resourceUri}/providers/Microsoft.ContainerService/deploymentSafeguards/default") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "resourceUri", encoded = true) String resourceUri, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/{resourceUri}/providers/Microsoft.ContainerService/deploymentSafeguards/default") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "resourceUri", encoded = true) String resourceUri, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/{resourceUri}/providers/Microsoft.ContainerService/deploymentSafeguards") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "resourceUri", encoded = true) String resourceUri, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/{resourceUri}/providers/Microsoft.ContainerService/deploymentSafeguards") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam(value = "resourceUri", encoded = true) String resourceUri, @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); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Fetch a deployment safeguard by name. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceUri) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Fetch a deployment safeguard by name. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceUri) { + return getWithResponseAsync(resourceUri).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Fetch a deployment safeguard by name. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceUri, Context context) { + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, accept, context); + } + + /** + * Fetch a deployment safeguard by name. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DeploymentSafeguardInner get(String resourceUri) { + return getWithResponse(resourceUri, Context.NONE).getValue(); + } + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync(String resourceUri, + DeploymentSafeguardInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri 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.create(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createWithResponse(String resourceUri, DeploymentSafeguardInner resource) { + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (resource == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, contentType, + accept, resource, Context.NONE); + } + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createWithResponse(String resourceUri, DeploymentSafeguardInner resource, + Context context) { + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (resource == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, contentType, + accept, resource, context); + } + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, DeploymentSafeguardInner> + beginCreateAsync(String resourceUri, DeploymentSafeguardInner resource) { + Mono>> mono = createWithResponseAsync(resourceUri, resource); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), DeploymentSafeguardInner.class, DeploymentSafeguardInner.class, + this.client.getContext()); + } + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, DeploymentSafeguardInner> beginCreate(String resourceUri, + DeploymentSafeguardInner resource) { + Response response = createWithResponse(resourceUri, resource); + return this.client.getLroResult(response, + DeploymentSafeguardInner.class, DeploymentSafeguardInner.class, Context.NONE); + } + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, DeploymentSafeguardInner> beginCreate(String resourceUri, + DeploymentSafeguardInner resource, Context context) { + Response response = createWithResponse(resourceUri, resource, context); + return this.client.getLroResult(response, + DeploymentSafeguardInner.class, DeploymentSafeguardInner.class, context); + } + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync(String resourceUri, DeploymentSafeguardInner resource) { + return beginCreateAsync(resourceUri, resource).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DeploymentSafeguardInner create(String resourceUri, DeploymentSafeguardInner resource) { + return beginCreate(resourceUri, resource).getFinalResult(); + } + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DeploymentSafeguardInner create(String resourceUri, DeploymentSafeguardInner resource, Context context) { + return beginCreate(resourceUri, resource, context).getFinalResult(); + } + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceUri) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response deleteWithResponse(String resourceUri) { + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + final String accept = "application/json"; + return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, accept, + Context.NONE); + } + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response deleteWithResponse(String resourceUri, Context context) { + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + final String accept = "application/json"; + return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, accept, context); + } + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceUri) { + Mono>> mono = deleteWithResponseAsync(resourceUri); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceUri) { + Response response = deleteWithResponse(resourceUri); + return this.client.getLroResult(response, Void.class, Void.class, Context.NONE); + } + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceUri, Context context) { + Response response = deleteWithResponse(resourceUri, context); + return this.client.getLroResult(response, Void.class, Void.class, context); + } + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceUri) { + return beginDeleteAsync(resourceUri).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceUri) { + beginDelete(resourceUri).getFinalResult(); + } + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceUri, Context context) { + beginDelete(resourceUri, context).getFinalResult(); + } + + /** + * List DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String resourceUri) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + 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 DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String resourceUri) { + return new PagedFlux<>(() -> listSinglePageAsync(resourceUri), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String resourceUri) { + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getApiVersion(), resourceUri, accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String resourceUri, Context context) { + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + final String accept = "application/json"; + Response res + = service.listSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String resourceUri) { + return new PagedIterable<>(() -> listSinglePage(resourceUri), nextLink -> listNextSinglePage(nextLink)); + } + + /** + * List DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String resourceUri, Context context) { + return new PagedIterable<>(() -> listSinglePage(resourceUri, context), + nextLink -> listNextSinglePage(nextLink, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink) { + if (nextLink == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, Context context) { + if (nextLink == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + private static final ClientLogger LOGGER = new ClientLogger(DeploymentSafeguardsClientImpl.class); +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/DeploymentSafeguardsImpl.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/DeploymentSafeguardsImpl.java new file mode 100644 index 000000000000..328e4fce5059 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/DeploymentSafeguardsImpl.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient; +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguard; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguards; + +public final class DeploymentSafeguardsImpl implements DeploymentSafeguards { + private static final ClientLogger LOGGER = new ClientLogger(DeploymentSafeguardsImpl.class); + + private final DeploymentSafeguardsClient innerClient; + + private final com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager serviceManager; + + public DeploymentSafeguardsImpl(DeploymentSafeguardsClient innerClient, + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceUri, Context context) { + Response inner = this.serviceClient().getWithResponse(resourceUri, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new DeploymentSafeguardImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public DeploymentSafeguard get(String resourceUri) { + DeploymentSafeguardInner inner = this.serviceClient().get(resourceUri); + if (inner != null) { + return new DeploymentSafeguardImpl(inner, this.manager()); + } else { + return null; + } + } + + public DeploymentSafeguard create(String resourceUri, DeploymentSafeguardInner resource) { + DeploymentSafeguardInner inner = this.serviceClient().create(resourceUri, resource); + if (inner != null) { + return new DeploymentSafeguardImpl(inner, this.manager()); + } else { + return null; + } + } + + public DeploymentSafeguard create(String resourceUri, DeploymentSafeguardInner resource, Context context) { + DeploymentSafeguardInner inner = this.serviceClient().create(resourceUri, resource, context); + if (inner != null) { + return new DeploymentSafeguardImpl(inner, this.manager()); + } else { + return null; + } + } + + public void delete(String resourceUri) { + this.serviceClient().delete(resourceUri); + } + + public void delete(String resourceUri, Context context) { + this.serviceClient().delete(resourceUri, context); + } + + public PagedIterable list(String resourceUri) { + PagedIterable inner = this.serviceClient().list(resourceUri); + return ResourceManagerUtils.mapPage(inner, inner1 -> new DeploymentSafeguardImpl(inner1, this.manager())); + } + + public PagedIterable list(String resourceUri, Context context) { + PagedIterable inner = this.serviceClient().list(resourceUri, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new DeploymentSafeguardImpl(inner1, this.manager())); + } + + private DeploymentSafeguardsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/OperationImpl.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/OperationImpl.java new file mode 100644 index 000000000000..cf717605b758 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.implementation; + +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.OperationInner; +import com.azure.resourcemanager.containerservicesafeguards.models.ActionType; +import com.azure.resourcemanager.containerservicesafeguards.models.Operation; +import com.azure.resourcemanager.containerservicesafeguards.models.OperationDisplay; +import com.azure.resourcemanager.containerservicesafeguards.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager serviceManager; + + OperationImpl(OperationInner innerObject, + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager 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.containerservicesafeguards.ContainerServiceSafeguardsManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/OperationsClientImpl.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..24256c571fca --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/OperationsClientImpl.java @@ -0,0 +1,284 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.containerservicesafeguards.fluent.OperationsClient; +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.OperationInner; +import com.azure.resourcemanager.containerservicesafeguards.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 ContainerServiceSafeguardsManagementClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(ContainerServiceSafeguardsManagementClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ContainerServiceSafeguardsManagementClientOperations to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ContainerServiceSafeguardsManagementClientOperations") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.ContainerService/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("/providers/Microsoft.ContainerService/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listSync(@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); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listNextSync(@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. + * + * @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. + * + * @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}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage() { + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + Response res + = service.listSync(this.client.getEndpoint(), this.client.getApiVersion(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * 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}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(Context context) { + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + Response res + = service.listSync(this.client.getEndpoint(), this.client.getApiVersion(), accept, context); + return 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 PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(() -> listSinglePage(), nextLink -> listNextSinglePage(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 PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(() -> listSinglePage(context), nextLink -> listNextSinglePage(nextLink, 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. + * @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}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink) { + if (nextLink == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @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}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, Context context) { + if (nextLink == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + Response res = service.listNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + private static final ClientLogger LOGGER = new ClientLogger(OperationsClientImpl.class); +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/OperationsImpl.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/OperationsImpl.java new file mode 100644 index 000000000000..9b3deba5fd30 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.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.containerservicesafeguards.fluent.OperationsClient; +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.OperationInner; +import com.azure.resourcemanager.containerservicesafeguards.models.Operation; +import com.azure.resourcemanager.containerservicesafeguards.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.containerservicesafeguards.ContainerServiceSafeguardsManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager 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.containerservicesafeguards.ContainerServiceSafeguardsManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/ResourceManagerUtils.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000000..b18f926c1761 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/models/DeploymentSafeguardListResult.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/models/DeploymentSafeguardListResult.java new file mode 100644 index 000000000000..f0a931a46e79 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/models/DeploymentSafeguardListResult.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.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.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a DeploymentSafeguard list operation. + */ +@Immutable +public final class DeploymentSafeguardListResult implements JsonSerializable { + /* + * The DeploymentSafeguard items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of DeploymentSafeguardListResult class. + */ + private DeploymentSafeguardListResult() { + } + + /** + * Get the value property: The DeploymentSafeguard 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 DeploymentSafeguardListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DeploymentSafeguardListResult.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 DeploymentSafeguardListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DeploymentSafeguardListResult 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 DeploymentSafeguardListResult. + */ + public static DeploymentSafeguardListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DeploymentSafeguardListResult deserializedDeploymentSafeguardListResult + = new DeploymentSafeguardListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> DeploymentSafeguardInner.fromJson(reader1)); + deserializedDeploymentSafeguardListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedDeploymentSafeguardListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedDeploymentSafeguardListResult; + }); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/models/OperationListResult.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/models/OperationListResult.java new file mode 100644 index 000000000000..c6abd63a8d64 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.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.containerservicesafeguards.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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/package-info.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/implementation/package-info.java new file mode 100644 index 000000000000..bce62e59c974 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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 ContainerServiceSafeguards. + * Azure Kubernetes Service Deployment Safeguards API Client. + */ +package com.azure.resourcemanager.containerservicesafeguards.implementation; diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/ActionType.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/ActionType.java new file mode 100644 index 000000000000..93429b5001da --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguard.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguard.java new file mode 100644 index 000000000000..6c05db9c37f5 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguard.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.models; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; + +/** + * An immutable client-side representation of DeploymentSafeguard. + */ +public interface DeploymentSafeguard { + /** + * 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. + */ + DeploymentSafeguardsProperties properties(); + + /** + * Gets the eTag property: If eTag is provided in the response body, it may also be provided as a header per the + * normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. + * HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), + * and If-Range (section 14.27) header fields. + * + * @return the eTag value. + */ + String eTag(); + + /** + * 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.containerservicesafeguards.fluent.models.DeploymentSafeguardInner + * object. + * + * @return the inner object. + */ + DeploymentSafeguardInner innerModel(); +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguards.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguards.java new file mode 100644 index 000000000000..0cb39bbd2a3a --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguards.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; + +/** + * Resource collection API of DeploymentSafeguards. + */ +public interface DeploymentSafeguards { + /** + * Fetch a deployment safeguard by name. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards along with {@link Response}. + */ + Response getWithResponse(String resourceUri, Context context); + + /** + * Fetch a deployment safeguard by name. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards. + */ + DeploymentSafeguard get(String resourceUri); + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards. + */ + DeploymentSafeguard create(String resourceUri, DeploymentSafeguardInner resource); + + /** + * Creates or updates a deploymentSafeguard. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return deployment Safeguards. + */ + DeploymentSafeguard create(String resourceUri, DeploymentSafeguardInner resource, Context context); + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceUri); + + /** + * Delete DeploymentSafeguards. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceUri, Context context); + + /** + * List DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(String resourceUri); + + /** + * List DeploymentSafeguards by parent resource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DeploymentSafeguard list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(String resourceUri, Context context); +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguardsLevel.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguardsLevel.java new file mode 100644 index 000000000000..54c7f2ef1f59 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguardsLevel.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.containerservicesafeguards.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies the level of Deployment Safeguards. + */ +public final class DeploymentSafeguardsLevel extends ExpandableStringEnum { + /** + * Best practice violations will only show warnings. + */ + public static final DeploymentSafeguardsLevel WARN = fromString("Warn"); + + /** + * Best practice violations will be denied. + */ + public static final DeploymentSafeguardsLevel ENFORCE = fromString("Enforce"); + + /** + * Creates a new instance of DeploymentSafeguardsLevel value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DeploymentSafeguardsLevel() { + } + + /** + * Creates or finds a DeploymentSafeguardsLevel from its string representation. + * + * @param name a name to look for. + * @return the corresponding DeploymentSafeguardsLevel. + */ + public static DeploymentSafeguardsLevel fromString(String name) { + return fromString(name, DeploymentSafeguardsLevel.class); + } + + /** + * Gets known DeploymentSafeguardsLevel values. + * + * @return known DeploymentSafeguardsLevel values. + */ + public static Collection values() { + return values(DeploymentSafeguardsLevel.class); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguardsProperties.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguardsProperties.java new file mode 100644 index 000000000000..2243ccc428e3 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/DeploymentSafeguardsProperties.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.models; + +import com.azure.core.annotation.Fluent; +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 java.io.IOException; +import java.util.List; + +/** + * DeploymentSafeguards Properties. + */ +@Fluent +public final class DeploymentSafeguardsProperties implements JsonSerializable { + /* + * Provisioning State + */ + private ProvisioningState provisioningState; + + /* + * The deployment safeguards level. Possible values are Warn and Enforce + */ + private DeploymentSafeguardsLevel level; + + /* + * User defined list of namespaces to exclude from Deployment Safeguards. Deployments in these namespaces will not + * be checked against any safeguards + */ + private List excludedNamespaces; + + /* + * System defined list of namespaces excluded from Deployment Safeguards. These are determined by the underlying + * provider (such as AKS), and cannot be changed. Deployments in these namespaces will not be checked + */ + private List systemExcludedNamespaces; + + /* + * The pod security standards level + */ + private PodSecurityStandardsLevel podSecurityStandardsLevel; + + /** + * Creates an instance of DeploymentSafeguardsProperties class. + */ + public DeploymentSafeguardsProperties() { + } + + /** + * Get the provisioningState property: Provisioning State. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the level property: The deployment safeguards level. Possible values are Warn and Enforce. + * + * @return the level value. + */ + public DeploymentSafeguardsLevel level() { + return this.level; + } + + /** + * Set the level property: The deployment safeguards level. Possible values are Warn and Enforce. + * + * @param level the level value to set. + * @return the DeploymentSafeguardsProperties object itself. + */ + public DeploymentSafeguardsProperties withLevel(DeploymentSafeguardsLevel level) { + this.level = level; + return this; + } + + /** + * Get the excludedNamespaces property: User defined list of namespaces to exclude from Deployment Safeguards. + * Deployments in these namespaces will not be checked against any safeguards. + * + * @return the excludedNamespaces value. + */ + public List excludedNamespaces() { + return this.excludedNamespaces; + } + + /** + * Set the excludedNamespaces property: User defined list of namespaces to exclude from Deployment Safeguards. + * Deployments in these namespaces will not be checked against any safeguards. + * + * @param excludedNamespaces the excludedNamespaces value to set. + * @return the DeploymentSafeguardsProperties object itself. + */ + public DeploymentSafeguardsProperties withExcludedNamespaces(List excludedNamespaces) { + this.excludedNamespaces = excludedNamespaces; + return this; + } + + /** + * Get the systemExcludedNamespaces property: System defined list of namespaces excluded from Deployment Safeguards. + * These are determined by the underlying provider (such as AKS), and cannot be changed. Deployments in these + * namespaces will not be checked. + * + * @return the systemExcludedNamespaces value. + */ + public List systemExcludedNamespaces() { + return this.systemExcludedNamespaces; + } + + /** + * Get the podSecurityStandardsLevel property: The pod security standards level. + * + * @return the podSecurityStandardsLevel value. + */ + public PodSecurityStandardsLevel podSecurityStandardsLevel() { + return this.podSecurityStandardsLevel; + } + + /** + * Set the podSecurityStandardsLevel property: The pod security standards level. + * + * @param podSecurityStandardsLevel the podSecurityStandardsLevel value to set. + * @return the DeploymentSafeguardsProperties object itself. + */ + public DeploymentSafeguardsProperties + withPodSecurityStandardsLevel(PodSecurityStandardsLevel podSecurityStandardsLevel) { + this.podSecurityStandardsLevel = podSecurityStandardsLevel; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (level() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property level in model DeploymentSafeguardsProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DeploymentSafeguardsProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("level", this.level == null ? null : this.level.toString()); + jsonWriter.writeArrayField("excludedNamespaces", this.excludedNamespaces, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("podSecurityStandardsLevel", + this.podSecurityStandardsLevel == null ? null : this.podSecurityStandardsLevel.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DeploymentSafeguardsProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DeploymentSafeguardsProperties 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 DeploymentSafeguardsProperties. + */ + public static DeploymentSafeguardsProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DeploymentSafeguardsProperties deserializedDeploymentSafeguardsProperties + = new DeploymentSafeguardsProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("level".equals(fieldName)) { + deserializedDeploymentSafeguardsProperties.level + = DeploymentSafeguardsLevel.fromString(reader.getString()); + } else if ("systemExcludedNamespaces".equals(fieldName)) { + List systemExcludedNamespaces = reader.readArray(reader1 -> reader1.getString()); + deserializedDeploymentSafeguardsProperties.systemExcludedNamespaces = systemExcludedNamespaces; + } else if ("provisioningState".equals(fieldName)) { + deserializedDeploymentSafeguardsProperties.provisioningState + = ProvisioningState.fromString(reader.getString()); + } else if ("excludedNamespaces".equals(fieldName)) { + List excludedNamespaces = reader.readArray(reader1 -> reader1.getString()); + deserializedDeploymentSafeguardsProperties.excludedNamespaces = excludedNamespaces; + } else if ("podSecurityStandardsLevel".equals(fieldName)) { + deserializedDeploymentSafeguardsProperties.podSecurityStandardsLevel + = PodSecurityStandardsLevel.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedDeploymentSafeguardsProperties; + }); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/Operation.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/Operation.java new file mode 100644 index 000000000000..4685f6e2150e --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.models; + +import com.azure.resourcemanager.containerservicesafeguards.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.containerservicesafeguards.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/OperationDisplay.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/OperationDisplay.java new file mode 100644 index 000000000000..d6602954dff0 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/Operations.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/Operations.java new file mode 100644 index 000000000000..cc80255cfed3 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/Origin.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/Origin.java new file mode 100644 index 000000000000..e070b725fd1d --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/PodSecurityStandardsLevel.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/PodSecurityStandardsLevel.java new file mode 100644 index 000000000000..8d000cf43a38 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/PodSecurityStandardsLevel.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.containerservicesafeguards.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies the Pod Security Standards level. + */ +public final class PodSecurityStandardsLevel extends ExpandableStringEnum { + /** + * Privileged level is an unrestricted policy, providing the widest possible level of permissions. This policy + * allows for known privilege escalations. + */ + public static final PodSecurityStandardsLevel POD_SECURITY_STANDARDS_PRIVILEGED = fromString("Privileged"); + + /** + * Baseline level is a minimally restrictive policy which prevents known privilege escalations. Allows the default + * (minimally specified) Pod configuration. + */ + public static final PodSecurityStandardsLevel POD_SECURITY_STANDARDS_BASELINE = fromString("Baseline"); + + /** + * Restricted level is a heavily restricted policy, following current Pod hardening best practices. + */ + public static final PodSecurityStandardsLevel POD_SECURITY_STANDARDS_RESTRICTED = fromString("Restricted"); + + /** + * Creates a new instance of PodSecurityStandardsLevel value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public PodSecurityStandardsLevel() { + } + + /** + * Creates or finds a PodSecurityStandardsLevel from its string representation. + * + * @param name a name to look for. + * @return the corresponding PodSecurityStandardsLevel. + */ + public static PodSecurityStandardsLevel fromString(String name) { + return fromString(name, PodSecurityStandardsLevel.class); + } + + /** + * Gets known PodSecurityStandardsLevel values. + * + * @return known PodSecurityStandardsLevel values. + */ + public static Collection values() { + return values(PodSecurityStandardsLevel.class); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/ProvisioningState.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/ProvisioningState.java new file mode 100644 index 000000000000..f01fdd8b61fe --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/ProvisioningState.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The provisioning state of the last accepted operation. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** + * The provisioning state of DeploymentSafeguards being created. + */ + public static final ProvisioningState CREATING = fromString("Creating"); + + /** + * The provisioning state of DeploymentSafeguards being updated. + */ + public static final ProvisioningState UPDATING = fromString("Updating"); + + /** + * The provisioning state of DeploymentSafeguards being deleted. + */ + public static final ProvisioningState DELETING = fromString("Deleting"); + + /** + * Creates a new instance of ProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ProvisioningState() { + } + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** + * Gets known ProvisioningState values. + * + * @return known ProvisioningState values. + */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/package-info.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/models/package-info.java new file mode 100644 index 000000000000..8126c23e9e6d --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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 ContainerServiceSafeguards. + * Azure Kubernetes Service Deployment Safeguards API Client. + */ +package com.azure.resourcemanager.containerservicesafeguards.models; diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/package-info.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/package-info.java new file mode 100644 index 000000000000..cba3a123b3f9 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/com/azure/resourcemanager/containerservicesafeguards/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 ContainerServiceSafeguards. + * Azure Kubernetes Service Deployment Safeguards API Client. + */ +package com.azure.resourcemanager.containerservicesafeguards; diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/module-info.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/java/module-info.java new file mode 100644 index 000000000000..d6d38943458b --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/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.containerservicesafeguards { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.containerservicesafeguards; + exports com.azure.resourcemanager.containerservicesafeguards.fluent; + exports com.azure.resourcemanager.containerservicesafeguards.fluent.models; + exports com.azure.resourcemanager.containerservicesafeguards.models; + + opens com.azure.resourcemanager.containerservicesafeguards.fluent.models to com.azure.core; + opens com.azure.resourcemanager.containerservicesafeguards.models to com.azure.core; + opens com.azure.resourcemanager.containerservicesafeguards.implementation.models to com.azure.core; +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/azure-resourcemanager-containerservicesafeguards_apiview_properties.json b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/azure-resourcemanager-containerservicesafeguards_apiview_properties.json new file mode 100644 index 000000000000..e0d2e120be83 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/azure-resourcemanager-containerservicesafeguards_apiview_properties.json @@ -0,0 +1,28 @@ +{ + "flavor": "azure", + "CrossLanguageDefinitionId": { + "com.azure.resourcemanager.containerservicesafeguards.fluent.ContainerServiceSafeguardsManagementClient": "Microsoft.ContainerService", + "com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient": "Microsoft.ContainerService.DeploymentSafeguards", + "com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.beginCreate": "Microsoft.ContainerService.DeploymentSafeguards.create", + "com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.beginDelete": "Microsoft.ContainerService.DeploymentSafeguards.delete", + "com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.create": "Microsoft.ContainerService.DeploymentSafeguards.create", + "com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.delete": "Microsoft.ContainerService.DeploymentSafeguards.delete", + "com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.get": "Microsoft.ContainerService.DeploymentSafeguards.get", + "com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.getWithResponse": "Microsoft.ContainerService.DeploymentSafeguards.get", + "com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.list": "Microsoft.ContainerService.DeploymentSafeguards.list", + "com.azure.resourcemanager.containerservicesafeguards.fluent.OperationsClient": "Microsoft.ContainerService.Operations", + "com.azure.resourcemanager.containerservicesafeguards.fluent.OperationsClient.list": "Azure.ResourceManager.Operations.list", + "com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner": "Microsoft.ContainerService.DeploymentSafeguard", + "com.azure.resourcemanager.containerservicesafeguards.fluent.models.OperationInner": "Azure.ResourceManager.CommonTypes.Operation", + "com.azure.resourcemanager.containerservicesafeguards.implementation.ContainerServiceSafeguardsManagementClientBuilder": "Microsoft.ContainerService", + "com.azure.resourcemanager.containerservicesafeguards.implementation.models.DeploymentSafeguardListResult": "Azure.ResourceManager.ResourceListResult", + "com.azure.resourcemanager.containerservicesafeguards.implementation.models.OperationListResult": "Azure.ResourceManager.CommonTypes.OperationListResult", + "com.azure.resourcemanager.containerservicesafeguards.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsLevel": "Microsoft.ContainerService.DeploymentSafeguardsLevel", + "com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsProperties": "Microsoft.ContainerService.DeploymentSafeguardsProperties", + "com.azure.resourcemanager.containerservicesafeguards.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "com.azure.resourcemanager.containerservicesafeguards.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "com.azure.resourcemanager.containerservicesafeguards.models.PodSecurityStandardsLevel": "Microsoft.ContainerService.PodSecurityStandardsLevel", + "com.azure.resourcemanager.containerservicesafeguards.models.ProvisioningState": "Microsoft.ContainerService.ProvisioningState" + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/azure-resourcemanager-containerservicesafeguards_metadata.json b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/azure-resourcemanager-containerservicesafeguards_metadata.json new file mode 100644 index 000000000000..ad654db61279 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/azure-resourcemanager-containerservicesafeguards_metadata.json @@ -0,0 +1 @@ +{"flavor":"azure","apiVersion":"2025-05-02-preview","crossLanguageDefinitions":{"com.azure.resourcemanager.containerservicesafeguards.fluent.ContainerServiceSafeguardsManagementClient":"Microsoft.ContainerService","com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient":"Microsoft.ContainerService.DeploymentSafeguards","com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.beginCreate":"Microsoft.ContainerService.DeploymentSafeguards.create","com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.beginDelete":"Microsoft.ContainerService.DeploymentSafeguards.delete","com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.create":"Microsoft.ContainerService.DeploymentSafeguards.create","com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.delete":"Microsoft.ContainerService.DeploymentSafeguards.delete","com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.get":"Microsoft.ContainerService.DeploymentSafeguards.get","com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.getWithResponse":"Microsoft.ContainerService.DeploymentSafeguards.get","com.azure.resourcemanager.containerservicesafeguards.fluent.DeploymentSafeguardsClient.list":"Microsoft.ContainerService.DeploymentSafeguards.list","com.azure.resourcemanager.containerservicesafeguards.fluent.OperationsClient":"Microsoft.ContainerService.Operations","com.azure.resourcemanager.containerservicesafeguards.fluent.OperationsClient.list":"Azure.ResourceManager.Operations.list","com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner":"Microsoft.ContainerService.DeploymentSafeguard","com.azure.resourcemanager.containerservicesafeguards.fluent.models.OperationInner":"Azure.ResourceManager.CommonTypes.Operation","com.azure.resourcemanager.containerservicesafeguards.implementation.ContainerServiceSafeguardsManagementClientBuilder":"Microsoft.ContainerService","com.azure.resourcemanager.containerservicesafeguards.implementation.models.DeploymentSafeguardListResult":"Azure.ResourceManager.ResourceListResult","com.azure.resourcemanager.containerservicesafeguards.implementation.models.OperationListResult":"Azure.ResourceManager.CommonTypes.OperationListResult","com.azure.resourcemanager.containerservicesafeguards.models.ActionType":"Azure.ResourceManager.CommonTypes.ActionType","com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsLevel":"Microsoft.ContainerService.DeploymentSafeguardsLevel","com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsProperties":"Microsoft.ContainerService.DeploymentSafeguardsProperties","com.azure.resourcemanager.containerservicesafeguards.models.OperationDisplay":"Azure.ResourceManager.CommonTypes.OperationDisplay","com.azure.resourcemanager.containerservicesafeguards.models.Origin":"Azure.ResourceManager.CommonTypes.Origin","com.azure.resourcemanager.containerservicesafeguards.models.PodSecurityStandardsLevel":"Microsoft.ContainerService.PodSecurityStandardsLevel","com.azure.resourcemanager.containerservicesafeguards.models.ProvisioningState":"Microsoft.ContainerService.ProvisioningState"}} \ No newline at end of file diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-containerservicesafeguards/proxy-config.json b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-containerservicesafeguards/proxy-config.json new file mode 100644 index 000000000000..84e44543c242 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-containerservicesafeguards/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.containerservicesafeguards.implementation.DeploymentSafeguardsClientImpl$DeploymentSafeguardsService"],["com.azure.resourcemanager.containerservicesafeguards.implementation.OperationsClientImpl$OperationsService"]] \ No newline at end of file diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-containerservicesafeguards/reflect-config.json b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-containerservicesafeguards/reflect-config.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-containerservicesafeguards/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/azure-resourcemanager-containerservicesafeguards.properties b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/azure-resourcemanager-containerservicesafeguards.properties new file mode 100644 index 000000000000..defbd48204e4 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/main/resources/azure-resourcemanager-containerservicesafeguards.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsCreateSamples.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsCreateSamples.java new file mode 100644 index 000000000000..8f42a4571ccb --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsCreateSamples.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.generated; + +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsLevel; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsProperties; +import com.azure.resourcemanager.containerservicesafeguards.models.PodSecurityStandardsLevel; + +/** + * Samples for DeploymentSafeguards Create. + */ +public final class DeploymentSafeguardsCreateSamples { + /* + * x-ms-original-file: 2025-05-02-preview/DeploymentSafeguards_Create.json + */ + /** + * Sample code: Creates a DeploymentSafeguards resource with a long running operation. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void createsADeploymentSafeguardsResourceWithALongRunningOperation( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.deploymentSafeguards() + .create( + "subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1", + new DeploymentSafeguardInner() + .withProperties(new DeploymentSafeguardsProperties().withLevel(DeploymentSafeguardsLevel.WARN) + .withPodSecurityStandardsLevel(PodSecurityStandardsLevel.POD_SECURITY_STANDARDS_BASELINE)), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsDeleteSamples.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsDeleteSamples.java new file mode 100644 index 000000000000..535361cb0b56 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsDeleteSamples.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.containerservicesafeguards.generated; + +/** + * Samples for DeploymentSafeguards Delete. + */ +public final class DeploymentSafeguardsDeleteSamples { + /* + * x-ms-original-file: 2025-05-02-preview/DeploymentSafeguards_Delete.json + */ + /** + * Sample code: Deletes a DeploymentSafeguard resource asynchronously with a long running operation. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void deletesADeploymentSafeguardResourceAsynchronouslyWithALongRunningOperation( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.deploymentSafeguards() + .delete( + "subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsGetSamples.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsGetSamples.java new file mode 100644 index 000000000000..e2134e09c64f --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsGetSamples.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.containerservicesafeguards.generated; + +/** + * Samples for DeploymentSafeguards Get. + */ +public final class DeploymentSafeguardsGetSamples { + /* + * x-ms-original-file: 2025-05-02-preview/DeploymentSafeguards_Get.json + */ + /** + * Sample code: Gets a DeploymentSafeguard resource. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void getsADeploymentSafeguardResource( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.deploymentSafeguards() + .getWithResponse( + "subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsListSamples.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsListSamples.java new file mode 100644 index 000000000000..a21329f4ef1a --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsListSamples.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.containerservicesafeguards.generated; + +/** + * Samples for DeploymentSafeguards List. + */ +public final class DeploymentSafeguardsListSamples { + /* + * x-ms-original-file: 2025-05-02-preview/DeploymentSafeguards_List.json + */ + /** + * Sample code: Lists DeploymentSafeguards by parent resource. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void listsDeploymentSafeguardsByParentResource( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.deploymentSafeguards() + .list( + "subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/OperationsListSamples.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/generated/OperationsListSamples.java new file mode 100644 index 000000000000..0e0133c4da20 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/samples/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.generated; + +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2025-05-02-preview/Operations_List.json + */ + /** + * Sample code: List the operations for the provider. + * + * @param manager Entry point to ContainerServiceSafeguardsManager. + */ + public static void listTheOperationsForTheProvider( + com.azure.resourcemanager.containerservicesafeguards.ContainerServiceSafeguardsManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsCreateMockTests.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsCreateMockTests.java new file mode 100644 index 000000000000..33a9944c6685 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsCreateMockTests.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.containerservicesafeguards.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.containerservicesafeguards.ContainerServiceSafeguardsManager; +import com.azure.resourcemanager.containerservicesafeguards.fluent.models.DeploymentSafeguardInner; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguard; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsLevel; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsProperties; +import com.azure.resourcemanager.containerservicesafeguards.models.PodSecurityStandardsLevel; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class DeploymentSafeguardsCreateMockTests { + @Test + public void testCreate() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Succeeded\",\"level\":\"Enforce\",\"excludedNamespaces\":[\"ksqrglssai\",\"qpjwnzlljfm\"],\"systemExcludedNamespaces\":[\"eebvmgxsab\"],\"podSecurityStandardsLevel\":\"Restricted\"},\"eTag\":\"uujitcjc\",\"id\":\"zevndhkrwpdappds\",\"name\":\"dkvwrwjfe\",\"type\":\"snhu\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + ContainerServiceSafeguardsManager manager = ContainerServiceSafeguardsManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + DeploymentSafeguard response = manager.deploymentSafeguards() + .create("cciqihnhungbwjz", + new DeploymentSafeguardInner() + .withProperties(new DeploymentSafeguardsProperties().withLevel(DeploymentSafeguardsLevel.WARN) + .withExcludedNamespaces(Arrays.asList("ispe", "vtz", "kufubljo", "xqeofjaeqjhqjba")) + .withPodSecurityStandardsLevel(PodSecurityStandardsLevel.POD_SECURITY_STANDARDS_BASELINE)), + com.azure.core.util.Context.NONE); + + Assertions.assertEquals(DeploymentSafeguardsLevel.ENFORCE, response.properties().level()); + Assertions.assertEquals("ksqrglssai", response.properties().excludedNamespaces().get(0)); + Assertions.assertEquals(PodSecurityStandardsLevel.POD_SECURITY_STANDARDS_RESTRICTED, + response.properties().podSecurityStandardsLevel()); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsGetWithResponseMockTests.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsGetWithResponseMockTests.java new file mode 100644 index 000000000000..baf3826a2b8f --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsGetWithResponseMockTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.containerservicesafeguards.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.containerservicesafeguards.ContainerServiceSafeguardsManager; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguard; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsLevel; +import com.azure.resourcemanager.containerservicesafeguards.models.PodSecurityStandardsLevel; +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 DeploymentSafeguardsGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Failed\",\"level\":\"Warn\",\"excludedNamespaces\":[\"xjtfelluwfzit\",\"np\"],\"systemExcludedNamespaces\":[\"fpjkjlxofp\",\"vhpfxxypininmay\"],\"podSecurityStandardsLevel\":\"Baseline\"},\"eTag\":\"bkpodepooginuv\",\"id\":\"iheogna\",\"name\":\"xzxtheo\",\"type\":\"usivye\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + ContainerServiceSafeguardsManager manager = ContainerServiceSafeguardsManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + DeploymentSafeguard response + = manager.deploymentSafeguards().getWithResponse("f", com.azure.core.util.Context.NONE).getValue(); + + Assertions.assertEquals(DeploymentSafeguardsLevel.WARN, response.properties().level()); + Assertions.assertEquals("xjtfelluwfzit", response.properties().excludedNamespaces().get(0)); + Assertions.assertEquals(PodSecurityStandardsLevel.POD_SECURITY_STANDARDS_BASELINE, + response.properties().podSecurityStandardsLevel()); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsListMockTests.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsListMockTests.java new file mode 100644 index 000000000000..3fe72cff3dc3 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/DeploymentSafeguardsListMockTests.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.containerservicesafeguards.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.containerservicesafeguards.ContainerServiceSafeguardsManager; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguard; +import com.azure.resourcemanager.containerservicesafeguards.models.DeploymentSafeguardsLevel; +import com.azure.resourcemanager.containerservicesafeguards.models.PodSecurityStandardsLevel; +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 DeploymentSafeguardsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Updating\",\"level\":\"Enforce\",\"excludedNamespaces\":[\"ugjzzdatqxhocdge\",\"blgphuticn\",\"vkaozwyiftyhxhur\",\"k\"],\"systemExcludedNamespaces\":[\"yxolniwp\",\"cukjf\",\"giawx\"],\"podSecurityStandardsLevel\":\"Privileged\"},\"eTag\":\"plwckbas\",\"id\":\"pnddhsgcbacphejk\",\"name\":\"tynqgoul\",\"type\":\"ndlik\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + ContainerServiceSafeguardsManager manager = ContainerServiceSafeguardsManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response + = manager.deploymentSafeguards().list("je", com.azure.core.util.Context.NONE); + + Assertions.assertEquals(DeploymentSafeguardsLevel.ENFORCE, response.iterator().next().properties().level()); + Assertions.assertEquals("ugjzzdatqxhocdge", + response.iterator().next().properties().excludedNamespaces().get(0)); + Assertions.assertEquals(PodSecurityStandardsLevel.POD_SECURITY_STANDARDS_PRIVILEGED, + response.iterator().next().properties().podSecurityStandardsLevel()); + } +} diff --git a/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/OperationsListMockTests.java b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/generated/OperationsListMockTests.java new file mode 100644 index 000000000000..3d2f3d29994e --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/src/test/java/com/azure/resourcemanager/containerservicesafeguards/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.containerservicesafeguards.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.containerservicesafeguards.ContainerServiceSafeguardsManager; +import com.azure.resourcemanager.containerservicesafeguards.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\":\"paojakhmsbzjh\",\"isDataAction\":false,\"display\":{\"provider\":\"dphlxaolt\",\"resource\":\"trg\",\"operation\":\"bpf\",\"description\":\"s\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + ContainerServiceSafeguardsManager manager = ContainerServiceSafeguardsManager.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/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/tsp-location.yaml b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/tsp-location.yaml new file mode 100644 index 000000000000..552636b73992 --- /dev/null +++ b/sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/containerservice/DeploymentSafeguards.Management +commit: d98af308da690a9e62df88188b6563b0d588dafd +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/containerservicesafeguards/ci.yml b/sdk/containerservicesafeguards/ci.yml new file mode 100644 index 000000000000..cb113bac3174 --- /dev/null +++ b/sdk/containerservicesafeguards/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/containerservicesafeguards/ci.yml + - sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/ + exclude: + - sdk/containerservicesafeguards/pom.xml + - sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/containerservicesafeguards/ci.yml + - sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/ + exclude: + - sdk/containerservicesafeguards/pom.xml + - sdk/containerservicesafeguards/azure-resourcemanager-containerservicesafeguards/pom.xml + +parameters: + - name: release_azureresourcemanagercontainerservicesafeguards + displayName: azure-resourcemanager-containerservicesafeguards + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: containerservicesafeguards + Artifacts: + - name: azure-resourcemanager-containerservicesafeguards + groupId: com.azure.resourcemanager + safeName: azureresourcemanagercontainerservicesafeguards + releaseInBatch: ${{ parameters.release_azureresourcemanagercontainerservicesafeguards }} diff --git a/sdk/containerservicesafeguards/pom.xml b/sdk/containerservicesafeguards/pom.xml new file mode 100644 index 000000000000..b0993d26f86f --- /dev/null +++ b/sdk/containerservicesafeguards/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-containerservicesafeguards-service + pom + 1.0.0 + + + azure-resourcemanager-containerservicesafeguards + +