diff --git a/eng/versioning/external_dependencies.txt b/eng/versioning/external_dependencies.txt index 62906a566fee..464bc9b7cf1a 100644 --- a/eng/versioning/external_dependencies.txt +++ b/eng/versioning/external_dependencies.txt @@ -110,6 +110,7 @@ org.springframework.kafka:spring-kafka;2.5.7.RELEASE org.springframework.security:spring-security-config;5.3.5.RELEASE org.springframework.security:spring-security-core;5.3.5.RELEASE org.springframework.security:spring-security-oauth2-client;5.3.5.RELEASE +org.springframework.security:spring-security-oauth2-resource-server;5.3.5.RELEASE org.springframework.security:spring-security-oauth2-core;5.3.5.RELEASE org.springframework.security:spring-security-oauth2-jose;5.3.5.RELEASE org.springframework.security:spring-security-web;5.3.5.RELEASE diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index fa2e6238ee36..afd601c68c49 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -40,17 +40,22 @@ com.azure:azure-ai-anomalydetector;3.0.0-beta.1;3.0.0-beta.2 com.azure:azure-ai-formrecognizer;3.0.3;3.1.0-beta.2 com.azure:azure-ai-metricsadvisor;1.0.0-beta.2;1.0.0-beta.3 com.azure:azure-ai-textanalytics;5.0.1;5.1.0-beta.4 +com.azure:azure-analytics-synapse-accesscontrol;1.0.0-beta.1;1.0.0-beta.2 +com.azure:azure-analytics-synapse-artifacts;1.0.0-beta.1;1.0.0-beta.2 +com.azure:azure-analytics-synapse-spark;1.0.0-beta.1;1.0.0-beta.2 +com.azure:azure-analytics-synapse-managedprivateendpoints;1.0.0-beta.1;1.0.0-beta.1 +com.azure:azure-analytics-synapse-monitoring;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-communication-chat;1.0.0-beta.3;1.0.0-beta.4 com.azure:azure-communication-common;1.0.0-beta.3;1.0.0-beta.4 com.azure:azure-communication-administration;1.0.0-beta.3;1.0.0-beta.4 com.azure:azure-communication-sms;1.0.0-beta.3;1.0.0-beta.4 -com.azure:azure-core;1.10.0;1.11.0 -com.azure:azure-core-amqp;1.6.0;1.7.0-beta.3 +com.azure:azure-core;1.11.0;1.12.0-beta.1 +com.azure:azure-core-amqp;2.0.0;2.1.0-beta.1 com.azure:azure-core-amqp-experimental;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-core-experimental;1.0.0-beta.8;1.0.0-beta.9 com.azure:azure-core-http-jdk-httpclient;1.0.0-beta.1;1.0.0-beta.1 -com.azure:azure-core-http-netty;1.6.3;1.7.0 -com.azure:azure-core-http-okhttp;1.3.3;1.4.0 +com.azure:azure-core-http-netty;1.7.0;1.8.0-beta.1 +com.azure:azure-core-http-okhttp;1.4.0;1.5.0-beta.1 com.azure:azure-core-management;1.0.0;1.1.0-beta.1 com.azure:azure-core-serializer-avro-apache;1.0.0-beta.5;1.0.0-beta.6 com.azure:azure-core-serializer-avro-jackson;1.0.0-beta.1;1.0.0-beta.2 @@ -58,7 +63,7 @@ com.azure:azure-core-serializer-json-gson;1.0.3;1.1.0-beta.1 com.azure:azure-core-serializer-json-jackson;1.1.0;1.2.0-beta.1 com.azure:azure-core-test;1.5.1;1.6.0-beta.1 com.azure:azure-core-tracing-opentelemetry;1.0.0-beta.6;1.0.0-beta.7 -com.azure:azure-cosmos;4.8.0;4.9.0-beta.1 +com.azure:azure-cosmos;4.9.0;4.10.0 com.azure:azure-cosmos-benchmark;4.0.1-beta.1;4.0.1-beta.1 com.azure:azure-cosmos-dotnet-benchmark;4.0.1-beta.1;4.0.1-beta.1 com.azure:azure-cosmos-encryption;1.0.0-beta.1;1.0.0-beta.1 @@ -68,12 +73,12 @@ com.azure:azure-data-schemaregistry-avro;1.0.0-beta.4;1.0.0-beta.5 com.azure:azure-data-tables;12.0.0-beta.3;12.0.0-beta.4 com.azure:azure-digitaltwins-core;1.0.1;1.1.0-beta.1 com.azure:azure-e2e;1.0.0-beta.1;1.0.0-beta.1 -com.azure:azure-identity;1.2.0;1.3.0-beta.1 +com.azure:azure-identity;1.2.0;1.2.1 com.azure:azure-identity-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-messaging-eventgrid;2.0.0-beta.3;2.0.0-beta.4 com.azure:azure-messaging-eventhubs;5.3.1;5.4.0-beta.2 com.azure:azure-messaging-eventhubs-checkpointstore-blob;1.3.1;1.4.0-beta.2 -com.azure:azure-messaging-servicebus;7.0.0-beta.7;7.0.0-beta.8 +com.azure:azure-messaging-servicebus;7.0.0;7.1.0-beta.1 com.azure:azure-messaging-servicebus-track1-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-messaging-servicebus-track2-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-search-documents;11.1.2;11.2.0-beta.4 @@ -84,19 +89,19 @@ com.azure:azure-security-keyvault-jca;1.0.0-beta.2;1.0.0-beta.3 com.azure:azure-security-keyvault-keys;4.2.3;4.3.0-beta.4 com.azure:azure-security-keyvault-secrets;4.2.3;4.3.0-beta.3 com.azure:azure-sdk-template;1.2.1-beta.2;1.2.1-beta.16 -com.azure:azure-spring-data-cosmos;3.1.0;3.2.0-beta.1 +com.azure:azure-spring-data-cosmos;3.2.0;3.3.0-beta.1 com.azure:azure-spring-data-cosmos-test;3.0.0-beta.1;3.0.0-beta.1 -com.azure:azure-storage-blob;12.9.0;12.10.0-beta.1 -com.azure:azure-storage-blob-batch;12.7.0;12.8.0-beta.1 +com.azure:azure-storage-blob;12.9.0;12.10.0-beta.2 +com.azure:azure-storage-blob-batch;12.7.0;12.8.0-beta.2 com.azure:azure-storage-blob-changefeed;12.0.0-beta.4;12.0.0-beta.5 -com.azure:azure-storage-blob-cryptography;12.9.0;12.10.0-beta.1 +com.azure:azure-storage-blob-cryptography;12.9.0;12.10.0-beta.2 com.azure:azure-storage-blob-nio;12.0.0-beta.2;12.0.0-beta.3 -com.azure:azure-storage-common;12.9.0;12.10.0-beta.1 -com.azure:azure-storage-file-share;12.7.0;12.8.0-beta.1 -com.azure:azure-storage-file-datalake;12.3.0;12.4.0-beta.1 -com.azure:azure-storage-internal-avro;12.0.1;12.1.0-beta.1 +com.azure:azure-storage-common;12.9.0;12.10.0-beta.2 +com.azure:azure-storage-file-share;12.7.0;12.8.0-beta.2 +com.azure:azure-storage-file-datalake;12.3.0;12.4.0-beta.2 +com.azure:azure-storage-internal-avro;12.0.1;12.0.2-beta.2 com.azure:azure-storage-perf;1.0.0-beta.1;1.0.0-beta.1 -com.azure:azure-storage-queue;12.7.0;12.8.0-beta.1 +com.azure:azure-storage-queue;12.7.0;12.8.0-beta.2 com.azure:perf-test-core;1.0.0-beta.1;1.0.0-beta.1 com.azure.spring:azure-spring-boot-starter-active-directory-b2c;3.0.0-beta.1;3.0.0-beta.2 com.azure.spring:azure-spring-boot-starter-active-directory;3.0.0-beta.1;3.0.0-beta.2 @@ -168,6 +173,7 @@ com.azure.resourcemanager:azure-resourcemanager-sql;2.1.0;2.2.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-storage;2.1.0;2.2.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-trafficmanager;2.1.0;2.2.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-test;2.0.0-beta.1;2.0.0-beta.1 +com.azure.resourcemanager:azure-resourcemanager-advisor;1.0.0-beta.1;1.0.0-beta.1 com.microsoft:microsoft-opentelemetry-exporter-azuremonitor;1.0.0-beta.1;1.0.0-beta.2 @@ -176,9 +182,7 @@ com.microsoft:microsoft-opentelemetry-exporter-azuremonitor;1.0.0-beta.1;1.0.0-b # Format; # unreleased_:;dependency-version # note: The unreleased dependencies will not be manipulated with the automatic PR creation code. -unreleased_com.azure:azure-core;1.11.0 -unreleased_com.azure:azure-core-amqp;1.7.0-beta.3 -unreleased_com.azure:azure-messaging-servicebus;7.0.0-beta.7 +unreleased_com.azure:azure-messaging-servicebus;7.0.0 # Released Beta dependencies: Copy the entry from above, prepend "beta_", remove the current # version and set the version to the released beta. Released beta dependencies are only valid @@ -188,4 +192,3 @@ unreleased_com.azure:azure-messaging-servicebus;7.0.0-beta.7 # beta_:;dependency-version # note: Released beta versions will not be manipulated with the automatic PR creation code. beta_com.azure:azure-security-keyvault-keys;4.3.0-beta.1 -beta_com.azure:azure-core-amqp;1.7.0-beta.2 diff --git a/eng/versioning/version_data.txt b/eng/versioning/version_data.txt index 61c6a98825df..da53965c2792 100644 --- a/eng/versioning/version_data.txt +++ b/eng/versioning/version_data.txt @@ -34,7 +34,7 @@ com.microsoft.azure:azure-keyvault-cryptography;1.2.4;1.3.0-beta.1 com.microsoft.azure:azure-keyvault-extensions;1.2.4;1.3.0-beta.1 com.microsoft.azure:azure-keyvault-test;1.2.3;1.2.4 com.microsoft.azure:azure-keyvault-webkey;1.2.4;1.3.0-beta.1 -com.microsoft.azure:azure-servicebus;3.5.0;3.5.1 +com.microsoft.azure:azure-servicebus;3.5.1;3.6.0-beta.1 com.microsoft.azure:azure-storage-blob;11.0.2;11.0.2 com.microsoft.azure.msi_auth_token_provider:azure-authentication-msi-token-provider;1.1.0-beta.1;1.1.0-beta.1 com.microsoft.azure:azure-eventgrid;1.4.0-beta.1;1.4.0-beta.1 diff --git a/pom.xml b/pom.xml index d97614e5dba3..61330f393443 100644 --- a/pom.xml +++ b/pom.xml @@ -9,17 +9,18 @@ 1.0.0 common/perf-test-core - eng/jacoco-test-coverage eng/code-quality-reports + eng/jacoco-test-coverage + sdk/advisor sdk/anomalydetector sdk/appconfiguration sdk/authorization sdk/batch sdk/boms - sdk/core - sdk/cosmos sdk/cognitiveservices sdk/communication + sdk/core + sdk/cosmos sdk/digitaltwins sdk/eventgrid sdk/eventhubs @@ -28,16 +29,17 @@ sdk/keyvault sdk/loganalytics sdk/mediaservices - sdk/monitor sdk/metricsadvisor + sdk/monitor sdk/resourcemanager sdk/schemaregistry sdk/search sdk/servicebus + sdk/spring sdk/storage + sdk/synapse sdk/tables sdk/template sdk/textanalytics - sdk/spring diff --git a/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md b/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md new file mode 100644 index 000000000000..5ad9ae0c271c --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2020-12-15) + +- Azure Resource Manager Advisor client library for Java. This package contains Microsoft Azure SDK for Advisor Management SDK. REST APIs for Azure Advisor. Package tag package-2020-01. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). \ No newline at end of file diff --git a/sdk/advisor/azure-resourcemanager-advisor/README.md b/sdk/advisor/azure-resourcemanager-advisor/README.md new file mode 100644 index 000000000000..7039ea556dbe --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/README.md @@ -0,0 +1,84 @@ +# Azure Resource Manager Advisor client library for Java + +Azure Resource Manager Advisor client library for Java. + +This package contains Microsoft Azure SDK for Advisor Management SDK. REST APIs for Azure Advisor. Package tag package-2020-01. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +```xml + + com.azure.resourcemanager + azure-resourcemanager-advisor + 1.0.0-beta.1 + +``` + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation. + +### Authentication + +By default, Azure Active Directory token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, `azure` client can be authenticated by following code: + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-advisor;current}) +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +AdvisorManager manager = AdvisorManager + .authenticate(credential, profile); +``` +[//]: # ({x-version-update-end}) + +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +## Troubleshooting + +## Next steps + +## Contributing + +If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft +Azure Projects Contribution Guidelines](http://azure.github.io/guidelines.html). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/identity/azure-identity +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/DESIGN.md diff --git a/sdk/advisor/azure-resourcemanager-advisor/pom.xml b/sdk/advisor/azure-resourcemanager-advisor/pom.xml new file mode 100644 index 000000000000..65f560cd19a7 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/pom.xml @@ -0,0 +1,62 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-advisor + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Advisor Management + This package contains Microsoft Azure SDK for Advisor Management SDK. REST APIs for Azure Advisor. Package tag package-2020-01. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt + 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 + + + + + com.azure + azure-core-management + 1.0.0 + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + true + + + + + diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/AdvisorManager.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/AdvisorManager.java new file mode 100644 index 000000000000..a59a3fcb0a6a --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/AdvisorManager.java @@ -0,0 +1,249 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor; + +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.policy.AddDatePolicy; +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.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.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.AdvisorManagementClient; +import com.azure.resourcemanager.advisor.implementation.AdvisorManagementClientBuilder; +import com.azure.resourcemanager.advisor.implementation.ConfigurationsImpl; +import com.azure.resourcemanager.advisor.implementation.OperationsImpl; +import com.azure.resourcemanager.advisor.implementation.RecommendationMetadatasImpl; +import com.azure.resourcemanager.advisor.implementation.RecommendationsImpl; +import com.azure.resourcemanager.advisor.implementation.SuppressionsImpl; +import com.azure.resourcemanager.advisor.models.Configurations; +import com.azure.resourcemanager.advisor.models.Operations; +import com.azure.resourcemanager.advisor.models.RecommendationMetadatas; +import com.azure.resourcemanager.advisor.models.Recommendations; +import com.azure.resourcemanager.advisor.models.Suppressions; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Entry point to AdvisorManager. REST APIs for Azure Advisor. */ +public final class AdvisorManager { + private RecommendationMetadatas recommendationMetadatas; + + private Configurations configurations; + + private Recommendations recommendations; + + private Operations operations; + + private Suppressions suppressions; + + private final AdvisorManagementClient clientObject; + + private AdvisorManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new AdvisorManagementClientBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Advisor service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Advisor service API instance. + */ + public static AdvisorManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Gets a Configurable instance that can be used to create AdvisorManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new AdvisorManager.Configurable(); + } + + /** The Configurable allowing configurations to be set. */ + public static final class Configurable { + private final ClientLogger logger = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private RetryPolicy retryPolicy; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = Objects.requireNonNull(defaultPollInterval, "'retryPolicy' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw logger.logExceptionAsError(new IllegalArgumentException("'httpPipeline' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Advisor service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Advisor service API instance. + */ + public AdvisorManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + if (retryPolicy == null) { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + List policies = new ArrayList<>(); + policies + .add( + new UserAgentPolicy( + null, + "com.azure.resourcemanager.advisor", + "1.0.0-beta.1", + Configuration.getGlobalConfiguration())); + policies.add(new RequestIdPolicy()); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies + .add( + new BearerTokenAuthenticationPolicy( + credential, profile.getEnvironment().getManagementEndpoint() + "/.default")); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new AdvisorManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of RecommendationMetadatas. */ + public RecommendationMetadatas recommendationMetadatas() { + if (this.recommendationMetadatas == null) { + this.recommendationMetadatas = + new RecommendationMetadatasImpl(clientObject.getRecommendationMetadatas(), this); + } + return recommendationMetadatas; + } + + /** @return Resource collection API of Configurations. */ + public Configurations configurations() { + if (this.configurations == null) { + this.configurations = new ConfigurationsImpl(clientObject.getConfigurations(), this); + } + return configurations; + } + + /** @return Resource collection API of Recommendations. */ + public Recommendations recommendations() { + if (this.recommendations == null) { + this.recommendations = new RecommendationsImpl(clientObject.getRecommendations(), this); + } + return recommendations; + } + + /** @return Resource collection API of Operations. */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** @return Resource collection API of Suppressions. */ + public Suppressions suppressions() { + if (this.suppressions == null) { + this.suppressions = new SuppressionsImpl(clientObject.getSuppressions(), this); + } + return suppressions; + } + + /** + * @return Wrapped service client AdvisorManagementClient providing direct access to the underlying auto-generated + * API implementation, based on Azure REST API. + */ + public AdvisorManagementClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/AdvisorManagementClient.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/AdvisorManagementClient.java new file mode 100644 index 000000000000..247423ce021c --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/AdvisorManagementClient.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for AdvisorManagementClient class. */ +public interface AdvisorManagementClient { + /** + * Gets The Azure subscription ID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the RecommendationMetadatasClient object to access its operations. + * + * @return the RecommendationMetadatasClient object. + */ + RecommendationMetadatasClient getRecommendationMetadatas(); + + /** + * Gets the ConfigurationsClient object to access its operations. + * + * @return the ConfigurationsClient object. + */ + ConfigurationsClient getConfigurations(); + + /** + * Gets the RecommendationsClient object to access its operations. + * + * @return the RecommendationsClient object. + */ + RecommendationsClient getRecommendations(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the SuppressionsClient object to access its operations. + * + * @return the SuppressionsClient object. + */ + SuppressionsClient getSuppressions(); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/ConfigurationsClient.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/ConfigurationsClient.java new file mode 100644 index 000000000000..2e0a44c091a5 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/ConfigurationsClient.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.util.Context; +import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; +import com.azure.resourcemanager.advisor.models.ConfigurationName; + +/** An instance of this class provides access to all the operations defined in ConfigurationsClient. */ +public interface ConfigurationsClient { + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ConfigDataInner createInSubscription(ConfigurationName configurationName, ConfigDataInner configContract); + + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createInSubscriptionWithResponse( + ConfigurationName configurationName, ConfigDataInner configContract, Context context); + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroup); + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroup, Context context); + + /** + * Create/Overwrite Azure Advisor configuration. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param resourceGroup The name of the Azure resource group. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ConfigDataInner createInResourceGroup( + ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract); + + /** + * Create/Overwrite Azure Advisor configuration. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param resourceGroup The name of the Azure resource group. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createInResourceGroupWithResponse( + ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract, Context context); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/OperationsClient.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/OperationsClient.java new file mode 100644 index 000000000000..2aba94427976 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/OperationsClient.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.fluent.models.OperationEntityInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * Lists all the available Advisor REST API operations. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Lists all the available Advisor REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/RecommendationMetadatasClient.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/RecommendationMetadatasClient.java new file mode 100644 index 000000000000..c3768f44b211 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/RecommendationMetadatasClient.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.util.Context; +import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; + +/** An instance of this class provides access to all the operations defined in RecommendationMetadatasClient. */ +public interface RecommendationMetadatasClient { + /** + * Gets the metadata entity. + * + * @param name Name of metadata entity. + * @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 metadata entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MetadataEntityInner get(String name); + + /** + * Gets the metadata entity. + * + * @param name Name of metadata entity. + * @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 metadata entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String name, Context context); + + /** + * Gets the list of metadata entities. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Gets the list of metadata entities. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/RecommendationsClient.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/RecommendationsClient.java new file mode 100644 index 000000000000..e3912f79523e --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/RecommendationsClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.util.Context; +import com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner; +import java.util.UUID; + +/** An instance of this class provides access to all the operations defined in RecommendationsClient. */ +public interface RecommendationsClient { + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @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 generate(); + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response generateWithResponse(Context context); + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the + * generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation + * response header. + * @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 getGenerateStatus(UUID operationId); + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the + * generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation + * response header. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getGenerateStatusWithResponse(UUID operationId, Context context); + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @param filter The filter to apply to the recommendations.<br>Filter can be applied to properties + * ['ResourceId', 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', + * 'and', 'or'].<br>Example:<br>- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup'. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String filter, Integer top, String skipToken, Context context); + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return advisor Recommendation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ResourceRecommendationBaseInner get(String resourceUri, String recommendationId); + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return advisor Recommendation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse( + String resourceUri, String recommendationId, Context context); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/SuppressionsClient.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/SuppressionsClient.java new file mode 100644 index 000000000000..896b4c039b67 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/SuppressionsClient.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.util.Context; +import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; + +/** An instance of this class provides access to all the operations defined in SuppressionsClient. */ +public interface SuppressionsClient { + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SuppressionContractInner get(String resourceUri, String recommendationId, String name); + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse( + String resourceUri, String recommendationId, String name, Context context); + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to + * as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The details of the snoozed or dismissed rule; for example, the duration, name, and + * GUID associated with the rule. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SuppressionContractInner create( + String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract); + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to + * as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The details of the snoozed or dismissed rule; for example, the duration, name, and + * GUID associated with the rule. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createWithResponse( + String resourceUri, + String recommendationId, + String name, + SuppressionContractInner suppressionContract, + Context context); + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a + * recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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, String recommendationId, String name); + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a + * recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceUri, String recommendationId, String name, Context context); + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @param top The number of suppressions per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Integer top, String skipToken, Context context); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ConfigDataInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ConfigDataInner.java new file mode 100644 index 000000000000..7c84cd0db0ac --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ConfigDataInner.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.JsonFlatten; +import com.azure.core.management.ProxyResource; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.models.CpuThreshold; +import com.azure.resourcemanager.advisor.models.DigestConfig; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The Advisor configuration data structure. */ +@JsonFlatten +@Fluent +public class ConfigDataInner extends ProxyResource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ConfigDataInner.class); + + /* + * Exclude the resource from Advisor evaluations. Valid values: False + * (default) or True. + */ + @JsonProperty(value = "properties.exclude") + private Boolean exclude; + + /* + * Minimum percentage threshold for Advisor low CPU utilization evaluation. + * Valid only for subscriptions. Valid values: 5 (default), 10, 15 or 20. + */ + @JsonProperty(value = "properties.lowCpuThreshold") + private CpuThreshold lowCpuThreshold; + + /* + * Advisor digest configuration. Valid only for subscriptions + */ + @JsonProperty(value = "properties.digests") + private List digests; + + /** + * Get the exclude property: Exclude the resource from Advisor evaluations. Valid values: False (default) or True. + * + * @return the exclude value. + */ + public Boolean exclude() { + return this.exclude; + } + + /** + * Set the exclude property: Exclude the resource from Advisor evaluations. Valid values: False (default) or True. + * + * @param exclude the exclude value to set. + * @return the ConfigDataInner object itself. + */ + public ConfigDataInner withExclude(Boolean exclude) { + this.exclude = exclude; + return this; + } + + /** + * Get the lowCpuThreshold property: Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid + * only for subscriptions. Valid values: 5 (default), 10, 15 or 20. + * + * @return the lowCpuThreshold value. + */ + public CpuThreshold lowCpuThreshold() { + return this.lowCpuThreshold; + } + + /** + * Set the lowCpuThreshold property: Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid + * only for subscriptions. Valid values: 5 (default), 10, 15 or 20. + * + * @param lowCpuThreshold the lowCpuThreshold value to set. + * @return the ConfigDataInner object itself. + */ + public ConfigDataInner withLowCpuThreshold(CpuThreshold lowCpuThreshold) { + this.lowCpuThreshold = lowCpuThreshold; + return this; + } + + /** + * Get the digests property: Advisor digest configuration. Valid only for subscriptions. + * + * @return the digests value. + */ + public List digests() { + return this.digests; + } + + /** + * Set the digests property: Advisor digest configuration. Valid only for subscriptions. + * + * @param digests the digests value to set. + * @return the ConfigDataInner object itself. + */ + public ConfigDataInner withDigests(List digests) { + this.digests = digests; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (digests() != null) { + digests().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityInner.java new file mode 100644 index 000000000000..d3152dea8d5c --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityInner.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.JsonFlatten; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.models.MetadataSupportedValueDetail; +import com.azure.resourcemanager.advisor.models.Scenario; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The metadata entity contract. */ +@JsonFlatten +@Fluent +public class MetadataEntityInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(MetadataEntityInner.class); + + /* + * The resource Id of the metadata entity. + */ + @JsonProperty(value = "id") + private String id; + + /* + * The type of the metadata entity. + */ + @JsonProperty(value = "type") + private String type; + + /* + * The name of the metadata entity. + */ + @JsonProperty(value = "name") + private String name; + + /* + * The display name. + */ + @JsonProperty(value = "properties.displayName") + private String displayName; + + /* + * The list of keys on which this entity depends on. + */ + @JsonProperty(value = "properties.dependsOn") + private List dependsOn; + + /* + * The list of scenarios applicable to this metadata entity. + */ + @JsonProperty(value = "properties.applicableScenarios") + private List applicableScenarios; + + /* + * The list of supported values. + */ + @JsonProperty(value = "properties.supportedValues") + private List supportedValues; + + /** + * Get the id property: The resource Id of the metadata entity. + * + * @return the id value. + */ + public String id() { + return this.id; + } + + /** + * Set the id property: The resource Id of the metadata entity. + * + * @param id the id value to set. + * @return the MetadataEntityInner object itself. + */ + public MetadataEntityInner withId(String id) { + this.id = id; + return this; + } + + /** + * Get the type property: The type of the metadata entity. + * + * @return the type value. + */ + public String type() { + return this.type; + } + + /** + * Set the type property: The type of the metadata entity. + * + * @param type the type value to set. + * @return the MetadataEntityInner object itself. + */ + public MetadataEntityInner withType(String type) { + this.type = type; + return this; + } + + /** + * Get the name property: The name of the metadata entity. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the metadata entity. + * + * @param name the name value to set. + * @return the MetadataEntityInner object itself. + */ + public MetadataEntityInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the displayName property: The display name. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: The display name. + * + * @param displayName the displayName value to set. + * @return the MetadataEntityInner object itself. + */ + public MetadataEntityInner withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the dependsOn property: The list of keys on which this entity depends on. + * + * @return the dependsOn value. + */ + public List dependsOn() { + return this.dependsOn; + } + + /** + * Set the dependsOn property: The list of keys on which this entity depends on. + * + * @param dependsOn the dependsOn value to set. + * @return the MetadataEntityInner object itself. + */ + public MetadataEntityInner withDependsOn(List dependsOn) { + this.dependsOn = dependsOn; + return this; + } + + /** + * Get the applicableScenarios property: The list of scenarios applicable to this metadata entity. + * + * @return the applicableScenarios value. + */ + public List applicableScenarios() { + return this.applicableScenarios; + } + + /** + * Set the applicableScenarios property: The list of scenarios applicable to this metadata entity. + * + * @param applicableScenarios the applicableScenarios value to set. + * @return the MetadataEntityInner object itself. + */ + public MetadataEntityInner withApplicableScenarios(List applicableScenarios) { + this.applicableScenarios = applicableScenarios; + return this; + } + + /** + * Get the supportedValues property: The list of supported values. + * + * @return the supportedValues value. + */ + public List supportedValues() { + return this.supportedValues; + } + + /** + * Set the supportedValues property: The list of supported values. + * + * @param supportedValues the supportedValues value to set. + * @return the MetadataEntityInner object itself. + */ + public MetadataEntityInner withSupportedValues(List supportedValues) { + this.supportedValues = supportedValues; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (supportedValues() != null) { + supportedValues().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/OperationEntityInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/OperationEntityInner.java new file mode 100644 index 000000000000..ce36a73f631d --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/OperationEntityInner.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.models.OperationDisplayInfo; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The operation supported by Advisor. */ +@Fluent +public final class OperationEntityInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationEntityInner.class); + + /* + * Operation name: {provider}/{resource}/{operation}. + */ + @JsonProperty(value = "name") + private String name; + + /* + * The operation supported by Advisor. + */ + @JsonProperty(value = "display") + private OperationDisplayInfo display; + + /** + * Get the name property: Operation name: {provider}/{resource}/{operation}. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Operation name: {provider}/{resource}/{operation}. + * + * @param name the name value to set. + * @return the OperationEntityInner object itself. + */ + public OperationEntityInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the display property: The operation supported by Advisor. + * + * @return the display value. + */ + public OperationDisplayInfo display() { + return this.display; + } + + /** + * Set the display property: The operation supported by Advisor. + * + * @param display the display value to set. + * @return the OperationEntityInner object itself. + */ + public OperationEntityInner withDisplay(OperationDisplayInfo display) { + this.display = display; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ResourceRecommendationBaseInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ResourceRecommendationBaseInner.java new file mode 100644 index 000000000000..90e9b8216dd3 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ResourceRecommendationBaseInner.java @@ -0,0 +1,355 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.JsonFlatten; +import com.azure.core.management.ProxyResource; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.models.Category; +import com.azure.resourcemanager.advisor.models.Impact; +import com.azure.resourcemanager.advisor.models.ResourceMetadata; +import com.azure.resourcemanager.advisor.models.Risk; +import com.azure.resourcemanager.advisor.models.ShortDescription; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** Advisor Recommendation. */ +@JsonFlatten +@Fluent +public class ResourceRecommendationBaseInner extends ProxyResource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceRecommendationBaseInner.class); + + /* + * The category of the recommendation. + */ + @JsonProperty(value = "properties.category") + private Category category; + + /* + * The business impact of the recommendation. + */ + @JsonProperty(value = "properties.impact") + private Impact impact; + + /* + * The resource type identified by Advisor. + */ + @JsonProperty(value = "properties.impactedField") + private String impactedField; + + /* + * The resource identified by Advisor. + */ + @JsonProperty(value = "properties.impactedValue") + private String impactedValue; + + /* + * The most recent time that Advisor checked the validity of the + * recommendation. + */ + @JsonProperty(value = "properties.lastUpdated") + private OffsetDateTime lastUpdated; + + /* + * The recommendation metadata. + */ + @JsonProperty(value = "properties.metadata") + private Map metadata; + + /* + * The recommendation-type GUID. + */ + @JsonProperty(value = "properties.recommendationTypeId") + private String recommendationTypeId; + + /* + * The potential risk of not implementing the recommendation. + */ + @JsonProperty(value = "properties.risk") + private Risk risk; + + /* + * A summary of the recommendation. + */ + @JsonProperty(value = "properties.shortDescription") + private ShortDescription shortDescription; + + /* + * The list of snoozed and dismissed rules for the recommendation. + */ + @JsonProperty(value = "properties.suppressionIds") + private List suppressionIds; + + /* + * Extended properties + */ + @JsonProperty(value = "properties.extendedProperties") + private Map extendedProperties; + + /* + * Metadata of resource that was assessed + */ + @JsonProperty(value = "properties.resourceMetadata") + private ResourceMetadata resourceMetadata; + + /** + * Get the category property: The category of the recommendation. + * + * @return the category value. + */ + public Category category() { + return this.category; + } + + /** + * Set the category property: The category of the recommendation. + * + * @param category the category value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withCategory(Category category) { + this.category = category; + return this; + } + + /** + * Get the impact property: The business impact of the recommendation. + * + * @return the impact value. + */ + public Impact impact() { + return this.impact; + } + + /** + * Set the impact property: The business impact of the recommendation. + * + * @param impact the impact value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withImpact(Impact impact) { + this.impact = impact; + return this; + } + + /** + * Get the impactedField property: The resource type identified by Advisor. + * + * @return the impactedField value. + */ + public String impactedField() { + return this.impactedField; + } + + /** + * Set the impactedField property: The resource type identified by Advisor. + * + * @param impactedField the impactedField value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withImpactedField(String impactedField) { + this.impactedField = impactedField; + return this; + } + + /** + * Get the impactedValue property: The resource identified by Advisor. + * + * @return the impactedValue value. + */ + public String impactedValue() { + return this.impactedValue; + } + + /** + * Set the impactedValue property: The resource identified by Advisor. + * + * @param impactedValue the impactedValue value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withImpactedValue(String impactedValue) { + this.impactedValue = impactedValue; + return this; + } + + /** + * Get the lastUpdated property: The most recent time that Advisor checked the validity of the recommendation. + * + * @return the lastUpdated value. + */ + public OffsetDateTime lastUpdated() { + return this.lastUpdated; + } + + /** + * Set the lastUpdated property: The most recent time that Advisor checked the validity of the recommendation. + * + * @param lastUpdated the lastUpdated value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withLastUpdated(OffsetDateTime lastUpdated) { + this.lastUpdated = lastUpdated; + return this; + } + + /** + * Get the metadata property: The recommendation metadata. + * + * @return the metadata value. + */ + public Map metadata() { + return this.metadata; + } + + /** + * Set the metadata property: The recommendation metadata. + * + * @param metadata the metadata value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Get the recommendationTypeId property: The recommendation-type GUID. + * + * @return the recommendationTypeId value. + */ + public String recommendationTypeId() { + return this.recommendationTypeId; + } + + /** + * Set the recommendationTypeId property: The recommendation-type GUID. + * + * @param recommendationTypeId the recommendationTypeId value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withRecommendationTypeId(String recommendationTypeId) { + this.recommendationTypeId = recommendationTypeId; + return this; + } + + /** + * Get the risk property: The potential risk of not implementing the recommendation. + * + * @return the risk value. + */ + public Risk risk() { + return this.risk; + } + + /** + * Set the risk property: The potential risk of not implementing the recommendation. + * + * @param risk the risk value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withRisk(Risk risk) { + this.risk = risk; + return this; + } + + /** + * Get the shortDescription property: A summary of the recommendation. + * + * @return the shortDescription value. + */ + public ShortDescription shortDescription() { + return this.shortDescription; + } + + /** + * Set the shortDescription property: A summary of the recommendation. + * + * @param shortDescription the shortDescription value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withShortDescription(ShortDescription shortDescription) { + this.shortDescription = shortDescription; + return this; + } + + /** + * Get the suppressionIds property: The list of snoozed and dismissed rules for the recommendation. + * + * @return the suppressionIds value. + */ + public List suppressionIds() { + return this.suppressionIds; + } + + /** + * Set the suppressionIds property: The list of snoozed and dismissed rules for the recommendation. + * + * @param suppressionIds the suppressionIds value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withSuppressionIds(List suppressionIds) { + this.suppressionIds = suppressionIds; + return this; + } + + /** + * Get the extendedProperties property: Extended properties. + * + * @return the extendedProperties value. + */ + public Map extendedProperties() { + return this.extendedProperties; + } + + /** + * Set the extendedProperties property: Extended properties. + * + * @param extendedProperties the extendedProperties value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withExtendedProperties(Map extendedProperties) { + this.extendedProperties = extendedProperties; + return this; + } + + /** + * Get the resourceMetadata property: Metadata of resource that was assessed. + * + * @return the resourceMetadata value. + */ + public ResourceMetadata resourceMetadata() { + return this.resourceMetadata; + } + + /** + * Set the resourceMetadata property: Metadata of resource that was assessed. + * + * @param resourceMetadata the resourceMetadata value to set. + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withResourceMetadata(ResourceMetadata resourceMetadata) { + this.resourceMetadata = resourceMetadata; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (shortDescription() != null) { + shortDescription().validate(); + } + if (resourceMetadata() != null) { + resourceMetadata().validate(); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionContractInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionContractInner.java new file mode 100644 index 000000000000..5c3af5862bff --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionContractInner.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.JsonFlatten; +import com.azure.core.management.ProxyResource; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** The details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with the rule. */ +@JsonFlatten +@Fluent +public class SuppressionContractInner extends ProxyResource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(SuppressionContractInner.class); + + /* + * The GUID of the suppression. + */ + @JsonProperty(value = "properties.suppressionId") + private String suppressionId; + + /* + * The duration for which the suppression is valid. + */ + @JsonProperty(value = "properties.ttl") + private String ttl; + + /* + * Gets or sets the expiration time stamp. + */ + @JsonProperty(value = "properties.expirationTimeStamp", access = JsonProperty.Access.WRITE_ONLY) + private OffsetDateTime expirationTimestamp; + + /** + * Get the suppressionId property: The GUID of the suppression. + * + * @return the suppressionId value. + */ + public String suppressionId() { + return this.suppressionId; + } + + /** + * Set the suppressionId property: The GUID of the suppression. + * + * @param suppressionId the suppressionId value to set. + * @return the SuppressionContractInner object itself. + */ + public SuppressionContractInner withSuppressionId(String suppressionId) { + this.suppressionId = suppressionId; + return this; + } + + /** + * Get the ttl property: The duration for which the suppression is valid. + * + * @return the ttl value. + */ + public String ttl() { + return this.ttl; + } + + /** + * Set the ttl property: The duration for which the suppression is valid. + * + * @param ttl the ttl value to set. + * @return the SuppressionContractInner object itself. + */ + public SuppressionContractInner withTtl(String ttl) { + this.ttl = ttl; + return this; + } + + /** + * Get the expirationTimestamp property: Gets or sets the expiration time stamp. + * + * @return the expirationTimestamp value. + */ + public OffsetDateTime expirationTimestamp() { + return this.expirationTimestamp; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/package-info.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/package-info.java new file mode 100644 index 000000000000..50a514da695c --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the inner data models for AdvisorManagementClient. REST APIs for Azure Advisor. */ +package com.azure.resourcemanager.advisor.fluent.models; diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/package-info.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/package-info.java new file mode 100644 index 000000000000..0394bf92594a --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the service clients for AdvisorManagementClient. REST APIs for Azure Advisor. */ +package com.azure.resourcemanager.advisor.fluent; diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorManagementClientBuilder.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorManagementClientBuilder.java new file mode 100644 index 000000000000..9671cc13625c --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorManagementClientBuilder.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** A builder for creating a new instance of the AdvisorManagementClientImpl type. */ +@ServiceClientBuilder(serviceClients = {AdvisorManagementClientImpl.class}) +public final class AdvisorManagementClientBuilder { + /* + * The Azure subscription ID. + */ + private String subscriptionId; + + /** + * Sets The Azure subscription ID. + * + * @param subscriptionId the subscriptionId value. + * @return the AdvisorManagementClientBuilder. + */ + public AdvisorManagementClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the AdvisorManagementClientBuilder. + */ + public AdvisorManagementClientBuilder 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 AdvisorManagementClientBuilder. + */ + public AdvisorManagementClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the AdvisorManagementClientBuilder. + */ + public AdvisorManagementClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the AdvisorManagementClientBuilder. + */ + public AdvisorManagementClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the AdvisorManagementClientBuilder. + */ + public AdvisorManagementClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of AdvisorManagementClientImpl with the provided parameters. + * + * @return an instance of AdvisorManagementClientImpl. + */ + public AdvisorManagementClientImpl buildClient() { + if (endpoint == null) { + this.endpoint = "https://management.azure.com"; + } + if (environment == null) { + this.environment = AzureEnvironment.AZURE; + } + if (defaultPollInterval == null) { + this.defaultPollInterval = Duration.ofSeconds(30); + } + if (pipeline == null) { + this.pipeline = + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(); + } + if (serializerAdapter == null) { + this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter(); + } + AdvisorManagementClientImpl client = + new AdvisorManagementClientImpl( + pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint); + return client; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorManagementClientImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorManagementClientImpl.java new file mode 100644 index 000000000000..a391d51f4e9a --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorManagementClientImpl.java @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.advisor.fluent.AdvisorManagementClient; +import com.azure.resourcemanager.advisor.fluent.ConfigurationsClient; +import com.azure.resourcemanager.advisor.fluent.OperationsClient; +import com.azure.resourcemanager.advisor.fluent.RecommendationMetadatasClient; +import com.azure.resourcemanager.advisor.fluent.RecommendationsClient; +import com.azure.resourcemanager.advisor.fluent.SuppressionsClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.Map; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the AdvisorManagementClientImpl type. */ +@ServiceClient(builder = AdvisorManagementClientBuilder.class) +public final class AdvisorManagementClientImpl implements AdvisorManagementClient { + private final ClientLogger logger = new ClientLogger(AdvisorManagementClientImpl.class); + + /** The Azure subscription ID. */ + private final String subscriptionId; + + /** + * Gets The Azure subscription ID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** server parameter. */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Api Version. */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** The default poll interval for long-running operation. */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** The RecommendationMetadatasClient object to access its operations. */ + private final RecommendationMetadatasClient recommendationMetadatas; + + /** + * Gets the RecommendationMetadatasClient object to access its operations. + * + * @return the RecommendationMetadatasClient object. + */ + public RecommendationMetadatasClient getRecommendationMetadatas() { + return this.recommendationMetadatas; + } + + /** The ConfigurationsClient object to access its operations. */ + private final ConfigurationsClient configurations; + + /** + * Gets the ConfigurationsClient object to access its operations. + * + * @return the ConfigurationsClient object. + */ + public ConfigurationsClient getConfigurations() { + return this.configurations; + } + + /** The RecommendationsClient object to access its operations. */ + private final RecommendationsClient recommendations; + + /** + * Gets the RecommendationsClient object to access its operations. + * + * @return the RecommendationsClient object. + */ + public RecommendationsClient getRecommendations() { + return this.recommendations; + } + + /** 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 SuppressionsClient object to access its operations. */ + private final SuppressionsClient suppressions; + + /** + * Gets the SuppressionsClient object to access its operations. + * + * @return the SuppressionsClient object. + */ + public SuppressionsClient getSuppressions() { + return this.suppressions; + } + + /** + * Initializes an instance of AdvisorManagementClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param subscriptionId The Azure subscription ID. + * @param endpoint server parameter. + */ + AdvisorManagementClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + Duration defaultPollInterval, + AzureEnvironment environment, + String subscriptionId, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + this.apiVersion = "2020-01-01"; + this.recommendationMetadatas = new RecommendationMetadatasClientImpl(this); + this.configurations = new ConfigurationsClientImpl(this); + this.recommendations = new RecommendationsClientImpl(this); + this.operations = new OperationsClientImpl(this); + this.suppressions = new SuppressionsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + for (Map.Entry entry : this.getContext().getValues().entrySet()) { + context = context.addData(entry.getKey(), entry.getValue()); + } + return context; + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult( + Mono>> activationResponse, + HttpPipeline httpPipeline, + Type pollResultType, + Type finalResultType, + Context context) { + return PollerFactory + .create( + serializerAdapter, + httpPipeline, + pollResultType, + finalResultType, + defaultPollInterval, + activationResponse, + context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = + new HttpResponseImpl( + lroError.getResponseStatusCode(), lroError.getResponseHeaders(), lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = + this + .getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException 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.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(s); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ConfigDataImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ConfigDataImpl.java new file mode 100644 index 000000000000..94cc3b7ffef0 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ConfigDataImpl.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; +import com.azure.resourcemanager.advisor.models.ConfigData; +import com.azure.resourcemanager.advisor.models.ConfigurationName; +import com.azure.resourcemanager.advisor.models.CpuThreshold; +import com.azure.resourcemanager.advisor.models.DigestConfig; +import java.util.Collections; +import java.util.List; + +public final class ConfigDataImpl implements ConfigData, ConfigData.Definition { + private ConfigDataInner innerObject; + + private final AdvisorManager serviceManager; + + public ConfigDataImpl(ConfigDataInner innerObject, AdvisorManager 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 Boolean exclude() { + return this.innerModel().exclude(); + } + + public CpuThreshold lowCpuThreshold() { + return this.innerModel().lowCpuThreshold(); + } + + public List digests() { + List inner = this.innerModel().digests(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public ConfigDataInner innerModel() { + return this.innerObject; + } + + private AdvisorManager manager() { + return this.serviceManager; + } + + private ConfigurationName configurationName; + + private String resourceGroup; + + public ConfigDataImpl withExistingResourceGroup(String resourceGroup) { + this.resourceGroup = resourceGroup; + return this; + } + + public ConfigData create() { + this.innerObject = + serviceManager + .serviceClient() + .getConfigurations() + .createInResourceGroupWithResponse(configurationName, resourceGroup, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public ConfigData create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getConfigurations() + .createInResourceGroupWithResponse(configurationName, resourceGroup, this.innerModel(), context) + .getValue(); + return this; + } + + public ConfigDataImpl(ConfigurationName name, AdvisorManager serviceManager) { + this.innerObject = new ConfigDataInner(); + this.serviceManager = serviceManager; + this.configurationName = name; + } + + public ConfigDataImpl withExclude(Boolean exclude) { + this.innerModel().withExclude(exclude); + return this; + } + + public ConfigDataImpl withLowCpuThreshold(CpuThreshold lowCpuThreshold) { + this.innerModel().withLowCpuThreshold(lowCpuThreshold); + return this; + } + + public ConfigDataImpl withDigests(List digests) { + this.innerModel().withDigests(digests); + return this; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ConfigurationsClientImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ConfigurationsClientImpl.java new file mode 100644 index 000000000000..499084783f0f --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ConfigurationsClientImpl.java @@ -0,0 +1,812 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.core.annotation.BodyParam; +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.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.ConfigurationsClient; +import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; +import com.azure.resourcemanager.advisor.models.ConfigurationListResult; +import com.azure.resourcemanager.advisor.models.ConfigurationName; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in ConfigurationsClient. */ +public final class ConfigurationsClientImpl implements ConfigurationsClient { + private final ClientLogger logger = new ClientLogger(ConfigurationsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final ConfigurationsService service; + + /** The service client containing this operation class. */ + private final AdvisorManagementClientImpl client; + + /** + * Initializes an instance of ConfigurationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ConfigurationsClientImpl(AdvisorManagementClientImpl client) { + this.service = + RestProxy.create(ConfigurationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdvisorManagementClientConfigurations to be used by the proxy service + * to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AdvisorManagementCli") + private interface ConfigurationsService { + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations/{configurationName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createInSubscription( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("configurationName") ConfigurationName configurationName, + @BodyParam("application/json") ConfigDataInner configContract, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroup") String resourceGroup, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations" + + "/{configurationName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createInResourceGroup( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("configurationName") ConfigurationName configurationName, + @PathParam("resourceGroup") String resourceGroup, + @BodyParam("application/json") ConfigDataInner configContract, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .list( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + accept, + context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>( + () -> listSinglePageAsync(), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createInSubscriptionWithResponseAsync( + ConfigurationName configurationName, ConfigDataInner configContract) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (configurationName == null) { + return Mono + .error(new IllegalArgumentException("Parameter configurationName is required and cannot be null.")); + } + if (configContract == null) { + return Mono.error(new IllegalArgumentException("Parameter configContract is required and cannot be null.")); + } else { + configContract.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createInSubscription( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + configurationName, + configContract, + accept, + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createInSubscriptionWithResponseAsync( + ConfigurationName configurationName, ConfigDataInner configContract, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (configurationName == null) { + return Mono + .error(new IllegalArgumentException("Parameter configurationName is required and cannot be null.")); + } + if (configContract == null) { + return Mono.error(new IllegalArgumentException("Parameter configContract is required and cannot be null.")); + } else { + configContract.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createInSubscription( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + configurationName, + configContract, + accept, + context); + } + + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createInSubscriptionAsync( + ConfigurationName configurationName, ConfigDataInner configContract) { + return createInSubscriptionWithResponseAsync(configurationName, configContract) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ConfigDataInner createInSubscription(ConfigurationName configurationName, ConfigDataInner configContract) { + return createInSubscriptionAsync(configurationName, configContract).block(); + } + + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createInSubscriptionWithResponse( + ConfigurationName configurationName, ConfigDataInner configContract, Context context) { + return createInSubscriptionWithResponseAsync(configurationName, configContract, context).block(); + } + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroup) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroup == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroup, + accept, + context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync( + String resourceGroup, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroup == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroup, + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null)); + } + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroup) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroup)); + } + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroup, Context context) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroup, context)); + } + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroup) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroup)); + } + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroup, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroup, context)); + } + + /** + * Create/Overwrite Azure Advisor configuration. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param resourceGroup The name of the Azure resource group. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createInResourceGroupWithResponseAsync( + ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (configurationName == null) { + return Mono + .error(new IllegalArgumentException("Parameter configurationName is required and cannot be null.")); + } + if (resourceGroup == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null.")); + } + if (configContract == null) { + return Mono.error(new IllegalArgumentException("Parameter configContract is required and cannot be null.")); + } else { + configContract.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createInResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + configurationName, + resourceGroup, + configContract, + accept, + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Create/Overwrite Azure Advisor configuration. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param resourceGroup The name of the Azure resource group. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createInResourceGroupWithResponseAsync( + ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (configurationName == null) { + return Mono + .error(new IllegalArgumentException("Parameter configurationName is required and cannot be null.")); + } + if (resourceGroup == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null.")); + } + if (configContract == null) { + return Mono.error(new IllegalArgumentException("Parameter configContract is required and cannot be null.")); + } else { + configContract.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createInResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + configurationName, + resourceGroup, + configContract, + accept, + context); + } + + /** + * Create/Overwrite Azure Advisor configuration. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param resourceGroup The name of the Azure resource group. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createInResourceGroupAsync( + ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract) { + return createInResourceGroupWithResponseAsync(configurationName, resourceGroup, configContract) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Create/Overwrite Azure Advisor configuration. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param resourceGroup The name of the Azure resource group. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ConfigDataInner createInResourceGroup( + ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract) { + return createInResourceGroupAsync(configurationName, resourceGroup, configContract).block(); + } + + /** + * Create/Overwrite Azure Advisor configuration. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param resourceGroup The name of the Azure resource group. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createInResourceGroupWithResponse( + ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract, Context context) { + return createInResourceGroupWithResponseAsync(configurationName, resourceGroup, configContract, context) + .block(); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync( + String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ConfigurationsImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ConfigurationsImpl.java new file mode 100644 index 000000000000..a1c29876b6d5 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ConfigurationsImpl.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.ConfigurationsClient; +import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; +import com.azure.resourcemanager.advisor.models.ConfigData; +import com.azure.resourcemanager.advisor.models.ConfigurationName; +import com.azure.resourcemanager.advisor.models.Configurations; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class ConfigurationsImpl implements Configurations { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ConfigurationsImpl.class); + + private final ConfigurationsClient innerClient; + + private final AdvisorManager serviceManager; + + public ConfigurationsImpl(ConfigurationsClient innerClient, AdvisorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return inner.mapPage(inner1 -> new ConfigDataImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return inner.mapPage(inner1 -> new ConfigDataImpl(inner1, this.manager())); + } + + public ConfigData createInSubscription(ConfigurationName configurationName, ConfigDataInner configContract) { + ConfigDataInner inner = this.serviceClient().createInSubscription(configurationName, configContract); + if (inner != null) { + return new ConfigDataImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response createInSubscriptionWithResponse( + ConfigurationName configurationName, ConfigDataInner configContract, Context context) { + Response inner = + this.serviceClient().createInSubscriptionWithResponse(configurationName, configContract, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ConfigDataImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public PagedIterable listByResourceGroup(String resourceGroup) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroup); + return inner.mapPage(inner1 -> new ConfigDataImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroup, Context context) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroup, context); + return inner.mapPage(inner1 -> new ConfigDataImpl(inner1, this.manager())); + } + + private ConfigurationsClient serviceClient() { + return this.innerClient; + } + + private AdvisorManager manager() { + return this.serviceManager; + } + + public ConfigDataImpl define(ConfigurationName name) { + return new ConfigDataImpl(name, this.manager()); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/MetadataEntityImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/MetadataEntityImpl.java new file mode 100644 index 000000000000..fbc58a4e1c03 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/MetadataEntityImpl.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.resourcemanager.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; +import com.azure.resourcemanager.advisor.models.MetadataEntity; +import com.azure.resourcemanager.advisor.models.MetadataSupportedValueDetail; +import com.azure.resourcemanager.advisor.models.Scenario; +import java.util.Collections; +import java.util.List; + +public final class MetadataEntityImpl implements MetadataEntity { + private MetadataEntityInner innerObject; + + private final AdvisorManager serviceManager; + + public MetadataEntityImpl(MetadataEntityInner innerObject, AdvisorManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String type() { + return this.innerModel().type(); + } + + public String name() { + return this.innerModel().name(); + } + + public String displayName() { + return this.innerModel().displayName(); + } + + public List dependsOn() { + List inner = this.innerModel().dependsOn(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List applicableScenarios() { + List inner = this.innerModel().applicableScenarios(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List supportedValues() { + List inner = this.innerModel().supportedValues(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public MetadataEntityInner innerModel() { + return this.innerObject; + } + + private AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/OperationEntityImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/OperationEntityImpl.java new file mode 100644 index 000000000000..cea6a50149c5 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/OperationEntityImpl.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.resourcemanager.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner; +import com.azure.resourcemanager.advisor.models.OperationDisplayInfo; +import com.azure.resourcemanager.advisor.models.OperationEntity; + +public final class OperationEntityImpl implements OperationEntity { + private OperationEntityInner innerObject; + + private final AdvisorManager serviceManager; + + public OperationEntityImpl(OperationEntityInner innerObject, AdvisorManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public OperationDisplayInfo display() { + return this.innerModel().display(); + } + + public OperationEntityInner innerModel() { + return this.innerObject; + } + + private AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/OperationsClientImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..8b983387ded8 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/OperationsClientImpl.java @@ -0,0 +1,269 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.fluent.OperationsClient; +import com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner; +import com.azure.resourcemanager.advisor.models.OperationEntityListResult; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public final class OperationsClientImpl implements OperationsClient { + private final ClientLogger logger = new ClientLogger(OperationsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final OperationsService service; + + /** The service client containing this operation class. */ + private final AdvisorManagementClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(AdvisorManagementClientImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdvisorManagementClientOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AdvisorManagementCli") + private interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.Advisor/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/OperationsImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/OperationsImpl.java new file mode 100644 index 000000000000..f4debe98e460 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/OperationsImpl.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.OperationsClient; +import com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner; +import com.azure.resourcemanager.advisor.models.OperationEntity; +import com.azure.resourcemanager.advisor.models.Operations; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class OperationsImpl implements Operations { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final AdvisorManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, AdvisorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return inner.mapPage(inner1 -> new OperationEntityImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return inner.mapPage(inner1 -> new OperationEntityImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationMetadatasClientImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationMetadatasClientImpl.java new file mode 100644 index 000000000000..19f06459e4f7 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationMetadatasClientImpl.java @@ -0,0 +1,385 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.fluent.RecommendationMetadatasClient; +import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; +import com.azure.resourcemanager.advisor.models.MetadataEntityListResult; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in RecommendationMetadatasClient. */ +public final class RecommendationMetadatasClientImpl implements RecommendationMetadatasClient { + private final ClientLogger logger = new ClientLogger(RecommendationMetadatasClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final RecommendationMetadatasService service; + + /** The service client containing this operation class. */ + private final AdvisorManagementClientImpl client; + + /** + * Initializes an instance of RecommendationMetadatasClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RecommendationMetadatasClientImpl(AdvisorManagementClientImpl client) { + this.service = + RestProxy + .create(RecommendationMetadatasService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdvisorManagementClientRecommendationMetadatas to be used by the + * proxy service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AdvisorManagementCli") + private interface RecommendationMetadatasService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.Advisor/metadata/{name}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get( + @HostParam("$host") String endpoint, + @PathParam("name") String name, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.Advisor/metadata") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Gets the metadata entity. + * + * @param name Name of metadata entity. + * @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 metadata entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String name) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.get(this.client.getEndpoint(), name, this.client.getApiVersion(), accept, context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Gets the metadata entity. + * + * @param name Name of metadata entity. + * @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 metadata entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String name, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), name, this.client.getApiVersion(), accept, context); + } + + /** + * Gets the metadata entity. + * + * @param name Name of metadata entity. + * @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 metadata entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String name) { + return getWithResponseAsync(name) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Gets the metadata entity. + * + * @param name Name of metadata entity. + * @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 metadata entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MetadataEntityInner get(String name) { + return getAsync(name).block(); + } + + /** + * Gets the metadata entity. + * + * @param name Name of metadata entity. + * @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 metadata entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, Context context) { + return getWithResponseAsync(name, context).block(); + } + + /** + * Gets the list of metadata entities. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @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)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Gets the list of metadata entities. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Gets the list of metadata entities. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Gets the list of metadata entities. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Gets the list of metadata entities. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Gets the list of metadata entities. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @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)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationMetadatasImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationMetadatasImpl.java new file mode 100644 index 000000000000..1accc5c133b6 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationMetadatasImpl.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.RecommendationMetadatasClient; +import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; +import com.azure.resourcemanager.advisor.models.MetadataEntity; +import com.azure.resourcemanager.advisor.models.RecommendationMetadatas; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class RecommendationMetadatasImpl implements RecommendationMetadatas { + @JsonIgnore private final ClientLogger logger = new ClientLogger(RecommendationMetadatasImpl.class); + + private final RecommendationMetadatasClient innerClient; + + private final AdvisorManager serviceManager; + + public RecommendationMetadatasImpl(RecommendationMetadatasClient innerClient, AdvisorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public MetadataEntity get(String name) { + MetadataEntityInner inner = this.serviceClient().get(name); + if (inner != null) { + return new MetadataEntityImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getWithResponse(String name, Context context) { + Response inner = this.serviceClient().getWithResponse(name, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new MetadataEntityImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return inner.mapPage(inner1 -> new MetadataEntityImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return inner.mapPage(inner1 -> new MetadataEntityImpl(inner1, this.manager())); + } + + private RecommendationMetadatasClient serviceClient() { + return this.innerClient; + } + + private AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationsClientImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationsClientImpl.java new file mode 100644 index 000000000000..803b570a326b --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationsClientImpl.java @@ -0,0 +1,765 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.Post; +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.advisor.fluent.RecommendationsClient; +import com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner; +import com.azure.resourcemanager.advisor.models.RecommendationsGenerateResponse; +import com.azure.resourcemanager.advisor.models.ResourceRecommendationBaseListResult; +import java.util.UUID; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in RecommendationsClient. */ +public final class RecommendationsClientImpl implements RecommendationsClient { + private final ClientLogger logger = new ClientLogger(RecommendationsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final RecommendationsService service; + + /** The service client containing this operation class. */ + private final AdvisorManagementClientImpl client; + + /** + * Initializes an instance of RecommendationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RecommendationsClientImpl(AdvisorManagementClientImpl client) { + this.service = + RestProxy.create(RecommendationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdvisorManagementClientRecommendations to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AdvisorManagementCli") + private interface RecommendationsService { + @Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"}) + @Post("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono generate( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + Context context); + + @Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}") + @ExpectedResponses({202, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getGenerateStatus( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("operationId") UUID operationId, + @QueryParam("api-version") String apiVersion, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @QueryParam("$filter") String filter, + @QueryParam("$top") Integer top, + @QueryParam("$skipToken") String skipToken, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get( + @HostParam("$host") String endpoint, + @PathParam("resourceUri") String resourceUri, + @PathParam("recommendationId") String recommendationId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono generateWithResponseAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + return FluxUtil + .withContext( + context -> + service + .generate( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono generateWithResponseAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + context = this.client.mergeContext(context); + return service + .generate(this.client.getEndpoint(), this.client.getSubscriptionId(), this.client.getApiVersion(), context); + } + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono generateAsync() { + return generateWithResponseAsync().flatMap((RecommendationsGenerateResponse res) -> Mono.empty()); + } + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @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 generate() { + generateAsync().block(); + } + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response generateWithResponse(Context context) { + return generateWithResponseAsync(context).block(); + } + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the + * generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation + * response header. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getGenerateStatusWithResponseAsync(UUID operationId) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (operationId == null) { + return Mono.error(new IllegalArgumentException("Parameter operationId is required and cannot be null.")); + } + return FluxUtil + .withContext( + context -> + service + .getGenerateStatus( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + operationId, + this.client.getApiVersion(), + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the + * generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation + * response header. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getGenerateStatusWithResponseAsync(UUID operationId, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (operationId == null) { + return Mono.error(new IllegalArgumentException("Parameter operationId is required and cannot be null.")); + } + context = this.client.mergeContext(context); + return service + .getGenerateStatus( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + operationId, + this.client.getApiVersion(), + context); + } + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the + * generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation + * response header. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getGenerateStatusAsync(UUID operationId) { + return getGenerateStatusWithResponseAsync(operationId).flatMap((Response res) -> Mono.empty()); + } + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the + * generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation + * response header. + * @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 getGenerateStatus(UUID operationId) { + getGenerateStatusAsync(operationId).block(); + } + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the + * generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation + * response header. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getGenerateStatusWithResponse(UUID operationId, Context context) { + return getGenerateStatusWithResponseAsync(operationId, context).block(); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @param filter The filter to apply to the recommendations.<br>Filter can be applied to properties + * ['ResourceId', 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', + * 'and', 'or'].<br>Example:<br>- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup'. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync( + String filter, Integer top, String skipToken) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .list( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + filter, + top, + skipToken, + accept, + context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @param filter The filter to apply to the recommendations.<br>Filter can be applied to properties + * ['ResourceId', 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', + * 'and', 'or'].<br>Example:<br>- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup'. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync( + String filter, Integer top, String skipToken, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + filter, + top, + skipToken, + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @param filter The filter to apply to the recommendations.<br>Filter can be applied to properties + * ['ResourceId', 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', + * 'and', 'or'].<br>Example:<br>- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup'. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String filter, Integer top, String skipToken) { + return new PagedFlux<>( + () -> listSinglePageAsync(filter, top, skipToken), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + final String filter = null; + final Integer top = null; + final String skipToken = null; + return new PagedFlux<>( + () -> listSinglePageAsync(filter, top, skipToken), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @param filter The filter to apply to the recommendations.<br>Filter can be applied to properties + * ['ResourceId', 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', + * 'and', 'or'].<br>Example:<br>- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup'. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync( + String filter, Integer top, String skipToken, Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(filter, top, skipToken, context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + final String filter = null; + final Integer top = null; + final String skipToken = null; + return new PagedIterable<>(listAsync(filter, top, skipToken)); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @param filter The filter to apply to the recommendations.<br>Filter can be applied to properties + * ['ResourceId', 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', + * 'and', 'or'].<br>Example:<br>- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup'. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list( + String filter, Integer top, String skipToken, Context context) { + return new PagedIterable<>(listAsync(filter, top, skipToken, context)); + } + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @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 advisor Recommendation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync( + String resourceUri, String recommendationId) { + 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 (recommendationId == null) { + return Mono + .error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .get( + this.client.getEndpoint(), + resourceUri, + recommendationId, + this.client.getApiVersion(), + accept, + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return advisor Recommendation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync( + String resourceUri, String recommendationId, Context context) { + 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 (recommendationId == null) { + return Mono + .error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .get( + this.client.getEndpoint(), resourceUri, recommendationId, this.client.getApiVersion(), accept, context); + } + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @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 advisor Recommendation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceUri, String recommendationId) { + return getWithResponseAsync(resourceUri, recommendationId) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @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 advisor Recommendation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResourceRecommendationBaseInner get(String resourceUri, String recommendationId) { + return getAsync(resourceUri, recommendationId).block(); + } + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return advisor Recommendation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse( + String resourceUri, String recommendationId, Context context) { + return getWithResponseAsync(resourceUri, recommendationId, context).block(); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @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)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync( + String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationsImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationsImpl.java new file mode 100644 index 000000000000..5ec8a308a743 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/RecommendationsImpl.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.RecommendationsClient; +import com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner; +import com.azure.resourcemanager.advisor.models.Recommendations; +import com.azure.resourcemanager.advisor.models.ResourceRecommendationBase; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.UUID; + +public final class RecommendationsImpl implements Recommendations { + @JsonIgnore private final ClientLogger logger = new ClientLogger(RecommendationsImpl.class); + + private final RecommendationsClient innerClient; + + private final AdvisorManager serviceManager; + + public RecommendationsImpl(RecommendationsClient innerClient, AdvisorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public void generate() { + this.serviceClient().generate(); + } + + public Response generateWithResponse(Context context) { + return this.serviceClient().generateWithResponse(context); + } + + public void getGenerateStatus(UUID operationId) { + this.serviceClient().getGenerateStatus(operationId); + } + + public Response getGenerateStatusWithResponse(UUID operationId, Context context) { + return this.serviceClient().getGenerateStatusWithResponse(operationId, context); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return inner.mapPage(inner1 -> new ResourceRecommendationBaseImpl(inner1, this.manager())); + } + + public PagedIterable list( + String filter, Integer top, String skipToken, Context context) { + PagedIterable inner = + this.serviceClient().list(filter, top, skipToken, context); + return inner.mapPage(inner1 -> new ResourceRecommendationBaseImpl(inner1, this.manager())); + } + + public ResourceRecommendationBase get(String resourceUri, String recommendationId) { + ResourceRecommendationBaseInner inner = this.serviceClient().get(resourceUri, recommendationId); + if (inner != null) { + return new ResourceRecommendationBaseImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getWithResponse( + String resourceUri, String recommendationId, Context context) { + Response inner = + this.serviceClient().getWithResponse(resourceUri, recommendationId, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ResourceRecommendationBaseImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + private RecommendationsClient serviceClient() { + return this.innerClient; + } + + private AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceRecommendationBaseImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceRecommendationBaseImpl.java new file mode 100644 index 000000000000..c5c4319b853f --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceRecommendationBaseImpl.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.resourcemanager.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner; +import com.azure.resourcemanager.advisor.models.Category; +import com.azure.resourcemanager.advisor.models.Impact; +import com.azure.resourcemanager.advisor.models.ResourceMetadata; +import com.azure.resourcemanager.advisor.models.ResourceRecommendationBase; +import com.azure.resourcemanager.advisor.models.Risk; +import com.azure.resourcemanager.advisor.models.ShortDescription; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public final class ResourceRecommendationBaseImpl implements ResourceRecommendationBase { + private ResourceRecommendationBaseInner innerObject; + + private final AdvisorManager serviceManager; + + public ResourceRecommendationBaseImpl(ResourceRecommendationBaseInner innerObject, AdvisorManager 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 Category category() { + return this.innerModel().category(); + } + + public Impact impact() { + return this.innerModel().impact(); + } + + public String impactedField() { + return this.innerModel().impactedField(); + } + + public String impactedValue() { + return this.innerModel().impactedValue(); + } + + public OffsetDateTime lastUpdated() { + return this.innerModel().lastUpdated(); + } + + public Map metadata() { + Map inner = this.innerModel().metadata(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public String recommendationTypeId() { + return this.innerModel().recommendationTypeId(); + } + + public Risk risk() { + return this.innerModel().risk(); + } + + public ShortDescription shortDescription() { + return this.innerModel().shortDescription(); + } + + public List suppressionIds() { + List inner = this.innerModel().suppressionIds(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public Map extendedProperties() { + Map inner = this.innerModel().extendedProperties(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public ResourceMetadata resourceMetadata() { + return this.innerModel().resourceMetadata(); + } + + public ResourceRecommendationBaseInner innerModel() { + return this.innerObject; + } + + private AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionContractImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionContractImpl.java new file mode 100644 index 000000000000..b575d0127845 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionContractImpl.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.resourcemanager.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; +import com.azure.resourcemanager.advisor.models.SuppressionContract; +import java.time.OffsetDateTime; + +public final class SuppressionContractImpl implements SuppressionContract { + private SuppressionContractInner innerObject; + + private final AdvisorManager serviceManager; + + public SuppressionContractImpl(SuppressionContractInner innerObject, AdvisorManager 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 String suppressionId() { + return this.innerModel().suppressionId(); + } + + public String ttl() { + return this.innerModel().ttl(); + } + + public OffsetDateTime expirationTimestamp() { + return this.innerModel().expirationTimestamp(); + } + + public SuppressionContractInner innerModel() { + return this.innerObject; + } + + private AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionsClientImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionsClientImpl.java new file mode 100644 index 000000000000..d238b267e040 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionsClientImpl.java @@ -0,0 +1,875 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.SuppressionsClient; +import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; +import com.azure.resourcemanager.advisor.models.SuppressionContractListResult; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in SuppressionsClient. */ +public final class SuppressionsClientImpl implements SuppressionsClient { + private final ClientLogger logger = new ClientLogger(SuppressionsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final SuppressionsService service; + + /** The service client containing this operation class. */ + private final AdvisorManagementClientImpl client; + + /** + * Initializes an instance of SuppressionsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SuppressionsClientImpl(AdvisorManagementClientImpl client) { + this.service = + RestProxy.create(SuppressionsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdvisorManagementClientSuppressions to be used by the proxy service + * to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AdvisorManagementCli") + private interface SuppressionsService { + @Headers({"Content-Type: application/json"}) + @Get("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get( + @HostParam("$host") String endpoint, + @PathParam("resourceUri") String resourceUri, + @PathParam("recommendationId") String recommendationId, + @PathParam("name") String name, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}") + @ExpectedResponses({200, 404}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> create( + @HostParam("$host") String endpoint, + @PathParam("resourceUri") String resourceUri, + @PathParam("recommendationId") String recommendationId, + @PathParam("name") String name, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") SuppressionContractInner suppressionContract, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"}) + @Delete("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete( + @HostParam("$host") String endpoint, + @PathParam("resourceUri") String resourceUri, + @PathParam("recommendationId") String recommendationId, + @PathParam("name") String name, + @QueryParam("api-version") String apiVersion, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @QueryParam("$top") Integer top, + @QueryParam("$skipToken") String skipToken, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync( + String resourceUri, String recommendationId, String name) { + 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 (recommendationId == null) { + return Mono + .error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .get( + this.client.getEndpoint(), + resourceUri, + recommendationId, + name, + this.client.getApiVersion(), + accept, + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync( + String resourceUri, String recommendationId, String name, Context context) { + 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 (recommendationId == null) { + return Mono + .error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .get( + this.client.getEndpoint(), + resourceUri, + recommendationId, + name, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceUri, String recommendationId, String name) { + return getWithResponseAsync(resourceUri, recommendationId, name) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SuppressionContractInner get(String resourceUri, String recommendationId, String name) { + return getAsync(resourceUri, recommendationId, name).block(); + } + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse( + String resourceUri, String recommendationId, String name, Context context) { + return getWithResponseAsync(resourceUri, recommendationId, name, context).block(); + } + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to + * as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The details of the snoozed or dismissed rule; for example, the duration, name, and + * GUID associated with the rule. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createWithResponseAsync( + String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + 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 (recommendationId == null) { + return Mono + .error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + if (suppressionContract == null) { + return Mono + .error(new IllegalArgumentException("Parameter suppressionContract is required and cannot be null.")); + } else { + suppressionContract.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .create( + this.client.getEndpoint(), + resourceUri, + recommendationId, + name, + this.client.getApiVersion(), + suppressionContract, + accept, + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to + * as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The details of the snoozed or dismissed rule; for example, the duration, name, and + * GUID associated with the rule. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createWithResponseAsync( + String resourceUri, + String recommendationId, + String name, + SuppressionContractInner suppressionContract, + Context context) { + 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 (recommendationId == null) { + return Mono + .error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + if (suppressionContract == null) { + return Mono + .error(new IllegalArgumentException("Parameter suppressionContract is required and cannot be null.")); + } else { + suppressionContract.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .create( + this.client.getEndpoint(), + resourceUri, + recommendationId, + name, + this.client.getApiVersion(), + suppressionContract, + accept, + context); + } + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to + * as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The details of the snoozed or dismissed rule; for example, the duration, name, and + * GUID associated with the rule. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync( + String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + return createWithResponseAsync(resourceUri, recommendationId, name, suppressionContract) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to + * as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The details of the snoozed or dismissed rule; for example, the duration, name, and + * GUID associated with the rule. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SuppressionContractInner create( + String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + return createAsync(resourceUri, recommendationId, name, suppressionContract).block(); + } + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to + * as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The details of the snoozed or dismissed rule; for example, the duration, name, and + * GUID associated with the rule. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse( + String resourceUri, + String recommendationId, + String name, + SuppressionContractInner suppressionContract, + Context context) { + return createWithResponseAsync(resourceUri, recommendationId, name, suppressionContract, context).block(); + } + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a + * recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceUri, String recommendationId, String name) { + 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 (recommendationId == null) { + return Mono + .error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + resourceUri, + recommendationId, + name, + this.client.getApiVersion(), + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a + * recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync( + String resourceUri, String recommendationId, String name, Context context) { + 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 (recommendationId == null) { + return Mono + .error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + context = this.client.mergeContext(context); + return service + .delete( + this.client.getEndpoint(), resourceUri, recommendationId, name, this.client.getApiVersion(), context); + } + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a + * recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceUri, String recommendationId, String name) { + return deleteWithResponseAsync(resourceUri, recommendationId, name) + .flatMap((Response res) -> Mono.empty()); + } + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a + * recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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, String recommendationId, String name) { + deleteAsync(resourceUri, recommendationId, name).block(); + } + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a + * recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse( + String resourceUri, String recommendationId, String name, Context context) { + return deleteWithResponseAsync(resourceUri, recommendationId, name, context).block(); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @param top The number of suppressions per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Integer top, String skipToken) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .list( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + top, + skipToken, + accept, + context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @param top The number of suppressions per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync( + Integer top, String skipToken, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + top, + skipToken, + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @param top The number of suppressions per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Integer top, String skipToken) { + return new PagedFlux<>( + () -> listSinglePageAsync(top, skipToken), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + final Integer top = null; + final String skipToken = null; + return new PagedFlux<>( + () -> listSinglePageAsync(top, skipToken), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @param top The number of suppressions per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Integer top, String skipToken, Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(top, skipToken, context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + final Integer top = null; + final String skipToken = null; + return new PagedIterable<>(listAsync(top, skipToken)); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @param top The number of suppressions per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Integer top, String skipToken, Context context) { + return new PagedIterable<>(listAsync(top, skipToken, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @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)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionsImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionsImpl.java new file mode 100644 index 000000000000..511527b7b6af --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionsImpl.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.AdvisorManager; +import com.azure.resourcemanager.advisor.fluent.SuppressionsClient; +import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; +import com.azure.resourcemanager.advisor.models.SuppressionContract; +import com.azure.resourcemanager.advisor.models.Suppressions; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class SuppressionsImpl implements Suppressions { + @JsonIgnore private final ClientLogger logger = new ClientLogger(SuppressionsImpl.class); + + private final SuppressionsClient innerClient; + + private final AdvisorManager serviceManager; + + public SuppressionsImpl(SuppressionsClient innerClient, AdvisorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public SuppressionContract get(String resourceUri, String recommendationId, String name) { + SuppressionContractInner inner = this.serviceClient().get(resourceUri, recommendationId, name); + if (inner != null) { + return new SuppressionContractImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getWithResponse( + String resourceUri, String recommendationId, String name, Context context) { + Response inner = + this.serviceClient().getWithResponse(resourceUri, recommendationId, name, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new SuppressionContractImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public SuppressionContract create( + String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + SuppressionContractInner inner = + this.serviceClient().create(resourceUri, recommendationId, name, suppressionContract); + if (inner != null) { + return new SuppressionContractImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response createWithResponse( + String resourceUri, + String recommendationId, + String name, + SuppressionContractInner suppressionContract, + Context context) { + Response inner = + this.serviceClient().createWithResponse(resourceUri, recommendationId, name, suppressionContract, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new SuppressionContractImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public void delete(String resourceUri, String recommendationId, String name) { + this.serviceClient().delete(resourceUri, recommendationId, name); + } + + public Response deleteWithResponse( + String resourceUri, String recommendationId, String name, Context context) { + return this.serviceClient().deleteWithResponse(resourceUri, recommendationId, name, context); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return inner.mapPage(inner1 -> new SuppressionContractImpl(inner1, this.manager())); + } + + public PagedIterable list(Integer top, String skipToken, Context context) { + PagedIterable inner = this.serviceClient().list(top, skipToken, context); + return inner.mapPage(inner1 -> new SuppressionContractImpl(inner1, this.manager())); + } + + private SuppressionsClient serviceClient() { + return this.innerClient; + } + + private AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/Utils.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/Utils.java new file mode 100644 index 000000000000..392e7e66f19a --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/Utils.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import java.util.Arrays; +import java.util.Iterator; + +final class Utils { + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterable iterable = Arrays.asList(id.split("/")); + Iterator itr = iterable.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; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/package-info.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/package-info.java new file mode 100644 index 000000000000..b35391d8b1bb --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the implementations for AdvisorManagementClient. REST APIs for Azure Advisor. */ +package com.azure.resourcemanager.advisor.implementation; diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Category.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Category.java new file mode 100644 index 000000000000..e87d373c6ca8 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Category.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for Category. */ +public final class Category extends ExpandableStringEnum { + /** Static value HighAvailability for Category. */ + public static final Category HIGH_AVAILABILITY = fromString("HighAvailability"); + + /** Static value Security for Category. */ + public static final Category SECURITY = fromString("Security"); + + /** Static value Performance for Category. */ + public static final Category PERFORMANCE = fromString("Performance"); + + /** Static value Cost for Category. */ + public static final Category COST = fromString("Cost"); + + /** Static value OperationalExcellence for Category. */ + public static final Category OPERATIONAL_EXCELLENCE = fromString("OperationalExcellence"); + + /** + * Creates or finds a Category from its string representation. + * + * @param name a name to look for. + * @return the corresponding Category. + */ + @JsonCreator + public static Category fromString(String name) { + return fromString(name, Category.class); + } + + /** @return known Category values. */ + public static Collection values() { + return values(Category.class); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ConfigData.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ConfigData.java new file mode 100644 index 000000000000..361cfec26f17 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ConfigData.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; +import java.util.List; + +/** An immutable client-side representation of ConfigData. */ +public interface ConfigData { + /** + * 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 exclude property: Exclude the resource from Advisor evaluations. Valid values: False (default) or True. + * + * @return the exclude value. + */ + Boolean exclude(); + + /** + * Gets the lowCpuThreshold property: Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid + * only for subscriptions. Valid values: 5 (default), 10, 15 or 20. + * + * @return the lowCpuThreshold value. + */ + CpuThreshold lowCpuThreshold(); + + /** + * Gets the digests property: Advisor digest configuration. Valid only for subscriptions. + * + * @return the digests value. + */ + List digests(); + + /** + * Gets the inner com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner object. + * + * @return the inner object. + */ + ConfigDataInner innerModel(); + + /** The entirety of the ConfigData definition. */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + /** The ConfigData definition stages. */ + interface DefinitionStages { + /** The first stage of the ConfigData definition. */ + interface Blank extends WithResourceGroup { + } + /** The stage of the ConfigData definition allowing to specify parent resource. */ + interface WithResourceGroup { + /** + * Specifies resourceGroup. + * + * @param resourceGroup The name of the Azure resource group. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroup); + } + /** + * The stage of the ConfigData definition which contains all the minimum required properties for the resource to + * be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate + extends DefinitionStages.WithExclude, DefinitionStages.WithLowCpuThreshold, DefinitionStages.WithDigests { + /** + * Executes the create request. + * + * @return the created resource. + */ + ConfigData create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ConfigData create(Context context); + } + /** The stage of the ConfigData definition allowing to specify exclude. */ + interface WithExclude { + /** + * Specifies the exclude property: Exclude the resource from Advisor evaluations. Valid values: False + * (default) or True.. + * + * @param exclude Exclude the resource from Advisor evaluations. Valid values: False (default) or True. + * @return the next definition stage. + */ + WithCreate withExclude(Boolean exclude); + } + /** The stage of the ConfigData definition allowing to specify lowCpuThreshold. */ + interface WithLowCpuThreshold { + /** + * Specifies the lowCpuThreshold property: Minimum percentage threshold for Advisor low CPU utilization + * evaluation. Valid only for subscriptions. Valid values: 5 (default), 10, 15 or 20.. + * + * @param lowCpuThreshold Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid + * only for subscriptions. Valid values: 5 (default), 10, 15 or 20. + * @return the next definition stage. + */ + WithCreate withLowCpuThreshold(CpuThreshold lowCpuThreshold); + } + /** The stage of the ConfigData definition allowing to specify digests. */ + interface WithDigests { + /** + * Specifies the digests property: Advisor digest configuration. Valid only for subscriptions. + * + * @param digests Advisor digest configuration. Valid only for subscriptions. + * @return the next definition stage. + */ + WithCreate withDigests(List digests); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ConfigurationListResult.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ConfigurationListResult.java new file mode 100644 index 000000000000..b6555aeedd71 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ConfigurationListResult.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The list of Advisor configurations. */ +@Fluent +public final class ConfigurationListResult { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ConfigurationListResult.class); + + /* + * The list of configurations. + */ + @JsonProperty(value = "value") + private List value; + + /* + * The link used to get the next page of configurations. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: The list of configurations. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The list of configurations. + * + * @param value the value value to set. + * @return the ConfigurationListResult object itself. + */ + public ConfigurationListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The link used to get the next page of configurations. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link used to get the next page of configurations. + * + * @param nextLink the nextLink value to set. + * @return the ConfigurationListResult object itself. + */ + public ConfigurationListResult withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ConfigurationName.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ConfigurationName.java new file mode 100644 index 000000000000..fc2f618e0868 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ConfigurationName.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for ConfigurationName. */ +public final class ConfigurationName extends ExpandableStringEnum { + /** Static value default for ConfigurationName. */ + public static final ConfigurationName DEFAULT = fromString("default"); + + /** + * Creates or finds a ConfigurationName from its string representation. + * + * @param name a name to look for. + * @return the corresponding ConfigurationName. + */ + @JsonCreator + public static ConfigurationName fromString(String name) { + return fromString(name, ConfigurationName.class); + } + + /** @return known ConfigurationName values. */ + public static Collection values() { + return values(ConfigurationName.class); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Configurations.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Configurations.java new file mode 100644 index 000000000000..6ece2b504372 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Configurations.java @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.fluent.models.ConfigDataInner; + +/** Resource collection API of Configurations. */ +public interface Configurations { + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + PagedIterable list(); + + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + PagedIterable list(Context context); + + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + ConfigData createInSubscription(ConfigurationName configurationName, ConfigDataInner configContract); + + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. + * + * @param configurationName Advisor configuration name. Value must be 'default'. + * @param configContract The Advisor configuration data structure. + * @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 Advisor configuration data structure. + */ + Response createInSubscriptionWithResponse( + ConfigurationName configurationName, ConfigDataInner configContract, Context context); + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + PagedIterable listByResourceGroup(String resourceGroup); + + /** + * Retrieve Azure Advisor configurations. + * + * @param resourceGroup The name of the Azure resource group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor configurations. + */ + PagedIterable listByResourceGroup(String resourceGroup, Context context); + + /** + * Begins definition for a new ConfigData resource. + * + * @param name resource name. + * @return the first stage of the new ConfigData definition. + */ + ConfigData.DefinitionStages.Blank define(ConfigurationName name); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/CpuThreshold.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/CpuThreshold.java new file mode 100644 index 000000000000..cafaf4a4b42b --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/CpuThreshold.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for CpuThreshold. */ +public final class CpuThreshold extends ExpandableStringEnum { + /** Static value 5 for CpuThreshold. */ + public static final CpuThreshold FIVE = fromString("5"); + + /** Static value 10 for CpuThreshold. */ + public static final CpuThreshold ONE_ZERO = fromString("10"); + + /** Static value 15 for CpuThreshold. */ + public static final CpuThreshold ONE_FIVE = fromString("15"); + + /** Static value 20 for CpuThreshold. */ + public static final CpuThreshold TWO_ZERO = fromString("20"); + + /** + * Creates or finds a CpuThreshold from its string representation. + * + * @param name a name to look for. + * @return the corresponding CpuThreshold. + */ + @JsonCreator + public static CpuThreshold fromString(String name) { + return fromString(name, CpuThreshold.class); + } + + /** @return known CpuThreshold values. */ + public static Collection values() { + return values(CpuThreshold.class); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/DigestConfig.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/DigestConfig.java new file mode 100644 index 000000000000..f415574d66bc --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/DigestConfig.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Advisor Digest configuration entity. */ +@Fluent +public final class DigestConfig { + @JsonIgnore private final ClientLogger logger = new ClientLogger(DigestConfig.class); + + /* + * Name of digest configuration. Value is case-insensitive and must be + * unique within a subscription. + */ + @JsonProperty(value = "name") + private String name; + + /* + * Action group resource id used by digest. + */ + @JsonProperty(value = "actionGroupResourceId") + private String actionGroupResourceId; + + /* + * Frequency that digest will be triggered, in days. Value must be between + * 7 and 30 days inclusive. + */ + @JsonProperty(value = "frequency") + private Integer frequency; + + /* + * Categories to send digest for. If categories are not provided, then + * digest will be sent for all categories. + */ + @JsonProperty(value = "categories") + private List categories; + + /* + * Language for digest content body. Value must be ISO 639-1 code for one + * of Azure portal supported languages. Otherwise, it will be converted + * into one. Default value is English (en). + */ + @JsonProperty(value = "language") + private String language; + + /* + * State of digest configuration. + */ + @JsonProperty(value = "state") + private DigestConfigState state; + + /** + * Get the name property: Name of digest configuration. Value is case-insensitive and must be unique within a + * subscription. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Name of digest configuration. Value is case-insensitive and must be unique within a + * subscription. + * + * @param name the name value to set. + * @return the DigestConfig object itself. + */ + public DigestConfig withName(String name) { + this.name = name; + return this; + } + + /** + * Get the actionGroupResourceId property: Action group resource id used by digest. + * + * @return the actionGroupResourceId value. + */ + public String actionGroupResourceId() { + return this.actionGroupResourceId; + } + + /** + * Set the actionGroupResourceId property: Action group resource id used by digest. + * + * @param actionGroupResourceId the actionGroupResourceId value to set. + * @return the DigestConfig object itself. + */ + public DigestConfig withActionGroupResourceId(String actionGroupResourceId) { + this.actionGroupResourceId = actionGroupResourceId; + return this; + } + + /** + * Get the frequency property: Frequency that digest will be triggered, in days. Value must be between 7 and 30 days + * inclusive. + * + * @return the frequency value. + */ + public Integer frequency() { + return this.frequency; + } + + /** + * Set the frequency property: Frequency that digest will be triggered, in days. Value must be between 7 and 30 days + * inclusive. + * + * @param frequency the frequency value to set. + * @return the DigestConfig object itself. + */ + public DigestConfig withFrequency(Integer frequency) { + this.frequency = frequency; + return this; + } + + /** + * Get the categories property: Categories to send digest for. If categories are not provided, then digest will be + * sent for all categories. + * + * @return the categories value. + */ + public List categories() { + return this.categories; + } + + /** + * Set the categories property: Categories to send digest for. If categories are not provided, then digest will be + * sent for all categories. + * + * @param categories the categories value to set. + * @return the DigestConfig object itself. + */ + public DigestConfig withCategories(List categories) { + this.categories = categories; + return this; + } + + /** + * Get the language property: Language for digest content body. Value must be ISO 639-1 code for one of Azure portal + * supported languages. Otherwise, it will be converted into one. Default value is English (en). + * + * @return the language value. + */ + public String language() { + return this.language; + } + + /** + * Set the language property: Language for digest content body. Value must be ISO 639-1 code for one of Azure portal + * supported languages. Otherwise, it will be converted into one. Default value is English (en). + * + * @param language the language value to set. + * @return the DigestConfig object itself. + */ + public DigestConfig withLanguage(String language) { + this.language = language; + return this; + } + + /** + * Get the state property: State of digest configuration. + * + * @return the state value. + */ + public DigestConfigState state() { + return this.state; + } + + /** + * Set the state property: State of digest configuration. + * + * @param state the state value to set. + * @return the DigestConfig object itself. + */ + public DigestConfig withState(DigestConfigState state) { + this.state = state; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/DigestConfigState.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/DigestConfigState.java new file mode 100644 index 000000000000..cfa5d2b131a0 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/DigestConfigState.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for DigestConfigState. */ +public final class DigestConfigState extends ExpandableStringEnum { + /** Static value Active for DigestConfigState. */ + public static final DigestConfigState ACTIVE = fromString("Active"); + + /** Static value Disabled for DigestConfigState. */ + public static final DigestConfigState DISABLED = fromString("Disabled"); + + /** + * Creates or finds a DigestConfigState from its string representation. + * + * @param name a name to look for. + * @return the corresponding DigestConfigState. + */ + @JsonCreator + public static DigestConfigState fromString(String name) { + return fromString(name, DigestConfigState.class); + } + + /** @return known DigestConfigState values. */ + public static Collection values() { + return values(DigestConfigState.class); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Impact.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Impact.java new file mode 100644 index 000000000000..e0018d623eb7 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Impact.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for Impact. */ +public final class Impact extends ExpandableStringEnum { + /** Static value High for Impact. */ + public static final Impact HIGH = fromString("High"); + + /** Static value Medium for Impact. */ + public static final Impact MEDIUM = fromString("Medium"); + + /** Static value Low for Impact. */ + public static final Impact LOW = fromString("Low"); + + /** + * Creates or finds a Impact from its string representation. + * + * @param name a name to look for. + * @return the corresponding Impact. + */ + @JsonCreator + public static Impact fromString(String name) { + return fromString(name, Impact.class); + } + + /** @return known Impact values. */ + public static Collection values() { + return values(Impact.class); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/MetadataEntity.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/MetadataEntity.java new file mode 100644 index 000000000000..0bdd69509b20 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/MetadataEntity.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; +import java.util.List; + +/** An immutable client-side representation of MetadataEntity. */ +public interface MetadataEntity { + /** + * Gets the id property: The resource Id of the metadata entity. + * + * @return the id value. + */ + String id(); + + /** + * Gets the type property: The type of the metadata entity. + * + * @return the type value. + */ + String type(); + + /** + * Gets the name property: The name of the metadata entity. + * + * @return the name value. + */ + String name(); + + /** + * Gets the displayName property: The display name. + * + * @return the displayName value. + */ + String displayName(); + + /** + * Gets the dependsOn property: The list of keys on which this entity depends on. + * + * @return the dependsOn value. + */ + List dependsOn(); + + /** + * Gets the applicableScenarios property: The list of scenarios applicable to this metadata entity. + * + * @return the applicableScenarios value. + */ + List applicableScenarios(); + + /** + * Gets the supportedValues property: The list of supported values. + * + * @return the supportedValues value. + */ + List supportedValues(); + + /** + * Gets the inner com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner object. + * + * @return the inner object. + */ + MetadataEntityInner innerModel(); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/MetadataEntityListResult.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/MetadataEntityListResult.java new file mode 100644 index 000000000000..a7f53037aa24 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/MetadataEntityListResult.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The list of metadata entities. */ +@Fluent +public final class MetadataEntityListResult { + @JsonIgnore private final ClientLogger logger = new ClientLogger(MetadataEntityListResult.class); + + /* + * The list of metadata entities. + */ + @JsonProperty(value = "value") + private List value; + + /* + * The link used to get the next page of metadata. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: The list of metadata entities. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The list of metadata entities. + * + * @param value the value value to set. + * @return the MetadataEntityListResult object itself. + */ + public MetadataEntityListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The link used to get the next page of metadata. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link used to get the next page of metadata. + * + * @param nextLink the nextLink value to set. + * @return the MetadataEntityListResult object itself. + */ + public MetadataEntityListResult withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/MetadataSupportedValueDetail.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/MetadataSupportedValueDetail.java new file mode 100644 index 000000000000..7005db108635 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/MetadataSupportedValueDetail.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The metadata supported value detail. */ +@Fluent +public final class MetadataSupportedValueDetail { + @JsonIgnore private final ClientLogger logger = new ClientLogger(MetadataSupportedValueDetail.class); + + /* + * The id. + */ + @JsonProperty(value = "id") + private String id; + + /* + * The display name. + */ + @JsonProperty(value = "displayName") + private String displayName; + + /** + * Get the id property: The id. + * + * @return the id value. + */ + public String id() { + return this.id; + } + + /** + * Set the id property: The id. + * + * @param id the id value to set. + * @return the MetadataSupportedValueDetail object itself. + */ + public MetadataSupportedValueDetail withId(String id) { + this.id = id; + return this; + } + + /** + * Get the displayName property: The display name. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: The display name. + * + * @param displayName the displayName value to set. + * @return the MetadataSupportedValueDetail object itself. + */ + public MetadataSupportedValueDetail withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/OperationDisplayInfo.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/OperationDisplayInfo.java new file mode 100644 index 000000000000..5a04f20f003b --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/OperationDisplayInfo.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The operation supported by Advisor. */ +@Fluent +public final class OperationDisplayInfo { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationDisplayInfo.class); + + /* + * The description of the operation. + */ + @JsonProperty(value = "description") + private String description; + + /* + * The action that users can perform, based on their permission level. + */ + @JsonProperty(value = "operation") + private String operation; + + /* + * Service provider: Microsoft Advisor. + */ + @JsonProperty(value = "provider") + private String provider; + + /* + * Resource on which the operation is performed. + */ + @JsonProperty(value = "resource") + private String resource; + + /** + * Get the description property: The description of the operation. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: The description of the operation. + * + * @param description the description value to set. + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the operation property: The action that users can perform, based on their permission level. + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Set the operation property: The action that users can perform, based on their permission level. + * + * @param operation the operation value to set. + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withOperation(String operation) { + this.operation = operation; + return this; + } + + /** + * Get the provider property: Service provider: Microsoft Advisor. + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider property: Service provider: Microsoft Advisor. + * + * @param provider the provider value to set. + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the resource property: Resource on which the operation is performed. + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Set the resource property: Resource on which the operation is performed. + * + * @param resource the resource value to set. + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withResource(String resource) { + this.resource = resource; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/OperationEntity.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/OperationEntity.java new file mode 100644 index 000000000000..d190a4a4138a --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/OperationEntity.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner; + +/** An immutable client-side representation of OperationEntity. */ +public interface OperationEntity { + /** + * Gets the name property: Operation name: {provider}/{resource}/{operation}. + * + * @return the name value. + */ + String name(); + + /** + * Gets the display property: The operation supported by Advisor. + * + * @return the display value. + */ + OperationDisplayInfo display(); + + /** + * Gets the inner com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner object. + * + * @return the inner object. + */ + OperationEntityInner innerModel(); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/OperationEntityListResult.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/OperationEntityListResult.java new file mode 100644 index 000000000000..18565d800ee6 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/OperationEntityListResult.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The list of Advisor operations. */ +@Fluent +public final class OperationEntityListResult { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationEntityListResult.class); + + /* + * The link used to get the next page of operations. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /* + * The list of operations. + */ + @JsonProperty(value = "value") + private List value; + + /** + * Get the nextLink property: The link used to get the next page of operations. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link used to get the next page of operations. + * + * @param nextLink the nextLink value to set. + * @return the OperationEntityListResult object itself. + */ + public OperationEntityListResult withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Get the value property: The list of operations. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The list of operations. + * + * @param value the value value to set. + * @return the OperationEntityListResult object itself. + */ + public OperationEntityListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Operations.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Operations.java new file mode 100644 index 000000000000..4b4efb5e1a86 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Operations.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * Lists all the available Advisor REST API operations. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + PagedIterable list(); + + /** + * Lists all the available Advisor REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor operations. + */ + PagedIterable list(Context context); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/RecommendationMetadatas.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/RecommendationMetadatas.java new file mode 100644 index 000000000000..d23c28c2a057 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/RecommendationMetadatas.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of RecommendationMetadatas. */ +public interface RecommendationMetadatas { + /** + * Gets the metadata entity. + * + * @param name Name of metadata entity. + * @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 metadata entity. + */ + MetadataEntity get(String name); + + /** + * Gets the metadata entity. + * + * @param name Name of metadata entity. + * @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 metadata entity. + */ + Response getWithResponse(String name, Context context); + + /** + * Gets the list of metadata entities. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + PagedIterable list(); + + /** + * Gets the list of metadata entities. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of metadata entities. + */ + PagedIterable list(Context context); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Recommendations.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Recommendations.java new file mode 100644 index 000000000000..e30d0375e6fc --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Recommendations.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import java.util.UUID; + +/** Resource collection API of Recommendations. */ +public interface Recommendations { + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @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 generate(); + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + Response generateWithResponse(Context context); + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the + * generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation + * response header. + * @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 getGenerateStatus(UUID operationId); + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the + * generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation + * response header. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + Response getGenerateStatusWithResponse(UUID operationId, Context context); + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + PagedIterable list(); + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking + * generateRecommendations. + * + * @param filter The filter to apply to the recommendations.<br>Filter can be applied to properties + * ['ResourceId', 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', + * 'and', 'or'].<br>Example:<br>- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup'. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor recommendations. + */ + PagedIterable list(String filter, Integer top, String skipToken, Context context); + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return advisor Recommendation. + */ + ResourceRecommendationBase get(String resourceUri, String recommendationId); + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return advisor Recommendation. + */ + Response getWithResponse(String resourceUri, String recommendationId, Context context); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/RecommendationsGenerateHeaders.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/RecommendationsGenerateHeaders.java new file mode 100644 index 000000000000..4c93a3d458ef --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/RecommendationsGenerateHeaders.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The RecommendationsGenerateHeaders model. */ +@Fluent +public final class RecommendationsGenerateHeaders { + @JsonIgnore private final ClientLogger logger = new ClientLogger(RecommendationsGenerateHeaders.class); + + /* + * The Retry-After property. + */ + @JsonProperty(value = "Retry-After") + private String retryAfter; + + /* + * The Location property. + */ + @JsonProperty(value = "Location") + private String location; + + /** + * Get the retryAfter property: The Retry-After property. + * + * @return the retryAfter value. + */ + public String retryAfter() { + return this.retryAfter; + } + + /** + * Set the retryAfter property: The Retry-After property. + * + * @param retryAfter the retryAfter value to set. + * @return the RecommendationsGenerateHeaders object itself. + */ + public RecommendationsGenerateHeaders withRetryAfter(String retryAfter) { + this.retryAfter = retryAfter; + return this; + } + + /** + * Get the location property: The Location property. + * + * @return the location value. + */ + public String location() { + return this.location; + } + + /** + * Set the location property: The Location property. + * + * @param location the location value to set. + * @return the RecommendationsGenerateHeaders object itself. + */ + public RecommendationsGenerateHeaders withLocation(String location) { + this.location = location; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/RecommendationsGenerateResponse.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/RecommendationsGenerateResponse.java new file mode 100644 index 000000000000..fe5f7f901030 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/RecommendationsGenerateResponse.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.ResponseBase; + +/** Contains all response data for the generate operation. */ +public final class RecommendationsGenerateResponse extends ResponseBase { + /** + * Creates an instance of RecommendationsGenerateResponse. + * + * @param request the request which resulted in this RecommendationsGenerateResponse. + * @param statusCode the status code of the HTTP response. + * @param rawHeaders the raw headers of the HTTP response. + * @param value the deserialized value of the HTTP response. + * @param headers the deserialized headers of the HTTP response. + */ + public RecommendationsGenerateResponse( + HttpRequest request, + int statusCode, + HttpHeaders rawHeaders, + Void value, + RecommendationsGenerateHeaders headers) { + super(request, statusCode, rawHeaders, value, headers); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceMetadata.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceMetadata.java new file mode 100644 index 000000000000..b357eb84c10f --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceMetadata.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Recommendation resource metadata. */ +@Fluent +public final class ResourceMetadata { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceMetadata.class); + + /* + * Azure resource Id of the assessed resource + */ + @JsonProperty(value = "resourceId") + private String resourceId; + + /* + * Source from which recommendation is generated + */ + @JsonProperty(value = "source") + private String source; + + /** + * Get the resourceId property: Azure resource Id of the assessed resource. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: Azure resource Id of the assessed resource. + * + * @param resourceId the resourceId value to set. + * @return the ResourceMetadata object itself. + */ + public ResourceMetadata withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * Get the source property: Source from which recommendation is generated. + * + * @return the source value. + */ + public String source() { + return this.source; + } + + /** + * Set the source property: Source from which recommendation is generated. + * + * @param source the source value to set. + * @return the ResourceMetadata object itself. + */ + public ResourceMetadata withSource(String source) { + this.source = source; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceRecommendationBase.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceRecommendationBase.java new file mode 100644 index 000000000000..e7fe3c3822a2 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceRecommendationBase.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** An immutable client-side representation of ResourceRecommendationBase. */ +public interface ResourceRecommendationBase { + /** + * 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 category property: The category of the recommendation. + * + * @return the category value. + */ + Category category(); + + /** + * Gets the impact property: The business impact of the recommendation. + * + * @return the impact value. + */ + Impact impact(); + + /** + * Gets the impactedField property: The resource type identified by Advisor. + * + * @return the impactedField value. + */ + String impactedField(); + + /** + * Gets the impactedValue property: The resource identified by Advisor. + * + * @return the impactedValue value. + */ + String impactedValue(); + + /** + * Gets the lastUpdated property: The most recent time that Advisor checked the validity of the recommendation. + * + * @return the lastUpdated value. + */ + OffsetDateTime lastUpdated(); + + /** + * Gets the metadata property: The recommendation metadata. + * + * @return the metadata value. + */ + Map metadata(); + + /** + * Gets the recommendationTypeId property: The recommendation-type GUID. + * + * @return the recommendationTypeId value. + */ + String recommendationTypeId(); + + /** + * Gets the risk property: The potential risk of not implementing the recommendation. + * + * @return the risk value. + */ + Risk risk(); + + /** + * Gets the shortDescription property: A summary of the recommendation. + * + * @return the shortDescription value. + */ + ShortDescription shortDescription(); + + /** + * Gets the suppressionIds property: The list of snoozed and dismissed rules for the recommendation. + * + * @return the suppressionIds value. + */ + List suppressionIds(); + + /** + * Gets the extendedProperties property: Extended properties. + * + * @return the extendedProperties value. + */ + Map extendedProperties(); + + /** + * Gets the resourceMetadata property: Metadata of resource that was assessed. + * + * @return the resourceMetadata value. + */ + ResourceMetadata resourceMetadata(); + + /** + * Gets the inner com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner object. + * + * @return the inner object. + */ + ResourceRecommendationBaseInner innerModel(); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceRecommendationBaseListResult.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceRecommendationBaseListResult.java new file mode 100644 index 000000000000..e1d013e03bf8 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceRecommendationBaseListResult.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The list of Advisor recommendations. */ +@Fluent +public final class ResourceRecommendationBaseListResult { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceRecommendationBaseListResult.class); + + /* + * The link used to get the next page of recommendations. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /* + * The list of recommendations. + */ + @JsonProperty(value = "value") + private List value; + + /** + * Get the nextLink property: The link used to get the next page of recommendations. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link used to get the next page of recommendations. + * + * @param nextLink the nextLink value to set. + * @return the ResourceRecommendationBaseListResult object itself. + */ + public ResourceRecommendationBaseListResult withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Get the value property: The list of recommendations. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The list of recommendations. + * + * @param value the value value to set. + * @return the ResourceRecommendationBaseListResult object itself. + */ + public ResourceRecommendationBaseListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Risk.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Risk.java new file mode 100644 index 000000000000..4bb3aced7cae --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Risk.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for Risk. */ +public final class Risk extends ExpandableStringEnum { + /** Static value Error for Risk. */ + public static final Risk ERROR = fromString("Error"); + + /** Static value Warning for Risk. */ + public static final Risk WARNING = fromString("Warning"); + + /** Static value None for Risk. */ + public static final Risk NONE = fromString("None"); + + /** + * Creates or finds a Risk from its string representation. + * + * @param name a name to look for. + * @return the corresponding Risk. + */ + @JsonCreator + public static Risk fromString(String name) { + return fromString(name, Risk.class); + } + + /** @return known Risk values. */ + public static Collection values() { + return values(Risk.class); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Scenario.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Scenario.java new file mode 100644 index 000000000000..7b8532f41934 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Scenario.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for Scenario. */ +public final class Scenario extends ExpandableStringEnum { + /** Static value Alerts for Scenario. */ + public static final Scenario ALERTS = fromString("Alerts"); + + /** + * Creates or finds a Scenario from its string representation. + * + * @param name a name to look for. + * @return the corresponding Scenario. + */ + @JsonCreator + public static Scenario fromString(String name) { + return fromString(name, Scenario.class); + } + + /** @return known Scenario values. */ + public static Collection values() { + return values(Scenario.class); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ShortDescription.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ShortDescription.java new file mode 100644 index 000000000000..85a737eb694a --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ShortDescription.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** A summary of the recommendation. */ +@Fluent +public final class ShortDescription { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ShortDescription.class); + + /* + * The issue or opportunity identified by the recommendation. + */ + @JsonProperty(value = "problem") + private String problem; + + /* + * The remediation action suggested by the recommendation. + */ + @JsonProperty(value = "solution") + private String solution; + + /** + * Get the problem property: The issue or opportunity identified by the recommendation. + * + * @return the problem value. + */ + public String problem() { + return this.problem; + } + + /** + * Set the problem property: The issue or opportunity identified by the recommendation. + * + * @param problem the problem value to set. + * @return the ShortDescription object itself. + */ + public ShortDescription withProblem(String problem) { + this.problem = problem; + return this; + } + + /** + * Get the solution property: The remediation action suggested by the recommendation. + * + * @return the solution value. + */ + public String solution() { + return this.solution; + } + + /** + * Set the solution property: The remediation action suggested by the recommendation. + * + * @param solution the solution value to set. + * @return the ShortDescription object itself. + */ + public ShortDescription withSolution(String solution) { + this.solution = solution; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/SuppressionContract.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/SuppressionContract.java new file mode 100644 index 000000000000..b0d8089db6ae --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/SuppressionContract.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; +import java.time.OffsetDateTime; + +/** An immutable client-side representation of SuppressionContract. */ +public interface SuppressionContract { + /** + * 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 suppressionId property: The GUID of the suppression. + * + * @return the suppressionId value. + */ + String suppressionId(); + + /** + * Gets the ttl property: The duration for which the suppression is valid. + * + * @return the ttl value. + */ + String ttl(); + + /** + * Gets the expirationTimestamp property: Gets or sets the expiration time stamp. + * + * @return the expirationTimestamp value. + */ + OffsetDateTime expirationTimestamp(); + + /** + * Gets the inner com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner object. + * + * @return the inner object. + */ + SuppressionContractInner innerModel(); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/SuppressionContractListResult.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/SuppressionContractListResult.java new file mode 100644 index 000000000000..4759dc3345e3 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/SuppressionContractListResult.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The list of Advisor suppressions. */ +@Fluent +public final class SuppressionContractListResult { + @JsonIgnore private final ClientLogger logger = new ClientLogger(SuppressionContractListResult.class); + + /* + * The link used to get the next page of suppressions. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /* + * The list of suppressions. + */ + @JsonProperty(value = "value") + private List value; + + /** + * Get the nextLink property: The link used to get the next page of suppressions. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link used to get the next page of suppressions. + * + * @param nextLink the nextLink value to set. + * @return the SuppressionContractListResult object itself. + */ + public SuppressionContractListResult withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Get the value property: The list of suppressions. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The list of suppressions. + * + * @param value the value value to set. + * @return the SuppressionContractListResult object itself. + */ + public SuppressionContractListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Suppressions.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Suppressions.java new file mode 100644 index 000000000000..45cb42acb06e --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Suppressions.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.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.advisor.fluent.models.SuppressionContractInner; + +/** Resource collection API of Suppressions. */ +public interface Suppressions { + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + SuppressionContract get(String resourceUri, String recommendationId, String name); + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + Response getWithResponse( + String resourceUri, String recommendationId, String name, Context context); + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to + * as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The details of the snoozed or dismissed rule; for example, the duration, name, and + * GUID associated with the rule. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + SuppressionContract create( + String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract); + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to + * as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The details of the snoozed or dismissed rule; for example, the duration, name, and + * GUID associated with the rule. + * @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 details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with + * the rule. + */ + Response createWithResponse( + String resourceUri, + String recommendationId, + String name, + SuppressionContractInner suppressionContract, + Context context); + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a + * recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @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, String recommendationId, String name); + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a + * recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the + * recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + Response deleteWithResponse(String resourceUri, String recommendationId, String name, Context context); + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + PagedIterable list(); + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of + * a recommendation is referred to as a suppression. + * + * @param top The number of suppressions per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of Advisor suppressions. + */ + PagedIterable list(Integer top, String skipToken, Context context); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/package-info.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/package-info.java new file mode 100644 index 000000000000..ecd0b9d76f93 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the data models for AdvisorManagementClient. REST APIs for Azure Advisor. */ +package com.azure.resourcemanager.advisor.models; diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/package-info.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/package-info.java new file mode 100644 index 000000000000..afbe5cce63d0 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the classes for AdvisorManagementClient. REST APIs for Azure Advisor. */ +package com.azure.resourcemanager.advisor; diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/module-info.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/module-info.java new file mode 100644 index 000000000000..a3210b22e261 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/module-info.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.resourcemanager.advisor { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.advisor; + exports com.azure.resourcemanager.advisor.fluent; + exports com.azure.resourcemanager.advisor.fluent.models; + exports com.azure.resourcemanager.advisor.models; + + opens com.azure.resourcemanager.advisor.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.advisor.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/advisor/ci.yml b/sdk/advisor/ci.yml new file mode 100644 index 000000000000..e19ded40ccd9 --- /dev/null +++ b/sdk/advisor/ci.yml @@ -0,0 +1,31 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - master + - hotfix/* + - release/* + paths: + include: + - sdk/advisor/ + +pr: + branches: + include: + - master + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/advisor/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: advisor + Artifacts: + - name: azure-resourcemanager-advisor + groupId: com.azure.resourcemanager + safeName: azureresourcemanageradvisor diff --git a/sdk/advisor/pom.xml b/sdk/advisor/pom.xml new file mode 100644 index 000000000000..e05c24783ea6 --- /dev/null +++ b/sdk/advisor/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + com.azure + azure-advisor-service + pom + 1.0.0 + + azure-resourcemanager-advisor + +