diff --git a/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md b/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md index 2bebf105e041..843004d37176 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md +++ b/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md @@ -1,6 +1,8 @@ # Release History -## 1.0.0-beta.3 (Unreleased) +## 1.0.0-beta.1 (2024-10-07) + +- 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-2023-01. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). ### Features Added diff --git a/sdk/advisor/azure-resourcemanager-advisor/README.md b/sdk/advisor/azure-resourcemanager-advisor/README.md index a4feca030eb9..4ad30821d42a 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/README.md +++ b/sdk/advisor/azure-resourcemanager-advisor/README.md @@ -2,7 +2,7 @@ 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). +This package contains Microsoft Azure SDK for Advisor Management SDK. REST APIs for Azure Advisor. Package tag package-2023-01. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). ## We'd love to hear your feedback @@ -32,7 +32,7 @@ Various documentation is available to help you get started com.azure.resourcemanager azure-resourcemanager-advisor - 1.0.0-beta.2 + 1.0.0-beta.3 ``` [//]: # ({x-version-update-end}) @@ -45,15 +45,11 @@ Azure Management Libraries require a `TokenCredential` implementation for authen ### Authentication -By default, Azure Active Directory token authentication depends on correct configuration of the following environment variables. +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. -- `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. +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. -In addition, Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. - -With above configuration, `azure` client can be authenticated using the following code: +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: ```java AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); @@ -94,12 +90,15 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m [survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS [docs]: https://azure.github.io/azure-sdk-for-java/ -[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ [azure_subscription]: https://azure.microsoft.com/free/ [azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials [azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty [authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md [design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md [cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md [coc]: https://opensource.microsoft.com/codeofconduct/ [coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fadvisor%2Fazure-resourcemanager-advisor%2FREADME.png) diff --git a/sdk/advisor/azure-resourcemanager-advisor/SAMPLE.md b/sdk/advisor/azure-resourcemanager-advisor/SAMPLE.md index d22c5ee23864..6b51b321025b 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/SAMPLE.md +++ b/sdk/advisor/azure-resourcemanager-advisor/SAMPLE.md @@ -1,6 +1,11 @@ # Code snippets and samples +## AdvisorScores + +- [Get](#advisorscores_get) +- [List](#advisorscores_list) + ## Configurations - [CreateInResourceGroup](#configurations_createinresourcegroup) @@ -24,12 +29,60 @@ - [GetGenerateStatus](#recommendations_getgeneratestatus) - [List](#recommendations_list) +## ResourceProvider + +- [Predict](#resourceprovider_predict) + ## Suppressions - [Create](#suppressions_create) - [Delete](#suppressions_delete) - [Get](#suppressions_get) - [List](#suppressions_list) +### AdvisorScores_Get + +```java +/** + * Samples for AdvisorScores Get. + */ +public final class AdvisorScoresGetSamples { + /* + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/GetAdvisorScoreDetail.json + */ + /** + * Sample code: GetAdvisorScoreDetail. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getAdvisorScoreDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.advisorScores().getWithResponse("Cost", com.azure.core.util.Context.NONE); + } +} +``` + +### AdvisorScores_List + +```java +/** + * Samples for AdvisorScores List. + */ +public final class AdvisorScoresListSamples { + /* + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListAdvisorScore.json + */ + /** + * Sample code: ListAdvisorScore. + * + * @param manager Entry point to AdvisorManager. + */ + public static void listAdvisorScore(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.advisorScores().listWithResponse(com.azure.core.util.Context.NONE); + } +} +``` + ### Configurations_CreateInResourceGroup ```java @@ -38,43 +91,37 @@ import com.azure.resourcemanager.advisor.models.ConfigurationName; import com.azure.resourcemanager.advisor.models.CpuThreshold; import com.azure.resourcemanager.advisor.models.DigestConfig; import com.azure.resourcemanager.advisor.models.DigestConfigState; +import com.azure.resourcemanager.advisor.models.DurationModel; import java.util.Arrays; -/** Samples for Configurations CreateInResourceGroup. */ +/** + * Samples for Configurations CreateInResourceGroup. + */ public final class ConfigurationsCreateInResourceGroupSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateConfiguration.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/CreateConfiguration.json */ /** * Sample code: PutConfigurations. - * + * * @param manager Entry point to AdvisorManager. */ public static void putConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .configurations() + manager.configurations() .define(ConfigurationName.DEFAULT) .withExistingResourceGroup("resourceGroup") .withExclude(true) .withLowCpuThreshold(CpuThreshold.FIVE) - .withDigests( - Arrays - .asList( - new DigestConfig() - .withName("digestConfigName") - .withActionGroupResourceId( - "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName") - .withFrequency(30) - .withCategories( - Arrays - .asList( - Category.HIGH_AVAILABILITY, - Category.SECURITY, - Category.PERFORMANCE, - Category.COST, - Category.OPERATIONAL_EXCELLENCE)) - .withLanguage("en") - .withState(DigestConfigState.ACTIVE))) + .withDuration(DurationModel.SEVEN) + .withDigests(Arrays.asList(new DigestConfig().withName("digestConfigName") + .withActionGroupResourceId( + "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName") + .withFrequency(30) + .withCategories(Arrays.asList(Category.HIGH_AVAILABILITY, Category.SECURITY, Category.PERFORMANCE, + Category.COST, Category.OPERATIONAL_EXCELLENCE)) + .withLanguage("en") + .withState(DigestConfigState.ACTIVE))) .create(); } } @@ -89,44 +136,35 @@ import com.azure.resourcemanager.advisor.models.ConfigurationName; import com.azure.resourcemanager.advisor.models.CpuThreshold; import com.azure.resourcemanager.advisor.models.DigestConfig; import com.azure.resourcemanager.advisor.models.DigestConfigState; +import com.azure.resourcemanager.advisor.models.DurationModel; import java.util.Arrays; -/** Samples for Configurations CreateInSubscription. */ +/** + * Samples for Configurations CreateInSubscription. + */ public final class ConfigurationsCreateInSubscriptionSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateConfiguration.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/CreateConfiguration.json */ /** * Sample code: PutConfigurations. - * + * * @param manager Entry point to AdvisorManager. */ public static void putConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .configurations() - .createInSubscriptionWithResponse( - ConfigurationName.DEFAULT, - new ConfigDataInner() - .withExclude(true) - .withLowCpuThreshold(CpuThreshold.FIVE) - .withDigests( - Arrays - .asList( - new DigestConfig() - .withName("digestConfigName") - .withActionGroupResourceId( - "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName") - .withFrequency(30) - .withCategories( - Arrays - .asList( - Category.HIGH_AVAILABILITY, - Category.SECURITY, - Category.PERFORMANCE, - Category.COST, - Category.OPERATIONAL_EXCELLENCE)) - .withLanguage("en") - .withState(DigestConfigState.ACTIVE))), + manager.configurations() + .createInSubscriptionWithResponse(ConfigurationName.DEFAULT, new ConfigDataInner().withExclude(true) + .withLowCpuThreshold(CpuThreshold.FIVE) + .withDuration(DurationModel.SEVEN) + .withDigests(Arrays.asList(new DigestConfig().withName("digestConfigName") + .withActionGroupResourceId( + "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName") + .withFrequency(30) + .withCategories(Arrays.asList(Category.HIGH_AVAILABILITY, Category.SECURITY, Category.PERFORMANCE, + Category.COST, Category.OPERATIONAL_EXCELLENCE)) + .withLanguage("en") + .withState(DigestConfigState.ACTIVE))), com.azure.core.util.Context.NONE); } } @@ -135,14 +173,17 @@ public final class ConfigurationsCreateInSubscriptionSamples { ### Configurations_List ```java -/** Samples for Configurations List. */ +/** + * Samples for Configurations List. + */ public final class ConfigurationsListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListConfigurations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListConfigurations.json */ /** * Sample code: GetConfigurations. - * + * * @param manager Entry point to AdvisorManager. */ public static void getConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { @@ -154,14 +195,17 @@ public final class ConfigurationsListSamples { ### Configurations_ListByResourceGroup ```java -/** Samples for Configurations ListByResourceGroup. */ +/** + * Samples for Configurations ListByResourceGroup. + */ public final class ConfigurationsListByResourceGroupSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListConfigurations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListConfigurations.json */ /** * Sample code: GetConfigurations. - * + * * @param manager Entry point to AdvisorManager. */ public static void getConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { @@ -173,17 +217,20 @@ public final class ConfigurationsListByResourceGroupSamples { ### Operations_List ```java -/** Samples for Operations List. */ +/** + * Samples for Operations List. + */ public final class OperationsListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListOperations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/OperationsList.json */ /** - * Sample code: ListRecommendations. - * + * Sample code: OperationsList. + * * @param manager Entry point to AdvisorManager. */ - public static void listRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + public static void operationsList(com.azure.resourcemanager.advisor.AdvisorManager manager) { manager.operations().list(com.azure.core.util.Context.NONE); } } @@ -192,14 +239,17 @@ public final class OperationsListSamples { ### RecommendationMetadata_Get ```java -/** Samples for RecommendationMetadata Get. */ +/** + * Samples for RecommendationMetadata Get. + */ public final class RecommendationMetadataGetSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetRecommendationMetadataEntity.json + * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ + * GetRecommendationMetadataEntity.json */ /** * Sample code: GetMetadata. - * + * * @param manager Entry point to AdvisorManager. */ public static void getMetadata(com.azure.resourcemanager.advisor.AdvisorManager manager) { @@ -211,14 +261,18 @@ public final class RecommendationMetadataGetSamples { ### RecommendationMetadata_List ```java -/** Samples for RecommendationMetadata List. */ +/** + * Samples for RecommendationMetadata List. + */ public final class RecommendationMetadataListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListRecommendationMetadata.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListRecommendationMetadata. + * json */ /** * Sample code: GetMetadata. - * + * * @param manager Entry point to AdvisorManager. */ public static void getMetadata(com.azure.resourcemanager.advisor.AdvisorManager manager) { @@ -230,14 +284,17 @@ public final class RecommendationMetadataListSamples { ### Recommendations_Generate ```java -/** Samples for Recommendations Generate. */ +/** + * Samples for Recommendations Generate. + */ public final class RecommendationsGenerateSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GenerateRecommendations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/GenerateRecommendations.json */ /** * Sample code: GenerateRecommendations. - * + * * @param manager Entry point to AdvisorManager. */ public static void generateRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { @@ -249,14 +306,17 @@ public final class RecommendationsGenerateSamples { ### Recommendations_Get ```java -/** Samples for Recommendations Get. */ +/** + * Samples for Recommendations Get. + */ public final class RecommendationsGetSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetRecommendationDetail.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/GetRecommendationDetail.json */ /** * Sample code: GetRecommendationDetail. - * + * * @param manager Entry point to AdvisorManager. */ public static void getRecommendationDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { @@ -270,21 +330,23 @@ public final class RecommendationsGetSamples { ```java import java.util.UUID; -/** Samples for Recommendations GetGenerateStatus. */ +/** + * Samples for Recommendations GetGenerateStatus. + */ public final class RecommendationsGetGenerateStatusSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/EmptyResponse.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/EmptyResponse.json */ /** * Sample code: GetGenerateStatus. - * + * * @param manager Entry point to AdvisorManager. */ public static void getGenerateStatus(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .recommendations() - .getGenerateStatusWithResponse( - UUID.fromString("00000000-0000-0000-0000-000000000000"), com.azure.core.util.Context.NONE); + manager.recommendations() + .getGenerateStatusWithResponse(UUID.fromString("123e4567-e89b-12d3-a456-426614174000"), + com.azure.core.util.Context.NONE); } } ``` @@ -292,14 +354,17 @@ public final class RecommendationsGetGenerateStatusSamples { ### Recommendations_List ```java -/** Samples for Recommendations List. */ +/** + * Samples for Recommendations List. + */ public final class RecommendationsListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListRecommendations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListRecommendations.json */ /** * Sample code: ListRecommendations. - * + * * @param manager Entry point to AdvisorManager. */ public static void listRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { @@ -308,22 +373,58 @@ public final class RecommendationsListSamples { } ``` +### ResourceProvider_Predict + +```java +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.advisor.models.PredictionRequest; +import com.azure.resourcemanager.advisor.models.PredictionType; +import java.io.IOException; + +/** + * Samples for ResourceProvider Predict. + */ +public final class ResourceProviderPredictSamples { + /* + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/Predict.json + */ + /** + * Sample code: Predict. + * + * @param manager Entry point to AdvisorManager. + */ + public static void predict(com.azure.resourcemanager.advisor.AdvisorManager manager) throws IOException { + manager.resourceProviders() + .predictWithResponse(new PredictionRequest().withPredictionType(PredictionType.PREDICTIVE_RIGHTSIZING) + .withExtendedProperties(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize( + "{\"type\":\"iaas\",\"deploymentType\":\"Linux_IaaS_Software_Store\",\"numberOfInstances\":10,\"region\":\"CentralUS\",\"sku\":\"Standard_Dv4\"}", + Object.class, SerializerEncoding.JSON)), + com.azure.core.util.Context.NONE); + } +} +``` + ### Suppressions_Create ```java -/** Samples for Suppressions Create. */ +/** + * Samples for Suppressions Create. + */ public final class SuppressionsCreateSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateSuppression.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/CreateSuppression.json */ /** * Sample code: CreateSuppression. - * + * * @param manager Entry point to AdvisorManager. */ public static void createSuppression(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .suppressions() + manager.suppressions() .define("suppressionName1") .withExistingRecommendation("resourceUri", "recommendationId") .withTtl("07:00:00:00") @@ -335,21 +436,23 @@ public final class SuppressionsCreateSamples { ### Suppressions_Delete ```java -/** Samples for Suppressions Delete. */ +/** + * Samples for Suppressions Delete. + */ public final class SuppressionsDeleteSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/DeleteSuppression.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/DeleteSuppression.json */ /** * Sample code: DeleteSuppression. - * + * * @param manager Entry point to AdvisorManager. */ public static void deleteSuppression(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .suppressions() - .deleteWithResponse( - "resourceUri", "recommendationId", "suppressionName1", com.azure.core.util.Context.NONE); + manager.suppressions() + .deleteWithResponse("resourceUri", "recommendationId", "suppressionName1", + com.azure.core.util.Context.NONE); } } ``` @@ -357,19 +460,21 @@ public final class SuppressionsDeleteSamples { ### Suppressions_Get ```java -/** Samples for Suppressions Get. */ +/** + * Samples for Suppressions Get. + */ public final class SuppressionsGetSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetSuppressionDetail.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/GetSuppressionDetail.json */ /** * Sample code: GetSuppressionDetail. - * + * * @param manager Entry point to AdvisorManager. */ public static void getSuppressionDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .suppressions() + manager.suppressions() .getWithResponse("resourceUri", "recommendationId", "suppressionName1", com.azure.core.util.Context.NONE); } } @@ -378,14 +483,17 @@ public final class SuppressionsGetSamples { ### Suppressions_List ```java -/** Samples for Suppressions List. */ +/** + * Samples for Suppressions List. + */ public final class SuppressionsListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListSuppressions.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListSuppressions.json */ /** * Sample code: ListSuppressions. - * + * * @param manager Entry point to AdvisorManager. */ public static void listSuppressions(com.azure.resourcemanager.advisor.AdvisorManager manager) { diff --git a/sdk/advisor/azure-resourcemanager-advisor/pom.xml b/sdk/advisor/azure-resourcemanager-advisor/pom.xml index 6f2384d63eba..a576ddd615cc 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/pom.xml +++ b/sdk/advisor/azure-resourcemanager-advisor/pom.xml @@ -1,3 +1,8 @@ + 4.0.0 @@ -13,7 +18,7 @@ jar Microsoft Azure SDK for Advisor Management - This package contains Microsoft Azure SDK for Advisor Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. REST APIs for Azure Advisor. Package tag package-2020-01. + This package contains Microsoft Azure SDK for Advisor Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. REST APIs for Azure Advisor. Package tag package-2023-01. https://github.com/Azure/azure-sdk-for-java @@ -38,8 +43,10 @@ UTF-8 - true - - + 0 + 0 + true + false @@ -57,12 +64,6 @@ azure-core-test 1.27.0-beta.2 test - - - com.azure - azure-core-http-jdk-httpclient - - com.azure @@ -76,8 +77,6 @@ 4.11.0 test - - net.bytebuddy byte-buddy 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 index 154be7aa65e5..0a2a6bd391fd 100644 --- 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 @@ -25,15 +25,19 @@ 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.AdvisorScoresImpl; 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.ResourceProvidersImpl; import com.azure.resourcemanager.advisor.implementation.SuppressionsImpl; +import com.azure.resourcemanager.advisor.models.AdvisorScores; 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.ResourceProviders; import com.azure.resourcemanager.advisor.models.Suppressions; import java.time.Duration; import java.time.temporal.ChronoUnit; @@ -42,7 +46,10 @@ import java.util.Objects; import java.util.stream.Collectors; -/** Entry point to AdvisorManager. REST APIs for Azure Advisor. */ +/** + * Entry point to AdvisorManager. + * REST APIs for Azure Advisor. + */ public final class AdvisorManager { private RecommendationMetadatas recommendationMetadatas; @@ -54,23 +61,25 @@ public final class AdvisorManager { private Suppressions suppressions; + private ResourceProviders resourceProviders; + + private AdvisorScores advisorScores; + 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(); + 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. @@ -83,7 +92,7 @@ public static AdvisorManager authenticate(TokenCredential credential, AzureProfi /** * Creates an instance of Advisor service API entry point. - * + * * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. * @param profile the Azure profile for client. * @return the Advisor service API instance. @@ -96,14 +105,16 @@ public static AdvisorManager authenticate(HttpPipeline httpPipeline, AzureProfil /** * 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. */ + /** + * The Configurable allowing configurations to be set. + */ public static final class Configurable { private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); @@ -175,8 +186,8 @@ public Configurable withRetryPolicy(RetryPolicy retryPolicy) { /** * Sets the retry options for the HTTP pipeline retry policy. - * - *

This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. * * @param retryOptions the retry options for the HTTP pipeline retry policy. * @return the configurable object itself. @@ -193,8 +204,8 @@ public Configurable withRetryOptions(RetryOptions retryOptions) { * @return the configurable object itself. */ public Configurable withDefaultPollInterval(Duration defaultPollInterval) { - this.defaultPollInterval = - Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); if (this.defaultPollInterval.isNegative()) { throw LOGGER .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); @@ -214,15 +225,13 @@ public AdvisorManager authenticate(TokenCredential credential, AzureProfile prof Objects.requireNonNull(profile, "'profile' cannot be null."); StringBuilder userAgentBuilder = new StringBuilder(); - userAgentBuilder - .append("azsdk-java") + userAgentBuilder.append("azsdk-java") .append("-") .append("com.azure.resourcemanager.advisor") .append("/") - .append("1.0.0-beta.2"); + .append("1.0.0-beta.1"); if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { - userAgentBuilder - .append(" (") + userAgentBuilder.append(" (") .append(Configuration.getGlobalConfiguration().get("java.version")) .append("; ") .append(Configuration.getGlobalConfiguration().get("os.name")) @@ -247,51 +256,41 @@ public AdvisorManager authenticate(TokenCredential credential, AzureProfile prof policies.add(new UserAgentPolicy(userAgentBuilder.toString())); policies.add(new AddHeadersFromContextPolicy()); policies.add(new RequestIdPolicy()); - policies - .addAll( - this - .policies - .stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .collect(Collectors.toList())); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new AddDatePolicy()); policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); - policies - .addAll( - this - .policies - .stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .collect(Collectors.toList())); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(httpLogOptions)); - HttpPipeline httpPipeline = - new HttpPipelineBuilder() - .httpClient(httpClient) - .policies(policies.toArray(new HttpPipelinePolicy[0])) - .build(); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); return new AdvisorManager(httpPipeline, profile, defaultPollInterval); } } /** * Gets the resource collection API of RecommendationMetadatas. - * + * * @return Resource collection API of RecommendationMetadatas. */ public RecommendationMetadatas recommendationMetadatas() { if (this.recommendationMetadatas == null) { - this.recommendationMetadatas = - new RecommendationMetadatasImpl(clientObject.getRecommendationMetadatas(), this); + this.recommendationMetadatas + = new RecommendationMetadatasImpl(clientObject.getRecommendationMetadatas(), this); } return recommendationMetadatas; } /** * Gets the resource collection API of Configurations. It manages ConfigData. - * + * * @return Resource collection API of Configurations. */ public Configurations configurations() { @@ -303,7 +302,7 @@ public Configurations configurations() { /** * Gets the resource collection API of Recommendations. - * + * * @return Resource collection API of Recommendations. */ public Recommendations recommendations() { @@ -315,7 +314,7 @@ public Recommendations recommendations() { /** * Gets the resource collection API of Operations. - * + * * @return Resource collection API of Operations. */ public Operations operations() { @@ -327,7 +326,7 @@ public Operations operations() { /** * Gets the resource collection API of Suppressions. It manages SuppressionContract. - * + * * @return Resource collection API of Suppressions. */ public Suppressions suppressions() { @@ -338,8 +337,34 @@ public Suppressions suppressions() { } /** - * @return Wrapped service client AdvisorManagementClient providing direct access to the underlying auto-generated - * API implementation, based on Azure REST API. + * Gets the resource collection API of ResourceProviders. + * + * @return Resource collection API of ResourceProviders. + */ + public ResourceProviders resourceProviders() { + if (this.resourceProviders == null) { + this.resourceProviders = new ResourceProvidersImpl(clientObject.getResourceProviders(), this); + } + return resourceProviders; + } + + /** + * Gets the resource collection API of AdvisorScores. + * + * @return Resource collection API of AdvisorScores. + */ + public AdvisorScores advisorScores() { + if (this.advisorScores == null) { + this.advisorScores = new AdvisorScoresImpl(clientObject.getAdvisorScores(), this); + } + return advisorScores; + } + + /** + * Gets wrapped service client AdvisorManagementClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client AdvisorManagementClient. */ 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 index 247423ce021c..0afd38ac26bf 100644 --- 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 @@ -7,75 +7,91 @@ import com.azure.core.http.HttpPipeline; import java.time.Duration; -/** The interface for AdvisorManagementClient class. */ +/** + * 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(); + + /** + * Gets the ResourceProvidersClient object to access its operations. + * + * @return the ResourceProvidersClient object. + */ + ResourceProvidersClient getResourceProviders(); + + /** + * Gets the AdvisorScoresClient object to access its operations. + * + * @return the AdvisorScoresClient object. + */ + AdvisorScoresClient getAdvisorScores(); } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/AdvisorScoresClient.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/AdvisorScoresClient.java new file mode 100644 index 000000000000..792a6f27854a --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/AdvisorScoresClient.java @@ -0,0 +1,64 @@ +// 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.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreEntityInner; +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreResponseInner; + +/** + * An instance of this class provides access to all the operations defined in AdvisorScoresClient. + */ +public interface AdvisorScoresClient { + /** + * Gets the list of advisor scores. + * + * @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 scores along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response listWithResponse(Context context); + + /** + * Gets the list of advisor scores. + * + * @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 scores. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AdvisorScoreResponseInner list(); + + /** + * Gets the advisor score. + * + * @param name The scope of Advisor score 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 advisor score along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String name, Context context); + + /** + * Gets the advisor score. + * + * @param name The scope of Advisor score 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 advisor score. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AdvisorScoreEntityInner get(String name); +} 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 index da4558e53845..0411e662bbaa 100644 --- 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 @@ -12,13 +12,15 @@ 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. */ +/** + * An instance of this class provides access to all the operations defined in ConfigurationsClient. + */ public interface ConfigurationsClient { /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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 as paginated response with {@link PagedIterable}. @@ -28,9 +30,9 @@ public interface ConfigurationsClient { /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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. @@ -42,9 +44,9 @@ public interface ConfigurationsClient { /** * Create/Overwrite Azure Advisor configuration. - * - *

Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. - * + * + * 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 Azure Advisor configuration data structure. * @param context The context to associate with this operation. @@ -54,14 +56,14 @@ public interface ConfigurationsClient { * @return the Advisor configuration data structure along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - Response createInSubscriptionWithResponse( - ConfigurationName configurationName, ConfigDataInner configContract, Context context); + Response createInSubscriptionWithResponse(ConfigurationName configurationName, + ConfigDataInner configContract, Context context); /** * Create/Overwrite Azure Advisor configuration. - * - *

Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. - * + * + * 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 Azure Advisor configuration data structure. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -74,7 +76,7 @@ Response createInSubscriptionWithResponse( /** * 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. @@ -86,7 +88,7 @@ Response createInSubscriptionWithResponse( /** * 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. @@ -99,7 +101,7 @@ Response createInSubscriptionWithResponse( /** * 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 Azure Advisor configuration data structure. @@ -110,12 +112,12 @@ Response createInSubscriptionWithResponse( * @return the Advisor configuration data structure along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - Response createInResourceGroupWithResponse( - ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract, Context context); + Response createInResourceGroupWithResponse(ConfigurationName configurationName, + String resourceGroup, ConfigDataInner configContract, 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 Azure Advisor configuration data structure. @@ -125,6 +127,6 @@ Response createInResourceGroupWithResponse( * @return the Advisor configuration data structure. */ @ServiceMethod(returns = ReturnType.SINGLE) - ConfigDataInner createInResourceGroup( - ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract); + ConfigDataInner createInResourceGroup(ConfigurationName configurationName, String resourceGroup, + ConfigDataInner configContract); } 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 index 207a500de026..ba316720abe0 100644 --- 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 @@ -10,11 +10,13 @@ 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. */ +/** + * 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 as paginated response with {@link PagedIterable}. @@ -24,7 +26,7 @@ public interface OperationsClient { /** * 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. 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 index 4a3d8846bb0e..f2e50ab0c401 100644 --- 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 @@ -11,15 +11,19 @@ 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. */ +/** + * 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. * @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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the metadata entity along with {@link Response}. */ @@ -28,10 +32,12 @@ 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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the metadata entity. */ @@ -40,7 +46,7 @@ public interface RecommendationMetadatasClient { /** * 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 as paginated response with {@link PagedIterable}. @@ -50,7 +56,7 @@ public interface RecommendationMetadatasClient { /** * 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. 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 index b3867c15a0da..67f03eb0353d 100644 --- 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 @@ -13,12 +13,14 @@ import com.azure.resourcemanager.advisor.models.RecommendationsGenerateResponse; import java.util.UUID; -/** An instance of this class provides access to all the operations defined in RecommendationsClient. */ +/** + * 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. - * + * * @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. @@ -31,7 +33,7 @@ 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. */ @@ -41,9 +43,9 @@ public interface RecommendationsClient { /** * 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. + * 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. @@ -56,9 +58,9 @@ public interface RecommendationsClient { /** * 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. + * 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. @@ -69,7 +71,7 @@ public interface RecommendationsClient { /** * 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 as paginated response with {@link PagedIterable}. @@ -80,10 +82,10 @@ public interface RecommendationsClient { /** * 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'. + * ['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. @@ -97,9 +99,9 @@ public interface RecommendationsClient { /** * Obtains details of a cached recommendation. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * recommendation applies. * @param recommendationId The recommendation ID. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -108,14 +110,14 @@ public interface RecommendationsClient { * @return advisor Recommendation along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - Response getWithResponse( - String resourceUri, String recommendationId, Context context); + Response getWithResponse(String resourceUri, String recommendationId, + 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. + * 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. diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/ResourceProvidersClient.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/ResourceProvidersClient.java new file mode 100644 index 000000000000..6db2a5723817 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/ResourceProvidersClient.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.advisor.fluent.models.PredictionResponseInner; +import com.azure.resourcemanager.advisor.models.PredictionRequest; + +/** + * An instance of this class provides access to all the operations defined in ResourceProvidersClient. + */ +public interface ResourceProvidersClient { + /** + * Predicts a recommendation. + * + * @param predictionRequest Parameters for predict recommendation. + * @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 response used by predictions along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response predictWithResponse(PredictionRequest predictionRequest, Context context); + + /** + * Predicts a recommendation. + * + * @param predictionRequest Parameters for predict recommendation. + * @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 response used by predictions. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + PredictionResponseInner predict(PredictionRequest predictionRequest); +} 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 index 8bf20b370fb7..697364534b8a 100644 --- 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 @@ -11,38 +11,44 @@ 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. */ +/** + * 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. + * 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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @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 along with {@link Response}. + * the rule along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - Response getWithResponse( - String resourceUri, String recommendationId, String name, Context context); + Response getWithResponse(String resourceUri, String recommendationId, String name, + 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. + * 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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @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. + * the rule. */ @ServiceMethod(returns = ReturnType.SINGLE) SuppressionContractInner get(String resourceUri, String recommendationId, String name); @@ -50,52 +56,52 @@ Response getWithResponse( /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. * @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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @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 along with {@link Response}. + * the rule along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - Response createWithResponse( - String resourceUri, - String recommendationId, - String name, - SuppressionContractInner suppressionContract, - Context context); + Response createWithResponse(String resourceUri, String recommendationId, String name, + SuppressionContractInner suppressionContract, 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @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. + * the rule. */ @ServiceMethod(returns = ReturnType.SINGLE) - SuppressionContractInner create( - String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract); + SuppressionContractInner create(String resourceUri, String recommendationId, String name, + SuppressionContractInner suppressionContract); /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param context The context to associate with this operation. @@ -110,9 +116,9 @@ SuppressionContractInner create( /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -125,7 +131,7 @@ SuppressionContractInner create( /** * 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 as paginated response with {@link PagedIterable}. @@ -136,7 +142,7 @@ SuppressionContractInner create( /** * 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. diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/AdvisorScoreEntityInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/AdvisorScoreEntityInner.java new file mode 100644 index 000000000000..bec5a787f319 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/AdvisorScoreEntityInner.java @@ -0,0 +1,166 @@ +// 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.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.advisor.models.AdvisorScoreEntityProperties; +import java.io.IOException; + +/** + * The details of Advisor score for a single category. + */ +@Fluent +public final class AdvisorScoreEntityInner extends ProxyResource { + /* + * The Advisor score data. + */ + private AdvisorScoreEntityProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of AdvisorScoreEntityInner class. + */ + public AdvisorScoreEntityInner() { + } + + /** + * Get the properties property: The Advisor score data. + * + * @return the properties value. + */ + public AdvisorScoreEntityProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The Advisor score data. + * + * @param properties the properties value to set. + * @return the AdvisorScoreEntityInner object itself. + */ + public AdvisorScoreEntityInner withProperties(AdvisorScoreEntityProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AdvisorScoreEntityInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AdvisorScoreEntityInner if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AdvisorScoreEntityInner. + */ + public static AdvisorScoreEntityInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AdvisorScoreEntityInner deserializedAdvisorScoreEntityInner = new AdvisorScoreEntityInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedAdvisorScoreEntityInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedAdvisorScoreEntityInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedAdvisorScoreEntityInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedAdvisorScoreEntityInner.properties = AdvisorScoreEntityProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedAdvisorScoreEntityInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAdvisorScoreEntityInner; + }); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/AdvisorScoreResponseInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/AdvisorScoreResponseInner.java new file mode 100644 index 000000000000..c00b56e2ed48 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/AdvisorScoreResponseInner.java @@ -0,0 +1,99 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The AdvisorScoreResponse model. + */ +@Fluent +public final class AdvisorScoreResponseInner implements JsonSerializable { + /* + * The list of operations. + */ + private List value; + + /** + * Creates an instance of AdvisorScoreResponseInner class. + */ + public AdvisorScoreResponseInner() { + } + + /** + * 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 AdvisorScoreResponseInner object itself. + */ + public AdvisorScoreResponseInner 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()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AdvisorScoreResponseInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AdvisorScoreResponseInner if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the AdvisorScoreResponseInner. + */ + public static AdvisorScoreResponseInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AdvisorScoreResponseInner deserializedAdvisorScoreResponseInner = new AdvisorScoreResponseInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> AdvisorScoreEntityInner.fromJson(reader1)); + deserializedAdvisorScoreResponseInner.value = value; + } else { + reader.skipChildren(); + } + } + + return deserializedAdvisorScoreResponseInner; + }); + } +} 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 index 3f877b5e763e..981d910fbbaf 100644 --- 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 @@ -6,36 +6,103 @@ import com.azure.core.annotation.Fluent; import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.models.CpuThreshold; import com.azure.resourcemanager.advisor.models.DigestConfig; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.resourcemanager.advisor.models.DurationModel; +import java.io.IOException; import java.util.List; -/** The Advisor configuration data structure. */ +/** + * The Advisor configuration data structure. + */ @Fluent public final class ConfigDataInner extends ProxyResource { /* * The Advisor configuration data structure. */ - @JsonProperty(value = "properties") private ConfigDataProperties innerProperties; - /** Creates an instance of ConfigDataInner class. */ + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of ConfigDataInner class. + */ public ConfigDataInner() { } /** * Get the innerProperties property: The Advisor configuration data structure. - * + * * @return the innerProperties value. */ private ConfigDataProperties innerProperties() { return this.innerProperties; } + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + /** * Get the exclude property: Exclude the resource from Advisor evaluations. Valid values: False (default) or True. - * + * * @return the exclude value. */ public Boolean exclude() { @@ -44,7 +111,7 @@ public Boolean 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. */ @@ -59,7 +126,7 @@ public ConfigDataInner withExclude(Boolean exclude) { /** * 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() { @@ -69,7 +136,7 @@ public CpuThreshold 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. */ @@ -81,9 +148,34 @@ public ConfigDataInner withLowCpuThreshold(CpuThreshold lowCpuThreshold) { return this; } + /** + * Get the duration property: Minimum duration for Advisor low CPU utilization evaluation. Valid only for + * subscriptions. Valid values: 7 (default), 14, 21, 30, 60 or 90. + * + * @return the duration value. + */ + public DurationModel duration() { + return this.innerProperties() == null ? null : this.innerProperties().duration(); + } + + /** + * Set the duration property: Minimum duration for Advisor low CPU utilization evaluation. Valid only for + * subscriptions. Valid values: 7 (default), 14, 21, 30, 60 or 90. + * + * @param duration the duration value to set. + * @return the ConfigDataInner object itself. + */ + public ConfigDataInner withDuration(DurationModel duration) { + if (this.innerProperties() == null) { + this.innerProperties = new ConfigDataProperties(); + } + this.innerProperties().withDuration(duration); + return this; + } + /** * Get the digests property: Advisor digest configuration. Valid only for subscriptions. - * + * * @return the digests value. */ public List digests() { @@ -92,7 +184,7 @@ public List digests() { /** * Set the digests property: Advisor digest configuration. Valid only for subscriptions. - * + * * @param digests the digests value to set. * @return the ConfigDataInner object itself. */ @@ -106,7 +198,7 @@ public ConfigDataInner withDigests(List digests) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { @@ -114,4 +206,49 @@ public void validate() { innerProperties().validate(); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ConfigDataInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ConfigDataInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ConfigDataInner. + */ + public static ConfigDataInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ConfigDataInner deserializedConfigDataInner = new ConfigDataInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedConfigDataInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedConfigDataInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedConfigDataInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedConfigDataInner.innerProperties = ConfigDataProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedConfigDataInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedConfigDataInner; + }); + } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ConfigDataProperties.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ConfigDataProperties.java index e2d8a76caac5..7212275dfb5e 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ConfigDataProperties.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ConfigDataProperties.java @@ -5,40 +5,52 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.models.CpuThreshold; import com.azure.resourcemanager.advisor.models.DigestConfig; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.resourcemanager.advisor.models.DurationModel; +import java.io.IOException; import java.util.List; -/** Configuration data properties. */ +/** + * Configuration data properties. + */ @Fluent -public final class ConfigDataProperties { +public final class ConfigDataProperties implements JsonSerializable { /* * Exclude the resource from Advisor evaluations. Valid values: False (default) or True. */ - @JsonProperty(value = "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 = "lowCpuThreshold") private CpuThreshold lowCpuThreshold; + /* + * Minimum duration for Advisor low CPU utilization evaluation. Valid only for subscriptions. Valid values: 7 + * (default), 14, 21, 30, 60 or 90. + */ + private DurationModel duration; + /* * Advisor digest configuration. Valid only for subscriptions */ - @JsonProperty(value = "digests") private List digests; - /** Creates an instance of ConfigDataProperties class. */ + /** + * Creates an instance of ConfigDataProperties class. + */ public ConfigDataProperties() { } /** * Get the exclude property: Exclude the resource from Advisor evaluations. Valid values: False (default) or True. - * + * * @return the exclude value. */ public Boolean exclude() { @@ -47,7 +59,7 @@ public Boolean 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 ConfigDataProperties object itself. */ @@ -59,7 +71,7 @@ public ConfigDataProperties withExclude(Boolean exclude) { /** * 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() { @@ -69,7 +81,7 @@ public CpuThreshold 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 ConfigDataProperties object itself. */ @@ -78,9 +90,31 @@ public ConfigDataProperties withLowCpuThreshold(CpuThreshold lowCpuThreshold) { return this; } + /** + * Get the duration property: Minimum duration for Advisor low CPU utilization evaluation. Valid only for + * subscriptions. Valid values: 7 (default), 14, 21, 30, 60 or 90. + * + * @return the duration value. + */ + public DurationModel duration() { + return this.duration; + } + + /** + * Set the duration property: Minimum duration for Advisor low CPU utilization evaluation. Valid only for + * subscriptions. Valid values: 7 (default), 14, 21, 30, 60 or 90. + * + * @param duration the duration value to set. + * @return the ConfigDataProperties object itself. + */ + public ConfigDataProperties withDuration(DurationModel duration) { + this.duration = duration; + return this; + } + /** * Get the digests property: Advisor digest configuration. Valid only for subscriptions. - * + * * @return the digests value. */ public List digests() { @@ -89,7 +123,7 @@ public List digests() { /** * Set the digests property: Advisor digest configuration. Valid only for subscriptions. - * + * * @param digests the digests value to set. * @return the ConfigDataProperties object itself. */ @@ -100,7 +134,7 @@ public ConfigDataProperties withDigests(List digests) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { @@ -108,4 +142,51 @@ public void validate() { digests().forEach(e -> e.validate()); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("exclude", this.exclude); + jsonWriter.writeStringField("lowCpuThreshold", + this.lowCpuThreshold == null ? null : this.lowCpuThreshold.toString()); + jsonWriter.writeStringField("duration", this.duration == null ? null : this.duration.toString()); + jsonWriter.writeArrayField("digests", this.digests, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ConfigDataProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ConfigDataProperties if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the ConfigDataProperties. + */ + public static ConfigDataProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ConfigDataProperties deserializedConfigDataProperties = new ConfigDataProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("exclude".equals(fieldName)) { + deserializedConfigDataProperties.exclude = reader.getNullable(JsonReader::getBoolean); + } else if ("lowCpuThreshold".equals(fieldName)) { + deserializedConfigDataProperties.lowCpuThreshold = CpuThreshold.fromString(reader.getString()); + } else if ("duration".equals(fieldName)) { + deserializedConfigDataProperties.duration = DurationModel.fromString(reader.getString()); + } else if ("digests".equals(fieldName)) { + List digests = reader.readArray(reader1 -> DigestConfig.fromJson(reader1)); + deserializedConfigDataProperties.digests = digests; + } else { + reader.skipChildren(); + } + } + + return deserializedConfigDataProperties; + }); + } } 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 index 3aadf5667be7..1c323dd233c4 100644 --- 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 @@ -5,45 +5,49 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.models.MetadataSupportedValueDetail; import com.azure.resourcemanager.advisor.models.Scenario; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; import java.util.List; -/** The metadata entity contract. */ +/** + * The metadata entity contract. + */ @Fluent -public final class MetadataEntityInner { +public final class MetadataEntityInner implements JsonSerializable { /* * 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 metadata entity properties. */ - @JsonProperty(value = "properties") private MetadataEntityProperties innerProperties; - /** Creates an instance of MetadataEntityInner class. */ + /** + * Creates an instance of MetadataEntityInner class. + */ public MetadataEntityInner() { } /** * Get the id property: The resource Id of the metadata entity. - * + * * @return the id value. */ public String id() { @@ -52,7 +56,7 @@ public String id() { /** * Set the id property: The resource Id of the metadata entity. - * + * * @param id the id value to set. * @return the MetadataEntityInner object itself. */ @@ -63,7 +67,7 @@ public MetadataEntityInner withId(String id) { /** * Get the type property: The type of the metadata entity. - * + * * @return the type value. */ public String type() { @@ -72,7 +76,7 @@ public String type() { /** * Set the type property: The type of the metadata entity. - * + * * @param type the type value to set. * @return the MetadataEntityInner object itself. */ @@ -83,7 +87,7 @@ public MetadataEntityInner withType(String type) { /** * Get the name property: The name of the metadata entity. - * + * * @return the name value. */ public String name() { @@ -92,7 +96,7 @@ public String name() { /** * Set the name property: The name of the metadata entity. - * + * * @param name the name value to set. * @return the MetadataEntityInner object itself. */ @@ -103,7 +107,7 @@ public MetadataEntityInner withName(String name) { /** * Get the innerProperties property: The metadata entity properties. - * + * * @return the innerProperties value. */ private MetadataEntityProperties innerProperties() { @@ -112,7 +116,7 @@ private MetadataEntityProperties innerProperties() { /** * Get the displayName property: The display name. - * + * * @return the displayName value. */ public String displayName() { @@ -121,7 +125,7 @@ public String displayName() { /** * Set the displayName property: The display name. - * + * * @param displayName the displayName value to set. * @return the MetadataEntityInner object itself. */ @@ -135,7 +139,7 @@ public MetadataEntityInner withDisplayName(String displayName) { /** * Get the dependsOn property: The list of keys on which this entity depends on. - * + * * @return the dependsOn value. */ public List dependsOn() { @@ -144,7 +148,7 @@ public List 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. */ @@ -158,7 +162,7 @@ public MetadataEntityInner withDependsOn(List dependsOn) { /** * Get the applicableScenarios property: The list of scenarios applicable to this metadata entity. - * + * * @return the applicableScenarios value. */ public List applicableScenarios() { @@ -167,7 +171,7 @@ public List 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. */ @@ -181,7 +185,7 @@ public MetadataEntityInner withApplicableScenarios(List applicableScen /** * Get the supportedValues property: The list of supported values. - * + * * @return the supportedValues value. */ public List supportedValues() { @@ -190,7 +194,7 @@ public List supportedValues() { /** * Set the supportedValues property: The list of supported values. - * + * * @param supportedValues the supportedValues value to set. * @return the MetadataEntityInner object itself. */ @@ -204,7 +208,7 @@ public MetadataEntityInner withSupportedValues(List { + MetadataEntityInner deserializedMetadataEntityInner = new MetadataEntityInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedMetadataEntityInner.id = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedMetadataEntityInner.type = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedMetadataEntityInner.name = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedMetadataEntityInner.innerProperties = MetadataEntityProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedMetadataEntityInner; + }); + } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityProperties.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityProperties.java index 1f2187ba8082..ea4042d9f2bf 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityProperties.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityProperties.java @@ -5,45 +5,49 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.models.MetadataSupportedValueDetail; import com.azure.resourcemanager.advisor.models.Scenario; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; import java.util.List; -/** The metadata entity properties. */ +/** + * The metadata entity properties. + */ @Fluent -public final class MetadataEntityProperties { +public final class MetadataEntityProperties implements JsonSerializable { /* * The display name. */ - @JsonProperty(value = "displayName") private String displayName; /* * The list of keys on which this entity depends on. */ - @JsonProperty(value = "dependsOn") private List dependsOn; /* * The list of scenarios applicable to this metadata entity. */ - @JsonProperty(value = "applicableScenarios") private List applicableScenarios; /* * The list of supported values. */ - @JsonProperty(value = "supportedValues") private List supportedValues; - /** Creates an instance of MetadataEntityProperties class. */ + /** + * Creates an instance of MetadataEntityProperties class. + */ public MetadataEntityProperties() { } /** * Get the displayName property: The display name. - * + * * @return the displayName value. */ public String displayName() { @@ -52,7 +56,7 @@ public String displayName() { /** * Set the displayName property: The display name. - * + * * @param displayName the displayName value to set. * @return the MetadataEntityProperties object itself. */ @@ -63,7 +67,7 @@ public MetadataEntityProperties withDisplayName(String displayName) { /** * Get the dependsOn property: The list of keys on which this entity depends on. - * + * * @return the dependsOn value. */ public List dependsOn() { @@ -72,7 +76,7 @@ public List dependsOn() { /** * Set the dependsOn property: The list of keys on which this entity depends on. - * + * * @param dependsOn the dependsOn value to set. * @return the MetadataEntityProperties object itself. */ @@ -83,7 +87,7 @@ public MetadataEntityProperties withDependsOn(List dependsOn) { /** * Get the applicableScenarios property: The list of scenarios applicable to this metadata entity. - * + * * @return the applicableScenarios value. */ public List applicableScenarios() { @@ -92,7 +96,7 @@ public List applicableScenarios() { /** * Set the applicableScenarios property: The list of scenarios applicable to this metadata entity. - * + * * @param applicableScenarios the applicableScenarios value to set. * @return the MetadataEntityProperties object itself. */ @@ -103,7 +107,7 @@ public MetadataEntityProperties withApplicableScenarios(List applicabl /** * Get the supportedValues property: The list of supported values. - * + * * @return the supportedValues value. */ public List supportedValues() { @@ -112,7 +116,7 @@ public List supportedValues() { /** * Set the supportedValues property: The list of supported values. - * + * * @param supportedValues the supportedValues value to set. * @return the MetadataEntityProperties object itself. */ @@ -123,7 +127,7 @@ public MetadataEntityProperties withSupportedValues(List e.validate()); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("displayName", this.displayName); + jsonWriter.writeArrayField("dependsOn", this.dependsOn, (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("applicableScenarios", this.applicableScenarios, + (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeArrayField("supportedValues", this.supportedValues, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MetadataEntityProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MetadataEntityProperties if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the MetadataEntityProperties. + */ + public static MetadataEntityProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MetadataEntityProperties deserializedMetadataEntityProperties = new MetadataEntityProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("displayName".equals(fieldName)) { + deserializedMetadataEntityProperties.displayName = reader.getString(); + } else if ("dependsOn".equals(fieldName)) { + List dependsOn = reader.readArray(reader1 -> reader1.getString()); + deserializedMetadataEntityProperties.dependsOn = dependsOn; + } else if ("applicableScenarios".equals(fieldName)) { + List applicableScenarios + = reader.readArray(reader1 -> Scenario.fromString(reader1.getString())); + deserializedMetadataEntityProperties.applicableScenarios = applicableScenarios; + } else if ("supportedValues".equals(fieldName)) { + List supportedValues + = reader.readArray(reader1 -> MetadataSupportedValueDetail.fromJson(reader1)); + deserializedMetadataEntityProperties.supportedValues = supportedValues; + } else { + reader.skipChildren(); + } + } + + return deserializedMetadataEntityProperties; + }); + } } 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 index fa14b5241f15..032431ed1d6a 100644 --- 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 @@ -5,31 +5,37 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.models.OperationDisplayInfo; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; -/** The operation supported by Advisor. */ +/** + * The operation supported by Advisor. + */ @Fluent -public final class OperationEntityInner { +public final class OperationEntityInner implements JsonSerializable { /* * Operation name: {provider}/{resource}/{operation}. */ - @JsonProperty(value = "name") private String name; /* * The operation supported by Advisor. */ - @JsonProperty(value = "display") private OperationDisplayInfo display; - /** Creates an instance of OperationEntityInner class. */ + /** + * Creates an instance of OperationEntityInner class. + */ public OperationEntityInner() { } /** * Get the name property: Operation name: {provider}/{resource}/{operation}. - * + * * @return the name value. */ public String name() { @@ -38,7 +44,7 @@ public String name() { /** * Set the name property: Operation name: {provider}/{resource}/{operation}. - * + * * @param name the name value to set. * @return the OperationEntityInner object itself. */ @@ -49,7 +55,7 @@ public OperationEntityInner withName(String name) { /** * Get the display property: The operation supported by Advisor. - * + * * @return the display value. */ public OperationDisplayInfo display() { @@ -58,7 +64,7 @@ public OperationDisplayInfo display() { /** * Set the display property: The operation supported by Advisor. - * + * * @param display the display value to set. * @return the OperationEntityInner object itself. */ @@ -69,7 +75,7 @@ public OperationEntityInner withDisplay(OperationDisplayInfo display) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { @@ -77,4 +83,43 @@ public void validate() { display().validate(); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("display", this.display); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationEntityInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationEntityInner if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationEntityInner. + */ + public static OperationEntityInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationEntityInner deserializedOperationEntityInner = new OperationEntityInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOperationEntityInner.name = reader.getString(); + } else if ("display".equals(fieldName)) { + deserializedOperationEntityInner.display = OperationDisplayInfo.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationEntityInner; + }); + } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/PredictionRequestProperties.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/PredictionRequestProperties.java new file mode 100644 index 000000000000..d156f7613798 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/PredictionRequestProperties.java @@ -0,0 +1,124 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.advisor.models.PredictionType; +import java.io.IOException; + +/** + * Properties given for the predictor. + */ +@Fluent +public final class PredictionRequestProperties implements JsonSerializable { + /* + * Type of the prediction. + */ + private PredictionType predictionType; + + /* + * Extended properties are arguments specific for each prediction type. + */ + private Object extendedProperties; + + /** + * Creates an instance of PredictionRequestProperties class. + */ + public PredictionRequestProperties() { + } + + /** + * Get the predictionType property: Type of the prediction. + * + * @return the predictionType value. + */ + public PredictionType predictionType() { + return this.predictionType; + } + + /** + * Set the predictionType property: Type of the prediction. + * + * @param predictionType the predictionType value to set. + * @return the PredictionRequestProperties object itself. + */ + public PredictionRequestProperties withPredictionType(PredictionType predictionType) { + this.predictionType = predictionType; + return this; + } + + /** + * Get the extendedProperties property: Extended properties are arguments specific for each prediction type. + * + * @return the extendedProperties value. + */ + public Object extendedProperties() { + return this.extendedProperties; + } + + /** + * Set the extendedProperties property: Extended properties are arguments specific for each prediction type. + * + * @param extendedProperties the extendedProperties value to set. + * @return the PredictionRequestProperties object itself. + */ + public PredictionRequestProperties withExtendedProperties(Object extendedProperties) { + this.extendedProperties = extendedProperties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("predictionType", + this.predictionType == null ? null : this.predictionType.toString()); + jsonWriter.writeUntypedField("extendedProperties", this.extendedProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PredictionRequestProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PredictionRequestProperties if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the PredictionRequestProperties. + */ + public static PredictionRequestProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PredictionRequestProperties deserializedPredictionRequestProperties = new PredictionRequestProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("predictionType".equals(fieldName)) { + deserializedPredictionRequestProperties.predictionType + = PredictionType.fromString(reader.getString()); + } else if ("extendedProperties".equals(fieldName)) { + deserializedPredictionRequestProperties.extendedProperties = reader.readUntyped(); + } else { + reader.skipChildren(); + } + } + + return deserializedPredictionRequestProperties; + }); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/PredictionResponseInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/PredictionResponseInner.java new file mode 100644 index 000000000000..011479258f4e --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/PredictionResponseInner.java @@ -0,0 +1,251 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.advisor.models.Category; +import com.azure.resourcemanager.advisor.models.Impact; +import com.azure.resourcemanager.advisor.models.PredictionType; +import com.azure.resourcemanager.advisor.models.ShortDescription; +import java.io.IOException; +import java.time.OffsetDateTime; + +/** + * Response used by predictions. + */ +@Fluent +public final class PredictionResponseInner implements JsonSerializable { + /* + * The properties of the prediction. + */ + private PredictionResponseProperties innerProperties; + + /** + * Creates an instance of PredictionResponseInner class. + */ + public PredictionResponseInner() { + } + + /** + * Get the innerProperties property: The properties of the prediction. + * + * @return the innerProperties value. + */ + private PredictionResponseProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the extendedProperties property: Extended properties. + * + * @return the extendedProperties value. + */ + public Object extendedProperties() { + return this.innerProperties() == null ? null : this.innerProperties().extendedProperties(); + } + + /** + * Set the extendedProperties property: Extended properties. + * + * @param extendedProperties the extendedProperties value to set. + * @return the PredictionResponseInner object itself. + */ + public PredictionResponseInner withExtendedProperties(Object extendedProperties) { + if (this.innerProperties() == null) { + this.innerProperties = new PredictionResponseProperties(); + } + this.innerProperties().withExtendedProperties(extendedProperties); + return this; + } + + /** + * Get the predictionType property: Type of the prediction. + * + * @return the predictionType value. + */ + public PredictionType predictionType() { + return this.innerProperties() == null ? null : this.innerProperties().predictionType(); + } + + /** + * Set the predictionType property: Type of the prediction. + * + * @param predictionType the predictionType value to set. + * @return the PredictionResponseInner object itself. + */ + public PredictionResponseInner withPredictionType(PredictionType predictionType) { + if (this.innerProperties() == null) { + this.innerProperties = new PredictionResponseProperties(); + } + this.innerProperties().withPredictionType(predictionType); + return this; + } + + /** + * Get the category property: The category of the recommendation. + * + * @return the category value. + */ + public Category category() { + return this.innerProperties() == null ? null : this.innerProperties().category(); + } + + /** + * Set the category property: The category of the recommendation. + * + * @param category the category value to set. + * @return the PredictionResponseInner object itself. + */ + public PredictionResponseInner withCategory(Category category) { + if (this.innerProperties() == null) { + this.innerProperties = new PredictionResponseProperties(); + } + this.innerProperties().withCategory(category); + return this; + } + + /** + * Get the impact property: The business impact of the recommendation. + * + * @return the impact value. + */ + public Impact impact() { + return this.innerProperties() == null ? null : this.innerProperties().impact(); + } + + /** + * Set the impact property: The business impact of the recommendation. + * + * @param impact the impact value to set. + * @return the PredictionResponseInner object itself. + */ + public PredictionResponseInner withImpact(Impact impact) { + if (this.innerProperties() == null) { + this.innerProperties = new PredictionResponseProperties(); + } + this.innerProperties().withImpact(impact); + return this; + } + + /** + * Get the impactedField property: The resource type identified by Advisor. + * + * @return the impactedField value. + */ + public String impactedField() { + return this.innerProperties() == null ? null : this.innerProperties().impactedField(); + } + + /** + * Set the impactedField property: The resource type identified by Advisor. + * + * @param impactedField the impactedField value to set. + * @return the PredictionResponseInner object itself. + */ + public PredictionResponseInner withImpactedField(String impactedField) { + if (this.innerProperties() == null) { + this.innerProperties = new PredictionResponseProperties(); + } + this.innerProperties().withImpactedField(impactedField); + 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.innerProperties() == null ? null : this.innerProperties().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 PredictionResponseInner object itself. + */ + public PredictionResponseInner withLastUpdated(OffsetDateTime lastUpdated) { + if (this.innerProperties() == null) { + this.innerProperties = new PredictionResponseProperties(); + } + this.innerProperties().withLastUpdated(lastUpdated); + return this; + } + + /** + * Get the shortDescription property: A summary of the recommendation. + * + * @return the shortDescription value. + */ + public ShortDescription shortDescription() { + return this.innerProperties() == null ? null : this.innerProperties().shortDescription(); + } + + /** + * Set the shortDescription property: A summary of the recommendation. + * + * @param shortDescription the shortDescription value to set. + * @return the PredictionResponseInner object itself. + */ + public PredictionResponseInner withShortDescription(ShortDescription shortDescription) { + if (this.innerProperties() == null) { + this.innerProperties = new PredictionResponseProperties(); + } + this.innerProperties().withShortDescription(shortDescription); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PredictionResponseInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PredictionResponseInner if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the PredictionResponseInner. + */ + public static PredictionResponseInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PredictionResponseInner deserializedPredictionResponseInner = new PredictionResponseInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("properties".equals(fieldName)) { + deserializedPredictionResponseInner.innerProperties = PredictionResponseProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedPredictionResponseInner; + }); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/PredictionResponseProperties.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/PredictionResponseProperties.java new file mode 100644 index 000000000000..c39043dccaa8 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/PredictionResponseProperties.java @@ -0,0 +1,275 @@ +// 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.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.advisor.models.Category; +import com.azure.resourcemanager.advisor.models.Impact; +import com.azure.resourcemanager.advisor.models.PredictionType; +import com.azure.resourcemanager.advisor.models.ShortDescription; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Properties of the prediction. + */ +@Fluent +public final class PredictionResponseProperties implements JsonSerializable { + /* + * Extended properties + */ + private Object extendedProperties; + + /* + * Type of the prediction. + */ + private PredictionType predictionType; + + /* + * The category of the recommendation. + */ + private Category category; + + /* + * The business impact of the recommendation. + */ + private Impact impact; + + /* + * The resource type identified by Advisor. + */ + private String impactedField; + + /* + * The most recent time that Advisor checked the validity of the recommendation. + */ + private OffsetDateTime lastUpdated; + + /* + * A summary of the recommendation. + */ + private ShortDescription shortDescription; + + /** + * Creates an instance of PredictionResponseProperties class. + */ + public PredictionResponseProperties() { + } + + /** + * Get the extendedProperties property: Extended properties. + * + * @return the extendedProperties value. + */ + public Object extendedProperties() { + return this.extendedProperties; + } + + /** + * Set the extendedProperties property: Extended properties. + * + * @param extendedProperties the extendedProperties value to set. + * @return the PredictionResponseProperties object itself. + */ + public PredictionResponseProperties withExtendedProperties(Object extendedProperties) { + this.extendedProperties = extendedProperties; + return this; + } + + /** + * Get the predictionType property: Type of the prediction. + * + * @return the predictionType value. + */ + public PredictionType predictionType() { + return this.predictionType; + } + + /** + * Set the predictionType property: Type of the prediction. + * + * @param predictionType the predictionType value to set. + * @return the PredictionResponseProperties object itself. + */ + public PredictionResponseProperties withPredictionType(PredictionType predictionType) { + this.predictionType = predictionType; + return this; + } + + /** + * 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 PredictionResponseProperties object itself. + */ + public PredictionResponseProperties 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 PredictionResponseProperties object itself. + */ + public PredictionResponseProperties 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 PredictionResponseProperties object itself. + */ + public PredictionResponseProperties withImpactedField(String impactedField) { + this.impactedField = impactedField; + 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 PredictionResponseProperties object itself. + */ + public PredictionResponseProperties withLastUpdated(OffsetDateTime lastUpdated) { + this.lastUpdated = lastUpdated; + 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 PredictionResponseProperties object itself. + */ + public PredictionResponseProperties withShortDescription(ShortDescription shortDescription) { + this.shortDescription = shortDescription; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (shortDescription() != null) { + shortDescription().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("extendedProperties", this.extendedProperties); + jsonWriter.writeStringField("predictionType", + this.predictionType == null ? null : this.predictionType.toString()); + jsonWriter.writeStringField("category", this.category == null ? null : this.category.toString()); + jsonWriter.writeStringField("impact", this.impact == null ? null : this.impact.toString()); + jsonWriter.writeStringField("impactedField", this.impactedField); + jsonWriter.writeStringField("lastUpdated", + this.lastUpdated == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastUpdated)); + jsonWriter.writeJsonField("shortDescription", this.shortDescription); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PredictionResponseProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PredictionResponseProperties if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the PredictionResponseProperties. + */ + public static PredictionResponseProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PredictionResponseProperties deserializedPredictionResponseProperties = new PredictionResponseProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("extendedProperties".equals(fieldName)) { + deserializedPredictionResponseProperties.extendedProperties = reader.readUntyped(); + } else if ("predictionType".equals(fieldName)) { + deserializedPredictionResponseProperties.predictionType + = PredictionType.fromString(reader.getString()); + } else if ("category".equals(fieldName)) { + deserializedPredictionResponseProperties.category = Category.fromString(reader.getString()); + } else if ("impact".equals(fieldName)) { + deserializedPredictionResponseProperties.impact = Impact.fromString(reader.getString()); + } else if ("impactedField".equals(fieldName)) { + deserializedPredictionResponseProperties.impactedField = reader.getString(); + } else if ("lastUpdated".equals(fieldName)) { + deserializedPredictionResponseProperties.lastUpdated = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("shortDescription".equals(fieldName)) { + deserializedPredictionResponseProperties.shortDescription = ShortDescription.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedPredictionResponseProperties; + }); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/RecommendationProperties.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/RecommendationProperties.java index 68616b818011..482e0447184c 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/RecommendationProperties.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/RecommendationProperties.java @@ -5,139 +5,133 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; 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.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.UUID; -/** The properties of the recommendation. */ +/** + * The properties of the recommendation. + */ @Fluent -public final class RecommendationProperties { +public final class RecommendationProperties implements JsonSerializable { /* * The category of the recommendation. */ - @JsonProperty(value = "category") private Category category; /* * The business impact of the recommendation. */ - @JsonProperty(value = "impact") private Impact impact; /* * The resource type identified by Advisor. */ - @JsonProperty(value = "impactedField") private String impactedField; /* * The resource identified by Advisor. */ - @JsonProperty(value = "impactedValue") private String impactedValue; /* * The most recent time that Advisor checked the validity of the recommendation. */ - @JsonProperty(value = "lastUpdated") private OffsetDateTime lastUpdated; /* * The recommendation metadata. */ - @JsonProperty(value = "metadata") - @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) private Map metadata; /* * The recommendation-type GUID. */ - @JsonProperty(value = "recommendationTypeId") private String recommendationTypeId; + /* + * The potential risk of not implementing the recommendation. + */ + private Risk risk; + /* * A summary of the recommendation. */ - @JsonProperty(value = "shortDescription") private ShortDescription shortDescription; /* * The list of snoozed and dismissed rules for the recommendation. */ - @JsonProperty(value = "suppressionIds") private List suppressionIds; /* * Extended properties */ - @JsonProperty(value = "extendedProperties") - @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) private Map extendedProperties; /* * Metadata of resource that was assessed */ - @JsonProperty(value = "resourceMetadata") private ResourceMetadata resourceMetadata; /* * The detailed description of recommendation. */ - @JsonProperty(value = "description") private String description; /* * The label of recommendation. */ - @JsonProperty(value = "label") private String label; /* * The link to learn more about recommendation and generation logic. */ - @JsonProperty(value = "learnMoreLink") private String learnMoreLink; /* * The potential benefit of implementing recommendation. */ - @JsonProperty(value = "potentialBenefits") private String potentialBenefits; /* * The list of recommended actions to implement recommendation. */ - @JsonProperty(value = "actions") private List> actions; /* * The automated way to apply recommendation. */ - @JsonProperty(value = "remediation") - @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) private Map remediation; /* * The recommendation metadata properties exposed to customer to provide additional information. */ - @JsonProperty(value = "exposedMetadataProperties") - @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) private Map exposedMetadataProperties; - /** Creates an instance of RecommendationProperties class. */ + /** + * Creates an instance of RecommendationProperties class. + */ public RecommendationProperties() { } /** * Get the category property: The category of the recommendation. - * + * * @return the category value. */ public Category category() { @@ -146,7 +140,7 @@ public Category category() { /** * Set the category property: The category of the recommendation. - * + * * @param category the category value to set. * @return the RecommendationProperties object itself. */ @@ -157,7 +151,7 @@ public RecommendationProperties withCategory(Category category) { /** * Get the impact property: The business impact of the recommendation. - * + * * @return the impact value. */ public Impact impact() { @@ -166,7 +160,7 @@ public Impact impact() { /** * Set the impact property: The business impact of the recommendation. - * + * * @param impact the impact value to set. * @return the RecommendationProperties object itself. */ @@ -177,7 +171,7 @@ public RecommendationProperties withImpact(Impact impact) { /** * Get the impactedField property: The resource type identified by Advisor. - * + * * @return the impactedField value. */ public String impactedField() { @@ -186,7 +180,7 @@ public String impactedField() { /** * Set the impactedField property: The resource type identified by Advisor. - * + * * @param impactedField the impactedField value to set. * @return the RecommendationProperties object itself. */ @@ -197,7 +191,7 @@ public RecommendationProperties withImpactedField(String impactedField) { /** * Get the impactedValue property: The resource identified by Advisor. - * + * * @return the impactedValue value. */ public String impactedValue() { @@ -206,7 +200,7 @@ public String impactedValue() { /** * Set the impactedValue property: The resource identified by Advisor. - * + * * @param impactedValue the impactedValue value to set. * @return the RecommendationProperties object itself. */ @@ -217,7 +211,7 @@ public RecommendationProperties withImpactedValue(String impactedValue) { /** * Get the lastUpdated property: The most recent time that Advisor checked the validity of the recommendation. - * + * * @return the lastUpdated value. */ public OffsetDateTime lastUpdated() { @@ -226,7 +220,7 @@ public OffsetDateTime 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 RecommendationProperties object itself. */ @@ -237,7 +231,7 @@ public RecommendationProperties withLastUpdated(OffsetDateTime lastUpdated) { /** * Get the metadata property: The recommendation metadata. - * + * * @return the metadata value. */ public Map metadata() { @@ -246,7 +240,7 @@ public Map metadata() { /** * Set the metadata property: The recommendation metadata. - * + * * @param metadata the metadata value to set. * @return the RecommendationProperties object itself. */ @@ -257,7 +251,7 @@ public RecommendationProperties withMetadata(Map metadata) { /** * Get the recommendationTypeId property: The recommendation-type GUID. - * + * * @return the recommendationTypeId value. */ public String recommendationTypeId() { @@ -266,7 +260,7 @@ public String recommendationTypeId() { /** * Set the recommendationTypeId property: The recommendation-type GUID. - * + * * @param recommendationTypeId the recommendationTypeId value to set. * @return the RecommendationProperties object itself. */ @@ -275,9 +269,29 @@ public RecommendationProperties withRecommendationTypeId(String recommendationTy 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 RecommendationProperties object itself. + */ + public RecommendationProperties withRisk(Risk risk) { + this.risk = risk; + return this; + } + /** * Get the shortDescription property: A summary of the recommendation. - * + * * @return the shortDescription value. */ public ShortDescription shortDescription() { @@ -286,7 +300,7 @@ public ShortDescription shortDescription() { /** * Set the shortDescription property: A summary of the recommendation. - * + * * @param shortDescription the shortDescription value to set. * @return the RecommendationProperties object itself. */ @@ -297,7 +311,7 @@ public RecommendationProperties withShortDescription(ShortDescription shortDescr /** * Get the suppressionIds property: The list of snoozed and dismissed rules for the recommendation. - * + * * @return the suppressionIds value. */ public List suppressionIds() { @@ -306,7 +320,7 @@ public List suppressionIds() { /** * Set the suppressionIds property: The list of snoozed and dismissed rules for the recommendation. - * + * * @param suppressionIds the suppressionIds value to set. * @return the RecommendationProperties object itself. */ @@ -317,7 +331,7 @@ public RecommendationProperties withSuppressionIds(List suppressionIds) { /** * Get the extendedProperties property: Extended properties. - * + * * @return the extendedProperties value. */ public Map extendedProperties() { @@ -326,7 +340,7 @@ public Map extendedProperties() { /** * Set the extendedProperties property: Extended properties. - * + * * @param extendedProperties the extendedProperties value to set. * @return the RecommendationProperties object itself. */ @@ -337,7 +351,7 @@ public RecommendationProperties withExtendedProperties(Map exten /** * Get the resourceMetadata property: Metadata of resource that was assessed. - * + * * @return the resourceMetadata value. */ public ResourceMetadata resourceMetadata() { @@ -346,7 +360,7 @@ public ResourceMetadata resourceMetadata() { /** * Set the resourceMetadata property: Metadata of resource that was assessed. - * + * * @param resourceMetadata the resourceMetadata value to set. * @return the RecommendationProperties object itself. */ @@ -357,7 +371,7 @@ public RecommendationProperties withResourceMetadata(ResourceMetadata resourceMe /** * Get the description property: The detailed description of recommendation. - * + * * @return the description value. */ public String description() { @@ -366,7 +380,7 @@ public String description() { /** * Set the description property: The detailed description of recommendation. - * + * * @param description the description value to set. * @return the RecommendationProperties object itself. */ @@ -377,7 +391,7 @@ public RecommendationProperties withDescription(String description) { /** * Get the label property: The label of recommendation. - * + * * @return the label value. */ public String label() { @@ -386,7 +400,7 @@ public String label() { /** * Set the label property: The label of recommendation. - * + * * @param label the label value to set. * @return the RecommendationProperties object itself. */ @@ -397,7 +411,7 @@ public RecommendationProperties withLabel(String label) { /** * Get the learnMoreLink property: The link to learn more about recommendation and generation logic. - * + * * @return the learnMoreLink value. */ public String learnMoreLink() { @@ -406,7 +420,7 @@ public String learnMoreLink() { /** * Set the learnMoreLink property: The link to learn more about recommendation and generation logic. - * + * * @param learnMoreLink the learnMoreLink value to set. * @return the RecommendationProperties object itself. */ @@ -417,7 +431,7 @@ public RecommendationProperties withLearnMoreLink(String learnMoreLink) { /** * Get the potentialBenefits property: The potential benefit of implementing recommendation. - * + * * @return the potentialBenefits value. */ public String potentialBenefits() { @@ -426,7 +440,7 @@ public String potentialBenefits() { /** * Set the potentialBenefits property: The potential benefit of implementing recommendation. - * + * * @param potentialBenefits the potentialBenefits value to set. * @return the RecommendationProperties object itself. */ @@ -437,7 +451,7 @@ public RecommendationProperties withPotentialBenefits(String potentialBenefits) /** * Get the actions property: The list of recommended actions to implement recommendation. - * + * * @return the actions value. */ public List> actions() { @@ -446,7 +460,7 @@ public List> actions() { /** * Set the actions property: The list of recommended actions to implement recommendation. - * + * * @param actions the actions value to set. * @return the RecommendationProperties object itself. */ @@ -457,7 +471,7 @@ public RecommendationProperties withActions(List> actions) { /** * Get the remediation property: The automated way to apply recommendation. - * + * * @return the remediation value. */ public Map remediation() { @@ -466,7 +480,7 @@ public Map remediation() { /** * Set the remediation property: The automated way to apply recommendation. - * + * * @param remediation the remediation value to set. * @return the RecommendationProperties object itself. */ @@ -478,7 +492,7 @@ public RecommendationProperties withRemediation(Map remediation) /** * Get the exposedMetadataProperties property: The recommendation metadata properties exposed to customer to provide * additional information. - * + * * @return the exposedMetadataProperties value. */ public Map exposedMetadataProperties() { @@ -488,7 +502,7 @@ public Map exposedMetadataProperties() { /** * Set the exposedMetadataProperties property: The recommendation metadata properties exposed to customer to provide * additional information. - * + * * @param exposedMetadataProperties the exposedMetadataProperties value to set. * @return the RecommendationProperties object itself. */ @@ -499,7 +513,7 @@ public RecommendationProperties withExposedMetadataProperties(Map writer.writeUntyped(element)); + jsonWriter.writeStringField("recommendationTypeId", this.recommendationTypeId); + jsonWriter.writeStringField("risk", this.risk == null ? null : this.risk.toString()); + jsonWriter.writeJsonField("shortDescription", this.shortDescription); + jsonWriter.writeArrayField("suppressionIds", this.suppressionIds, + (writer, element) -> writer.writeString(Objects.toString(element, null))); + jsonWriter.writeMapField("extendedProperties", this.extendedProperties, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("resourceMetadata", this.resourceMetadata); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("label", this.label); + jsonWriter.writeStringField("learnMoreLink", this.learnMoreLink); + jsonWriter.writeStringField("potentialBenefits", this.potentialBenefits); + jsonWriter.writeArrayField("actions", this.actions, + (writer, element) -> writer.writeMap(element, (writer1, element1) -> writer1.writeUntyped(element1))); + jsonWriter.writeMapField("remediation", this.remediation, (writer, element) -> writer.writeUntyped(element)); + jsonWriter.writeMapField("exposedMetadataProperties", this.exposedMetadataProperties, + (writer, element) -> writer.writeUntyped(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RecommendationProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RecommendationProperties if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the RecommendationProperties. + */ + public static RecommendationProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RecommendationProperties deserializedRecommendationProperties = new RecommendationProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("category".equals(fieldName)) { + deserializedRecommendationProperties.category = Category.fromString(reader.getString()); + } else if ("impact".equals(fieldName)) { + deserializedRecommendationProperties.impact = Impact.fromString(reader.getString()); + } else if ("impactedField".equals(fieldName)) { + deserializedRecommendationProperties.impactedField = reader.getString(); + } else if ("impactedValue".equals(fieldName)) { + deserializedRecommendationProperties.impactedValue = reader.getString(); + } else if ("lastUpdated".equals(fieldName)) { + deserializedRecommendationProperties.lastUpdated = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.readUntyped()); + deserializedRecommendationProperties.metadata = metadata; + } else if ("recommendationTypeId".equals(fieldName)) { + deserializedRecommendationProperties.recommendationTypeId = reader.getString(); + } else if ("risk".equals(fieldName)) { + deserializedRecommendationProperties.risk = Risk.fromString(reader.getString()); + } else if ("shortDescription".equals(fieldName)) { + deserializedRecommendationProperties.shortDescription = ShortDescription.fromJson(reader); + } else if ("suppressionIds".equals(fieldName)) { + List suppressionIds = reader.readArray( + reader1 -> reader1.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()))); + deserializedRecommendationProperties.suppressionIds = suppressionIds; + } else if ("extendedProperties".equals(fieldName)) { + Map extendedProperties = reader.readMap(reader1 -> reader1.getString()); + deserializedRecommendationProperties.extendedProperties = extendedProperties; + } else if ("resourceMetadata".equals(fieldName)) { + deserializedRecommendationProperties.resourceMetadata = ResourceMetadata.fromJson(reader); + } else if ("description".equals(fieldName)) { + deserializedRecommendationProperties.description = reader.getString(); + } else if ("label".equals(fieldName)) { + deserializedRecommendationProperties.label = reader.getString(); + } else if ("learnMoreLink".equals(fieldName)) { + deserializedRecommendationProperties.learnMoreLink = reader.getString(); + } else if ("potentialBenefits".equals(fieldName)) { + deserializedRecommendationProperties.potentialBenefits = reader.getString(); + } else if ("actions".equals(fieldName)) { + List> actions + = reader.readArray(reader1 -> reader1.readMap(reader2 -> reader2.readUntyped())); + deserializedRecommendationProperties.actions = actions; + } else if ("remediation".equals(fieldName)) { + Map remediation = reader.readMap(reader1 -> reader1.readUntyped()); + deserializedRecommendationProperties.remediation = remediation; + } else if ("exposedMetadataProperties".equals(fieldName)) { + Map exposedMetadataProperties = reader.readMap(reader1 -> reader1.readUntyped()); + deserializedRecommendationProperties.exposedMetadataProperties = exposedMetadataProperties; + } else { + reader.skipChildren(); + } + } + + return deserializedRecommendationProperties; + }); + } } 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 index a28af38691e4..25a5a62ea284 100644 --- 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 @@ -6,41 +6,108 @@ import com.azure.core.annotation.Fluent; import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.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.JsonProperty; +import java.io.IOException; import java.time.OffsetDateTime; import java.util.List; import java.util.Map; import java.util.UUID; -/** Advisor Recommendation. */ +/** + * Advisor Recommendation. + */ @Fluent public final class ResourceRecommendationBaseInner extends ProxyResource { /* * The properties of the recommendation. */ - @JsonProperty(value = "properties") private RecommendationProperties innerProperties; - /** Creates an instance of ResourceRecommendationBaseInner class. */ + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of ResourceRecommendationBaseInner class. + */ public ResourceRecommendationBaseInner() { } /** * Get the innerProperties property: The properties of the recommendation. - * + * * @return the innerProperties value. */ private RecommendationProperties innerProperties() { return this.innerProperties; } + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + /** * Get the category property: The category of the recommendation. - * + * * @return the category value. */ public Category category() { @@ -49,7 +116,7 @@ public Category category() { /** * Set the category property: The category of the recommendation. - * + * * @param category the category value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -63,7 +130,7 @@ public ResourceRecommendationBaseInner withCategory(Category category) { /** * Get the impact property: The business impact of the recommendation. - * + * * @return the impact value. */ public Impact impact() { @@ -72,7 +139,7 @@ public Impact impact() { /** * Set the impact property: The business impact of the recommendation. - * + * * @param impact the impact value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -86,7 +153,7 @@ public ResourceRecommendationBaseInner withImpact(Impact impact) { /** * Get the impactedField property: The resource type identified by Advisor. - * + * * @return the impactedField value. */ public String impactedField() { @@ -95,7 +162,7 @@ public String impactedField() { /** * Set the impactedField property: The resource type identified by Advisor. - * + * * @param impactedField the impactedField value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -109,7 +176,7 @@ public ResourceRecommendationBaseInner withImpactedField(String impactedField) { /** * Get the impactedValue property: The resource identified by Advisor. - * + * * @return the impactedValue value. */ public String impactedValue() { @@ -118,7 +185,7 @@ public String impactedValue() { /** * Set the impactedValue property: The resource identified by Advisor. - * + * * @param impactedValue the impactedValue value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -132,7 +199,7 @@ public ResourceRecommendationBaseInner withImpactedValue(String impactedValue) { /** * Get the lastUpdated property: The most recent time that Advisor checked the validity of the recommendation. - * + * * @return the lastUpdated value. */ public OffsetDateTime lastUpdated() { @@ -141,7 +208,7 @@ public OffsetDateTime 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. */ @@ -155,7 +222,7 @@ public ResourceRecommendationBaseInner withLastUpdated(OffsetDateTime lastUpdate /** * Get the metadata property: The recommendation metadata. - * + * * @return the metadata value. */ public Map metadata() { @@ -164,7 +231,7 @@ public Map metadata() { /** * Set the metadata property: The recommendation metadata. - * + * * @param metadata the metadata value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -178,7 +245,7 @@ public ResourceRecommendationBaseInner withMetadata(Map metadata /** * Get the recommendationTypeId property: The recommendation-type GUID. - * + * * @return the recommendationTypeId value. */ public String recommendationTypeId() { @@ -187,7 +254,7 @@ public String recommendationTypeId() { /** * Set the recommendationTypeId property: The recommendation-type GUID. - * + * * @param recommendationTypeId the recommendationTypeId value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -199,9 +266,32 @@ public ResourceRecommendationBaseInner withRecommendationTypeId(String recommend return this; } + /** + * Get the risk property: The potential risk of not implementing the recommendation. + * + * @return the risk value. + */ + public Risk risk() { + return this.innerProperties() == null ? null : this.innerProperties().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) { + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withRisk(risk); + return this; + } + /** * Get the shortDescription property: A summary of the recommendation. - * + * * @return the shortDescription value. */ public ShortDescription shortDescription() { @@ -210,7 +300,7 @@ public ShortDescription shortDescription() { /** * Set the shortDescription property: A summary of the recommendation. - * + * * @param shortDescription the shortDescription value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -224,7 +314,7 @@ public ResourceRecommendationBaseInner withShortDescription(ShortDescription sho /** * Get the suppressionIds property: The list of snoozed and dismissed rules for the recommendation. - * + * * @return the suppressionIds value. */ public List suppressionIds() { @@ -233,7 +323,7 @@ public List 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. */ @@ -247,7 +337,7 @@ public ResourceRecommendationBaseInner withSuppressionIds(List suppression /** * Get the extendedProperties property: Extended properties. - * + * * @return the extendedProperties value. */ public Map extendedProperties() { @@ -256,7 +346,7 @@ public Map extendedProperties() { /** * Set the extendedProperties property: Extended properties. - * + * * @param extendedProperties the extendedProperties value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -270,7 +360,7 @@ public ResourceRecommendationBaseInner withExtendedProperties(Map> actions() { @@ -394,7 +484,7 @@ public List> actions() { /** * Set the actions property: The list of recommended actions to implement recommendation. - * + * * @param actions the actions value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -408,7 +498,7 @@ public ResourceRecommendationBaseInner withActions(List> act /** * Get the remediation property: The automated way to apply recommendation. - * + * * @return the remediation value. */ public Map remediation() { @@ -417,7 +507,7 @@ public Map remediation() { /** * Set the remediation property: The automated way to apply recommendation. - * + * * @param remediation the remediation value to set. * @return the ResourceRecommendationBaseInner object itself. */ @@ -432,7 +522,7 @@ public ResourceRecommendationBaseInner withRemediation(Map remed /** * Get the exposedMetadataProperties property: The recommendation metadata properties exposed to customer to provide * additional information. - * + * * @return the exposedMetadataProperties value. */ public Map exposedMetadataProperties() { @@ -442,12 +532,12 @@ public Map exposedMetadataProperties() { /** * Set the exposedMetadataProperties property: The recommendation metadata properties exposed to customer to provide * additional information. - * + * * @param exposedMetadataProperties the exposedMetadataProperties value to set. * @return the ResourceRecommendationBaseInner object itself. */ - public ResourceRecommendationBaseInner withExposedMetadataProperties( - Map exposedMetadataProperties) { + public ResourceRecommendationBaseInner + withExposedMetadataProperties(Map exposedMetadataProperties) { if (this.innerProperties() == null) { this.innerProperties = new RecommendationProperties(); } @@ -457,7 +547,7 @@ public ResourceRecommendationBaseInner withExposedMetadataProperties( /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { @@ -465,4 +555,51 @@ public void validate() { innerProperties().validate(); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceRecommendationBaseInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceRecommendationBaseInner if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceRecommendationBaseInner. + */ + public static ResourceRecommendationBaseInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceRecommendationBaseInner deserializedResourceRecommendationBaseInner + = new ResourceRecommendationBaseInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedResourceRecommendationBaseInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedResourceRecommendationBaseInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedResourceRecommendationBaseInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedResourceRecommendationBaseInner.innerProperties + = RecommendationProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedResourceRecommendationBaseInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceRecommendationBaseInner; + }); + } } 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 index be20ece0a7d5..c550c3baf41a 100644 --- 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 @@ -6,34 +6,100 @@ import com.azure.core.annotation.Fluent; import com.azure.core.management.ProxyResource; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.time.OffsetDateTime; -/** The details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with the rule. */ +/** + * The details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with the rule. + */ @Fluent public final class SuppressionContractInner extends ProxyResource { /* * The properties of the suppression. */ - @JsonProperty(value = "properties") private SuppressionProperties innerProperties; - /** Creates an instance of SuppressionContractInner class. */ + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of SuppressionContractInner class. + */ public SuppressionContractInner() { } /** * Get the innerProperties property: The properties of the suppression. - * + * * @return the innerProperties value. */ private SuppressionProperties innerProperties() { return this.innerProperties; } + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + /** * Get the suppressionId property: The GUID of the suppression. - * + * * @return the suppressionId value. */ public String suppressionId() { @@ -42,7 +108,7 @@ public String suppressionId() { /** * Set the suppressionId property: The GUID of the suppression. - * + * * @param suppressionId the suppressionId value to set. * @return the SuppressionContractInner object itself. */ @@ -56,7 +122,7 @@ public SuppressionContractInner withSuppressionId(String suppressionId) { /** * Get the ttl property: The duration for which the suppression is valid. - * + * * @return the ttl value. */ public String ttl() { @@ -65,7 +131,7 @@ public String 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. */ @@ -79,7 +145,7 @@ public SuppressionContractInner withTtl(String ttl) { /** * Get the expirationTimestamp property: Gets or sets the expiration time stamp. - * + * * @return the expirationTimestamp value. */ public OffsetDateTime expirationTimestamp() { @@ -88,7 +154,7 @@ public OffsetDateTime expirationTimestamp() { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { @@ -96,4 +162,49 @@ public void validate() { innerProperties().validate(); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SuppressionContractInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SuppressionContractInner if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SuppressionContractInner. + */ + public static SuppressionContractInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SuppressionContractInner deserializedSuppressionContractInner = new SuppressionContractInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSuppressionContractInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedSuppressionContractInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedSuppressionContractInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedSuppressionContractInner.innerProperties = SuppressionProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedSuppressionContractInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSuppressionContractInner; + }); + } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionProperties.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionProperties.java index c590fd6dc7f1..95d20d3b9291 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionProperties.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionProperties.java @@ -5,37 +5,43 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.time.OffsetDateTime; -/** The properties of the suppression. */ +/** + * The properties of the suppression. + */ @Fluent -public final class SuppressionProperties { +public final class SuppressionProperties implements JsonSerializable { /* * The GUID of the suppression. */ - @JsonProperty(value = "suppressionId") private String suppressionId; /* * The duration for which the suppression is valid. */ - @JsonProperty(value = "ttl") private String ttl; /* * Gets or sets the expiration time stamp. */ - @JsonProperty(value = "expirationTimeStamp", access = JsonProperty.Access.WRITE_ONLY) private OffsetDateTime expirationTimestamp; - /** Creates an instance of SuppressionProperties class. */ + /** + * Creates an instance of SuppressionProperties class. + */ public SuppressionProperties() { } /** * Get the suppressionId property: The GUID of the suppression. - * + * * @return the suppressionId value. */ public String suppressionId() { @@ -44,7 +50,7 @@ public String suppressionId() { /** * Set the suppressionId property: The GUID of the suppression. - * + * * @param suppressionId the suppressionId value to set. * @return the SuppressionProperties object itself. */ @@ -55,7 +61,7 @@ public SuppressionProperties withSuppressionId(String suppressionId) { /** * Get the ttl property: The duration for which the suppression is valid. - * + * * @return the ttl value. */ public String ttl() { @@ -64,7 +70,7 @@ public String ttl() { /** * Set the ttl property: The duration for which the suppression is valid. - * + * * @param ttl the ttl value to set. * @return the SuppressionProperties object itself. */ @@ -75,7 +81,7 @@ public SuppressionProperties withTtl(String ttl) { /** * Get the expirationTimestamp property: Gets or sets the expiration time stamp. - * + * * @return the expirationTimestamp value. */ public OffsetDateTime expirationTimestamp() { @@ -84,9 +90,51 @@ public OffsetDateTime expirationTimestamp() { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("suppressionId", this.suppressionId); + jsonWriter.writeStringField("ttl", this.ttl); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SuppressionProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SuppressionProperties if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the SuppressionProperties. + */ + public static SuppressionProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SuppressionProperties deserializedSuppressionProperties = new SuppressionProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("suppressionId".equals(fieldName)) { + deserializedSuppressionProperties.suppressionId = reader.getString(); + } else if ("ttl".equals(fieldName)) { + deserializedSuppressionProperties.ttl = reader.getString(); + } else if ("expirationTimeStamp".equals(fieldName)) { + deserializedSuppressionProperties.expirationTimestamp = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedSuppressionProperties; + }); + } } 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 index 50a514da695c..9d1e90d766eb 100644 --- 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 @@ -2,5 +2,8 @@ // 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 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 index 0394bf92594a..0a367cf82855 100644 --- 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 @@ -2,5 +2,8 @@ // 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 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 index 2cf40f1d077e..3f21e8d1d7dd 100644 --- 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 @@ -14,8 +14,10 @@ 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}) +/** + * A builder for creating a new instance of the AdvisorManagementClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { AdvisorManagementClientImpl.class }) public final class AdvisorManagementClientBuilder { /* * The Azure subscription ID. @@ -24,7 +26,7 @@ public final class AdvisorManagementClientBuilder { /** * Sets The Azure subscription ID. - * + * * @param subscriptionId the subscriptionId value. * @return the AdvisorManagementClientBuilder. */ @@ -40,7 +42,7 @@ public AdvisorManagementClientBuilder subscriptionId(String subscriptionId) { /** * Sets server parameter. - * + * * @param endpoint the endpoint value. * @return the AdvisorManagementClientBuilder. */ @@ -56,7 +58,7 @@ public AdvisorManagementClientBuilder endpoint(String endpoint) { /** * Sets The environment to connect to. - * + * * @param environment the environment value. * @return the AdvisorManagementClientBuilder. */ @@ -72,7 +74,7 @@ public AdvisorManagementClientBuilder environment(AzureEnvironment environment) /** * Sets The HTTP pipeline to send requests through. - * + * * @param pipeline the pipeline value. * @return the AdvisorManagementClientBuilder. */ @@ -88,7 +90,7 @@ public AdvisorManagementClientBuilder pipeline(HttpPipeline pipeline) { /** * Sets The default poll interval for long-running operation. - * + * * @param defaultPollInterval the defaultPollInterval value. * @return the AdvisorManagementClientBuilder. */ @@ -104,7 +106,7 @@ public AdvisorManagementClientBuilder defaultPollInterval(Duration defaultPollIn /** * Sets The serializer to serialize an object into a string. - * + * * @param serializerAdapter the serializerAdapter value. * @return the AdvisorManagementClientBuilder. */ @@ -115,30 +117,22 @@ public AdvisorManagementClientBuilder serializerAdapter(SerializerAdapter serial /** * Builds an instance of AdvisorManagementClientImpl with the provided parameters. - * + * * @return an instance of AdvisorManagementClientImpl. */ public AdvisorManagementClientImpl buildClient() { String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; - HttpPipeline localPipeline = - (pipeline != null) - ? pipeline - : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); - Duration localDefaultPollInterval = - (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); - SerializerAdapter localSerializerAdapter = - (serializerAdapter != null) - ? serializerAdapter - : SerializerFactory.createDefaultManagementSerializerAdapter(); - AdvisorManagementClientImpl client = - new AdvisorManagementClientImpl( - localPipeline, - localSerializerAdapter, - localDefaultPollInterval, - localEnvironment, - subscriptionId, - localEndpoint); + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + AdvisorManagementClientImpl client = new AdvisorManagementClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, this.subscriptionId, localEndpoint); 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 index f6086c60822b..53be94b779c2 100644 --- 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 @@ -5,6 +5,7 @@ package com.azure.resourcemanager.advisor.implementation; import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpResponse; @@ -23,10 +24,12 @@ 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.AdvisorScoresClient; 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.ResourceProvidersClient; import com.azure.resourcemanager.advisor.fluent.SuppressionsClient; import java.io.IOException; import java.lang.reflect.Type; @@ -37,144 +40,196 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -/** Initializes a new instance of the AdvisorManagementClientImpl type. */ +/** + * Initializes a new instance of the AdvisorManagementClientImpl type. + */ @ServiceClient(builder = AdvisorManagementClientBuilder.class) public final class AdvisorManagementClientImpl implements AdvisorManagementClient { - /** The Azure subscription ID. */ + /** + * 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. */ + /** + * server parameter. + */ private final String endpoint; /** * Gets server parameter. - * + * * @return the endpoint value. */ public String getEndpoint() { return this.endpoint; } - /** Api Version. */ + /** + * 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. */ + /** + * 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. */ + /** + * 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. */ + /** + * 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. */ + /** + * 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. */ + /** + * 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. */ + /** + * 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. */ + /** + * 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. */ + /** + * 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; } + /** + * The ResourceProvidersClient object to access its operations. + */ + private final ResourceProvidersClient resourceProviders; + + /** + * Gets the ResourceProvidersClient object to access its operations. + * + * @return the ResourceProvidersClient object. + */ + public ResourceProvidersClient getResourceProviders() { + return this.resourceProviders; + } + + /** + * The AdvisorScoresClient object to access its operations. + */ + private final AdvisorScoresClient advisorScores; + + /** + * Gets the AdvisorScoresClient object to access its operations. + * + * @return the AdvisorScoresClient object. + */ + public AdvisorScoresClient getAdvisorScores() { + return this.advisorScores; + } + /** * 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. @@ -182,29 +237,26 @@ public SuppressionsClient getSuppressions() { * @param subscriptionId The Azure subscription ID. * @param endpoint server parameter. */ - AdvisorManagementClientImpl( - HttpPipeline httpPipeline, - SerializerAdapter serializerAdapter, - Duration defaultPollInterval, - AzureEnvironment environment, - String subscriptionId, - String endpoint) { + 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.apiVersion = "2023-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); + this.resourceProviders = new ResourceProvidersClientImpl(this); + this.advisorScores = new AdvisorScoresClientImpl(this); } /** * Gets default client context. - * + * * @return the default client context. */ public Context getContext() { @@ -213,7 +265,7 @@ public Context getContext() { /** * Merges default client context with provided context. - * + * * @param context the context to be merged with default client context. * @return the merged context. */ @@ -223,7 +275,7 @@ public Context mergeContext(Context context) { /** * Gets long running operation result. - * + * * @param activationResponse the response of activation operation. * @param httpPipeline the http pipeline. * @param pollResultType type of poll result. @@ -233,26 +285,15 @@ public Context mergeContext(Context context) { * @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); + 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. @@ -265,19 +306,16 @@ public Mono getLroFinalResultOrError(AsyncPollResponse, HttpResponse errorResponse = null; PollResult.Error lroError = response.getValue().getError(); if (lroError != null) { - errorResponse = - new HttpResponseImpl( - lroError.getResponseStatusCode(), lroError.getResponseHeaders(), lroError.getResponseBody()); + 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); + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); if (managementError.getCode() == null || managementError.getMessage() == null) { managementError = null; } @@ -318,7 +356,7 @@ public int getStatusCode() { } public String getHeaderValue(String s) { - return httpHeaders.getValue(s); + return httpHeaders.getValue(HttpHeaderName.fromString(s)); } public HttpHeaders getHeaders() { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoreEntityImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoreEntityImpl.java new file mode 100644 index 000000000000..c4765d4844b1 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoreEntityImpl.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreEntityInner; +import com.azure.resourcemanager.advisor.models.AdvisorScoreEntity; +import com.azure.resourcemanager.advisor.models.AdvisorScoreEntityProperties; + +public final class AdvisorScoreEntityImpl implements AdvisorScoreEntity { + private AdvisorScoreEntityInner innerObject; + + private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; + + AdvisorScoreEntityImpl(AdvisorScoreEntityInner innerObject, + com.azure.resourcemanager.advisor.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 AdvisorScoreEntityProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public AdvisorScoreEntityInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.advisor.AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoreResponseImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoreResponseImpl.java new file mode 100644 index 000000000000..cc2c532f2d5b --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoreResponseImpl.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreEntityInner; +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreResponseInner; +import com.azure.resourcemanager.advisor.models.AdvisorScoreEntity; +import com.azure.resourcemanager.advisor.models.AdvisorScoreResponse; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public final class AdvisorScoreResponseImpl implements AdvisorScoreResponse { + private AdvisorScoreResponseInner innerObject; + + private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; + + AdvisorScoreResponseImpl(AdvisorScoreResponseInner innerObject, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public List value() { + List inner = this.innerModel().value(); + if (inner != null) { + return Collections.unmodifiableList(inner.stream() + .map(inner1 -> new AdvisorScoreEntityImpl(inner1, this.manager())) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public AdvisorScoreResponseInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.advisor.AdvisorManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoresClientImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoresClientImpl.java new file mode 100644 index 000000000000..ab62c6f5cf6d --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoresClientImpl.java @@ -0,0 +1,265 @@ +// 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.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.advisor.fluent.AdvisorScoresClient; +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreEntityInner; +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreResponseInner; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in AdvisorScoresClient. + */ +public final class AdvisorScoresClientImpl implements AdvisorScoresClient { + /** + * The proxy service used to perform REST calls. + */ + private final AdvisorScoresService service; + + /** + * The service client containing this operation class. + */ + private final AdvisorManagementClientImpl client; + + /** + * Initializes an instance of AdvisorScoresClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AdvisorScoresClientImpl(AdvisorManagementClientImpl client) { + this.service + = RestProxy.create(AdvisorScoresService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdvisorManagementClientAdvisorScores to be used by the proxy service + * to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AdvisorManagementCli") + public interface AdvisorScoresService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/advisorScore") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/advisorScore/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, @PathParam("name") String name, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + } + + /** + * Gets the list of advisor scores. + * + * @throws ManagementException 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 scores along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithResponseAsync() { + 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(), accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Gets the list of advisor scores. + * + * @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 scores along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithResponseAsync(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(), + accept, context); + } + + /** + * Gets the list of advisor scores. + * + * @throws ManagementException 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 scores on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono listAsync() { + return listWithResponseAsync().flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Gets the list of advisor scores. + * + * @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 scores along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listWithResponse(Context context) { + return listWithResponseAsync(context).block(); + } + + /** + * Gets the list of advisor scores. + * + * @throws ManagementException 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 scores. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AdvisorScoreResponseInner list() { + return listWithResponse(Context.NONE).getValue(); + } + + /** + * Gets the advisor score. + * + * @param name The scope of Advisor score 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 advisor score along with {@link Response} on successful completion of {@link Mono}. + */ + @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 (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() 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(), this.client.getSubscriptionId(), name, + this.client.getApiVersion(), accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Gets the advisor score. + * + * @param name The scope of Advisor score 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 advisor score along with {@link Response} on successful completion of {@link Mono}. + */ + @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 (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() 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(), this.client.getSubscriptionId(), name, + this.client.getApiVersion(), accept, context); + } + + /** + * Gets the advisor score. + * + * @param name The scope of Advisor score 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 advisor score on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String name) { + return getWithResponseAsync(name).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Gets the advisor score. + * + * @param name The scope of Advisor score 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 advisor score along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, Context context) { + return getWithResponseAsync(name, context).block(); + } + + /** + * Gets the advisor score. + * + * @param name The scope of Advisor score 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 advisor score. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AdvisorScoreEntityInner get(String name) { + return getWithResponse(name, Context.NONE).getValue(); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoresImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoresImpl.java new file mode 100644 index 000000000000..0bd90e45ae82 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/AdvisorScoresImpl.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.implementation; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.AdvisorScoresClient; +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreEntityInner; +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreResponseInner; +import com.azure.resourcemanager.advisor.models.AdvisorScoreEntity; +import com.azure.resourcemanager.advisor.models.AdvisorScoreResponse; +import com.azure.resourcemanager.advisor.models.AdvisorScores; + +public final class AdvisorScoresImpl implements AdvisorScores { + private static final ClientLogger LOGGER = new ClientLogger(AdvisorScoresImpl.class); + + private final AdvisorScoresClient innerClient; + + private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; + + public AdvisorScoresImpl(AdvisorScoresClient innerClient, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response listWithResponse(Context context) { + Response inner = this.serviceClient().listWithResponse(context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new AdvisorScoreResponseImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public AdvisorScoreResponse list() { + AdvisorScoreResponseInner inner = this.serviceClient().list(); + if (inner != null) { + return new AdvisorScoreResponseImpl(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 AdvisorScoreEntityImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public AdvisorScoreEntity get(String name) { + AdvisorScoreEntityInner inner = this.serviceClient().get(name); + if (inner != null) { + return new AdvisorScoreEntityImpl(inner, this.manager()); + } else { + return null; + } + } + + private AdvisorScoresClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.advisor.AdvisorManager manager() { + return this.serviceManager; + } +} 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 index b9218e498a51..e96130ee34f4 100644 --- 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 @@ -4,12 +4,14 @@ package com.azure.resourcemanager.advisor.implementation; +import com.azure.core.management.SystemData; import com.azure.core.util.Context; 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 com.azure.resourcemanager.advisor.models.DurationModel; import java.util.Collections; import java.util.List; @@ -35,6 +37,10 @@ public String type() { return this.innerModel().type(); } + public SystemData systemData() { + return this.innerModel().systemData(); + } + public Boolean exclude() { return this.innerModel().exclude(); } @@ -43,6 +49,10 @@ public CpuThreshold lowCpuThreshold() { return this.innerModel().lowCpuThreshold(); } + public DurationModel duration() { + return this.innerModel().duration(); + } + public List digests() { List inner = this.innerModel().digests(); if (inner != null) { @@ -70,22 +80,18 @@ public ConfigDataImpl withExistingResourceGroup(String resourceGroup) { } public ConfigData create() { - this.innerObject = - serviceManager - .serviceClient() - .getConfigurations() - .createInResourceGroupWithResponse(configurationName, resourceGroup, this.innerModel(), Context.NONE) - .getValue(); + 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(); + this.innerObject = serviceManager.serviceClient() + .getConfigurations() + .createInResourceGroupWithResponse(configurationName, resourceGroup, this.innerModel(), context) + .getValue(); return this; } @@ -105,6 +111,11 @@ public ConfigDataImpl withLowCpuThreshold(CpuThreshold lowCpuThreshold) { return this; } + public ConfigDataImpl withDuration(DurationModel duration) { + this.innerModel().withDuration(duration); + 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 index 7fa4d4331631..2cde27c36f04 100644 --- 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 @@ -33,22 +33,28 @@ 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. */ +/** + * An instance of this class provides access to all the operations defined in ConfigurationsClient. + */ public final class ConfigurationsClientImpl implements ConfigurationsClient { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final ConfigurationsService service; - /** The service client containing this operation class. */ + /** + * 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.service + = RestProxy.create(ConfigurationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } @@ -59,183 +65,132 @@ public final class ConfigurationsClientImpl implements ConfigurationsClient { @Host("{$host}") @ServiceInterface(name = "AdvisorManagementCli") public interface ConfigurationsService { - @Headers({"Content-Type: application/json"}) + @Headers({ "Content-Type: application/json" }) @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations") - @ExpectedResponses({200}) + @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); + 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"}) + @Headers({ "Content-Type: application/json" }) @Put("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations/{configurationName}") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> createInSubscription( - @HostParam("$host") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + 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, + @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}) + @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); + 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}) + @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, + 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, + @BodyParam("application/json") ConfigDataInner configContract, @HeaderParam("Accept") String accept, Context context); - @Headers({"Content-Type: application/json"}) + @Headers({ "Content-Type: application/json" }) @Get("{nextLink}") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) Mono> listBySubscriptionNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("$host") String endpoint, - @HeaderParam("Accept") String accept, - Context context); + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, Context context); } /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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 along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listSinglePageAsync() { if (this.client.getEndpoint() == null) { - return Mono - .error( - new IllegalArgumentException( - "Parameter this.client.getEndpoint() is required and cannot be null.")); + 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 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)) + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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 along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listSinglePageAsync(Context context) { if (this.client.getEndpoint() == null) { - return Mono - .error( - new IllegalArgumentException( - "Parameter this.client.getEndpoint() is required and cannot be null.")); + 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 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, + .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)); + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); } /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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 as paginated response with {@link PagedFlux}. */ @ServiceMethod(returns = ReturnType.COLLECTION) private PagedFlux listAsync() { - return new PagedFlux<>( - () -> listSinglePageAsync(), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + return new PagedFlux<>(() -> listSinglePageAsync(), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); } /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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. @@ -244,15 +199,15 @@ private PagedFlux listAsync() { */ @ServiceMethod(returns = ReturnType.COLLECTION) private PagedFlux listAsync(Context context) { - return new PagedFlux<>( - () -> listSinglePageAsync(context), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); } /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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 as paginated response with {@link PagedIterable}. @@ -264,9 +219,9 @@ public PagedIterable list() { /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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. @@ -280,31 +235,27 @@ public PagedIterable list(Context context) { /** * Create/Overwrite Azure Advisor configuration. - * - *

Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. - * + * + * 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 Azure 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 along with {@link Response} on successful completion of {@link - * Mono}. + * @return the Advisor configuration data structure along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> createInSubscriptionWithResponseAsync( - ConfigurationName configurationName, ConfigDataInner configContract) { + 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.")); + 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 Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); } if (configurationName == null) { return Mono @@ -317,48 +268,35 @@ private Mono> createInSubscriptionWithResponseAsync( } final String accept = "application/json"; return FluxUtil - .withContext( - context -> - service - .createInSubscription( - this.client.getEndpoint(), - this.client.getApiVersion(), - this.client.getSubscriptionId(), - configurationName, - configContract, - accept, - context)) + .withContext(context -> service.createInSubscription(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), configurationName, configContract, accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * Create/Overwrite Azure Advisor configuration. - * - *

Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. - * + * + * 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 Azure 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 along with {@link Response} on successful completion of {@link - * Mono}. + * @return the Advisor configuration data structure along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> createInSubscriptionWithResponseAsync( - ConfigurationName configurationName, ConfigDataInner configContract, Context context) { + 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.")); + 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 Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); } if (configurationName == null) { return Mono @@ -371,22 +309,15 @@ private Mono> createInSubscriptionWithResponseAsync( } 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); + return service.createInSubscription(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), configurationName, configContract, accept, context); } /** * Create/Overwrite Azure Advisor configuration. - * - *

Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. - * + * + * 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 Azure Advisor configuration data structure. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -395,17 +326,17 @@ private Mono> createInSubscriptionWithResponseAsync( * @return the Advisor configuration data structure on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono createInSubscriptionAsync( - ConfigurationName configurationName, ConfigDataInner configContract) { + private Mono createInSubscriptionAsync(ConfigurationName configurationName, + ConfigDataInner configContract) { return createInSubscriptionWithResponseAsync(configurationName, configContract) .flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** * Create/Overwrite Azure Advisor configuration. - * - *

Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. - * + * + * 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 Azure Advisor configuration data structure. * @param context The context to associate with this operation. @@ -415,16 +346,16 @@ private Mono createInSubscriptionAsync( * @return the Advisor configuration data structure along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createInSubscriptionWithResponse( - ConfigurationName configurationName, ConfigDataInner configContract, Context context) { + public Response createInSubscriptionWithResponse(ConfigurationName configurationName, + ConfigDataInner configContract, Context context) { return createInSubscriptionWithResponseAsync(configurationName, configContract, context).block(); } /** * Create/Overwrite Azure Advisor configuration. - * - *

Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. - * + * + * 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 Azure Advisor configuration data structure. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -439,75 +370,57 @@ public ConfigDataInner createInSubscription(ConfigurationName configurationName, /** * 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 along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @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.")); + 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 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)) + .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)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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 along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listByResourceGroupSinglePageAsync( - String resourceGroup, Context context) { + 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.")); + 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 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.")); @@ -515,22 +428,15 @@ private Mono> listByResourceGroupSinglePageAsync( 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)); + .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. @@ -544,7 +450,7 @@ private PagedFlux listByResourceGroupAsync(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. @@ -559,7 +465,7 @@ private PagedFlux listByResourceGroupAsync(String resourceGroup /** * 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. @@ -573,7 +479,7 @@ public 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. @@ -588,30 +494,26 @@ public PagedIterable listByResourceGroup(String resourceGroup, /** * 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 Azure 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 along with {@link Response} on successful completion of {@link - * Mono}. + * @return the Advisor configuration data structure along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> createInResourceGroupWithResponseAsync( - ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract) { + 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.")); + 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 Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); } if (configurationName == null) { return Mono @@ -628,23 +530,14 @@ private Mono> createInResourceGroupWithResponseAsync( 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)) + context -> service.createInResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), configurationName, resourceGroup, configContract, accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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 Azure Advisor configuration data structure. @@ -652,23 +545,19 @@ private Mono> createInResourceGroupWithResponseAsync( * @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 along with {@link Response} on successful completion of {@link - * Mono}. + * @return the Advisor configuration data structure along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> createInResourceGroupWithResponseAsync( - ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract, Context context) { + 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.")); + 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 Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); } if (configurationName == null) { return Mono @@ -684,21 +573,13 @@ private Mono> createInResourceGroupWithResponseAsync( } 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); + 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 Azure Advisor configuration data structure. @@ -708,15 +589,15 @@ private Mono> createInResourceGroupWithResponseAsync( * @return the Advisor configuration data structure on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono createInResourceGroupAsync( - ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract) { + private Mono createInResourceGroupAsync(ConfigurationName configurationName, String resourceGroup, + ConfigDataInner configContract) { return createInResourceGroupWithResponseAsync(configurationName, resourceGroup, configContract) .flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** * 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 Azure Advisor configuration data structure. @@ -727,15 +608,15 @@ private Mono createInResourceGroupAsync( * @return the Advisor configuration data structure along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createInResourceGroupWithResponse( - ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract, Context context) { + public Response createInResourceGroupWithResponse(ConfigurationName configurationName, + String resourceGroup, ConfigDataInner configContract, Context context) { return createInResourceGroupWithResponseAsync(configurationName, resourceGroup, configContract, context) .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 Azure Advisor configuration data structure. @@ -745,22 +626,21 @@ public Response createInResourceGroupWithResponse( * @return the Advisor configuration data structure. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ConfigDataInner createInResourceGroup( - ConfigurationName configurationName, String resourceGroup, ConfigDataInner configContract) { + public ConfigDataInner createInResourceGroup(ConfigurationName configurationName, String resourceGroup, + ConfigDataInner configContract) { return createInResourceGroupWithResponse(configurationName, resourceGroup, configContract, Context.NONE) .getValue(); } /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { @@ -768,63 +648,43 @@ private Mono> listBySubscriptionNextSinglePageAsy 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.")); + 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)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listBySubscriptionNextSinglePageAsync( - String nextLink, Context context) { + 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.")); + 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)); + 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 index e11d1a6110c8..4c17cca891a4 100644 --- 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 @@ -22,31 +22,28 @@ public final class ConfigurationsImpl implements Configurations { private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; - public ConfigurationsImpl( - ConfigurationsClient innerClient, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + public ConfigurationsImpl(ConfigurationsClient innerClient, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { this.innerClient = innerClient; this.serviceManager = serviceManager; } public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); - return Utils.mapPage(inner, inner1 -> new ConfigDataImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ConfigDataImpl(inner1, this.manager())); } public PagedIterable list(Context context) { PagedIterable inner = this.serviceClient().list(context); - return Utils.mapPage(inner, inner1 -> new ConfigDataImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ConfigDataImpl(inner1, this.manager())); } - public Response createInSubscriptionWithResponse( - ConfigurationName configurationName, ConfigDataInner configContract, Context context) { - Response inner = - this.serviceClient().createInSubscriptionWithResponse(configurationName, configContract, context); + 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(), + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), new ConfigDataImpl(inner.getValue(), this.manager())); } else { return null; @@ -64,12 +61,12 @@ public ConfigData createInSubscription(ConfigurationName configurationName, Conf public PagedIterable listByResourceGroup(String resourceGroup) { PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroup); - return Utils.mapPage(inner, inner1 -> new ConfigDataImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ConfigDataImpl(inner1, this.manager())); } public PagedIterable listByResourceGroup(String resourceGroup, Context context) { PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroup, context); - return Utils.mapPage(inner, inner1 -> new ConfigDataImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ConfigDataImpl(inner1, this.manager())); } private ConfigurationsClient serviceClient() { 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 index 1267d33f97f8..4b6d8895bed0 100644 --- 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 @@ -16,8 +16,8 @@ public final class MetadataEntityImpl implements MetadataEntity { private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; - MetadataEntityImpl( - MetadataEntityInner innerObject, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + MetadataEntityImpl(MetadataEntityInner innerObject, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { this.innerObject = innerObject; this.serviceManager = 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 index 75868ffc034a..5448a683f797 100644 --- 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 @@ -13,8 +13,8 @@ public final class OperationEntityImpl implements OperationEntity { private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; - OperationEntityImpl( - OperationEntityInner innerObject, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + OperationEntityImpl(OperationEntityInner innerObject, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { this.innerObject = innerObject; this.serviceManager = 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 index a4440776cb32..a95dbd3ec500 100644 --- 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 @@ -30,22 +30,28 @@ 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. */ +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ public final class OperationsClientImpl implements OperationsClient { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final OperationsService service; - /** The service client containing this operation class. */ + /** + * 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.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } @@ -56,30 +62,25 @@ public final class OperationsClientImpl implements OperationsClient { @Host("{$host}") @ServiceInterface(name = "AdvisorManagementCli") public interface OperationsService { - @Headers({"Content-Type: application/json"}) + @Headers({ "Content-Type: application/json" }) @Get("/providers/Microsoft.Advisor/operations") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> list( - @HostParam("$host") String endpoint, - @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); + Mono> list(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - @Headers({"Content-Type: application/json"}) + @Headers({ "Content-Type: application/json" }) @Get("{nextLink}") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) Mono> listNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("$host") String endpoint, - @HeaderParam("Accept") String accept, - Context context); + @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 along with {@link PagedResponse} on successful completion of {@link Mono}. @@ -87,30 +88,21 @@ Mono> listNext( @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.")); + 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)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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. @@ -120,29 +112,19 @@ private Mono> listSinglePageAsync() { @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.")); + 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)); + 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 as paginated response with {@link PagedFlux}. @@ -154,7 +136,7 @@ private PagedFlux 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. @@ -163,13 +145,13 @@ private PagedFlux listAsync() { */ @ServiceMethod(returns = ReturnType.COLLECTION) private PagedFlux listAsync(Context context) { - return new PagedFlux<>( - () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, 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 as paginated response with {@link PagedIterable}. @@ -181,7 +163,7 @@ public 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 ManagementException thrown if the request is rejected by server. @@ -195,9 +177,8 @@ public PagedIterable list(Context context) { /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -209,31 +190,20 @@ private Mono> listNextSinglePageAsync(String 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.")); + 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)) + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -246,23 +216,13 @@ private Mono> listNextSinglePageAsync(String 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.")); + 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)); + 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 index 44b50705ef45..1d6d7a8458d0 100644 --- 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 @@ -19,20 +19,20 @@ public final class OperationsImpl implements Operations { private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; - public OperationsImpl( - OperationsClient innerClient, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + public OperationsImpl(OperationsClient innerClient, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { this.innerClient = innerClient; this.serviceManager = serviceManager; } public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); - return Utils.mapPage(inner, inner1 -> new OperationEntityImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationEntityImpl(inner1, this.manager())); } public PagedIterable list(Context context) { PagedIterable inner = this.serviceClient().list(context); - return Utils.mapPage(inner, inner1 -> new OperationEntityImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationEntityImpl(inner1, this.manager())); } private OperationsClient serviceClient() { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/PredictionResponseImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/PredictionResponseImpl.java new file mode 100644 index 000000000000..a6d10228df95 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/PredictionResponseImpl.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.resourcemanager.advisor.fluent.models.PredictionResponseInner; +import com.azure.resourcemanager.advisor.models.Category; +import com.azure.resourcemanager.advisor.models.Impact; +import com.azure.resourcemanager.advisor.models.PredictionResponse; +import com.azure.resourcemanager.advisor.models.PredictionType; +import com.azure.resourcemanager.advisor.models.ShortDescription; +import java.time.OffsetDateTime; + +public final class PredictionResponseImpl implements PredictionResponse { + private PredictionResponseInner innerObject; + + private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; + + PredictionResponseImpl(PredictionResponseInner innerObject, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public Object extendedProperties() { + return this.innerModel().extendedProperties(); + } + + public PredictionType predictionType() { + return this.innerModel().predictionType(); + } + + public Category category() { + return this.innerModel().category(); + } + + public Impact impact() { + return this.innerModel().impact(); + } + + public String impactedField() { + return this.innerModel().impactedField(); + } + + public OffsetDateTime lastUpdated() { + return this.innerModel().lastUpdated(); + } + + public ShortDescription shortDescription() { + return this.innerModel().shortDescription(); + } + + public PredictionResponseInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.advisor.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 index 02f4ffcad082..a2c1a0ad55df 100644 --- 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 @@ -30,23 +30,28 @@ 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. */ +/** + * An instance of this class provides access to all the operations defined in RecommendationMetadatasClient. + */ public final class RecommendationMetadatasClientImpl implements RecommendationMetadatasClient { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final RecommendationMetadatasService service; - /** The service client containing this operation class. */ + /** + * 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.service = RestProxy.create(RecommendationMetadatasService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); this.client = client; } @@ -57,54 +62,45 @@ public final class RecommendationMetadatasClientImpl implements RecommendationMe @Host("{$host}") @ServiceInterface(name = "AdvisorManagementCli") public interface RecommendationMetadatasService { - @Headers({"Content-Type: application/json"}) + @Headers({ "Content-Type: application/json" }) @Get("/providers/Microsoft.Advisor/metadata/{name}") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ManagementException.class, code = { 404 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> get( - @HostParam("$host") String endpoint, - @PathParam("name") String name, - @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); + 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"}) + @Headers({ "Content-Type: application/json" }) @Get("/providers/Microsoft.Advisor/metadata") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> list( - @HostParam("$host") String endpoint, - @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); + Mono> list(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - @Headers({"Content-Type: application/json"}) + @Headers({ "Content-Type: application/json" }) @Get("{nextLink}") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) Mono> listNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("$host") String endpoint, - @HeaderParam("Accept") String accept, - Context context); + @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 ManagementException thrown if the request is rejected by server on status code 404. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the metadata entity along with {@link Response} on successful completion of {@link Mono}. */ @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.")); + 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.")); @@ -118,21 +114,20 @@ private Mono> getWithResponseAsync(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 ManagementException thrown if the request is rejected by server. + * @throws ManagementException thrown if the request is rejected by server on status code 404. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the metadata entity along with {@link Response} on successful completion of {@link Mono}. */ @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.")); + 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.")); @@ -144,10 +139,11 @@ private Mono> getWithResponseAsync(String name, Co /** * 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 ManagementException thrown if the request is rejected by server on status code 404. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the metadata entity on successful completion of {@link Mono}. */ @@ -158,11 +154,12 @@ private Mono getAsync(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 ManagementException thrown if the request is rejected by server. + * @throws ManagementException thrown if the request is rejected by server on status code 404. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the metadata entity along with {@link Response}. */ @@ -173,10 +170,11 @@ public Response getWithResponse(String name, Context contex /** * 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 ManagementException thrown if the request is rejected by server on status code 404. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the metadata entity. */ @@ -187,7 +185,7 @@ public MetadataEntityInner get(String name) { /** * 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 along with {@link PagedResponse} on successful completion of {@link Mono}. @@ -195,30 +193,21 @@ public MetadataEntityInner get(String name) { @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.")); + 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)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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. @@ -228,29 +217,19 @@ private Mono> listSinglePageAsync() { @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.")); + 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)); + 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 as paginated response with {@link PagedFlux}. @@ -262,7 +241,7 @@ private PagedFlux 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. @@ -271,13 +250,13 @@ private PagedFlux listAsync() { */ @ServiceMethod(returns = ReturnType.COLLECTION) private PagedFlux listAsync(Context context) { - return new PagedFlux<>( - () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, 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 as paginated response with {@link PagedIterable}. @@ -289,7 +268,7 @@ public 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 ManagementException thrown if the request is rejected by server. @@ -303,9 +282,8 @@ public PagedIterable list(Context context) { /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -317,31 +295,20 @@ private Mono> listNextSinglePageAsync(String 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.")); + 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)) + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -354,23 +321,13 @@ private Mono> listNextSinglePageAsync(String 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.")); + 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)); + 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 index 33071af42072..342693af0eb1 100644 --- 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 @@ -21,8 +21,8 @@ public final class RecommendationMetadatasImpl implements RecommendationMetadata private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; - public RecommendationMetadatasImpl( - RecommendationMetadatasClient innerClient, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + public RecommendationMetadatasImpl(RecommendationMetadatasClient innerClient, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { this.innerClient = innerClient; this.serviceManager = serviceManager; } @@ -30,10 +30,7 @@ public RecommendationMetadatasImpl( 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(), + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), new MetadataEntityImpl(inner.getValue(), this.manager())); } else { return null; @@ -51,12 +48,12 @@ public MetadataEntity get(String name) { public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); - return Utils.mapPage(inner, inner1 -> new MetadataEntityImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new MetadataEntityImpl(inner1, this.manager())); } public PagedIterable list(Context context) { PagedIterable inner = this.serviceClient().list(context); - return Utils.mapPage(inner, inner1 -> new MetadataEntityImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new MetadataEntityImpl(inner1, this.manager())); } private RecommendationMetadatasClient serviceClient() { 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 index 2349b5e6e2c3..45c4dbaf8be2 100644 --- 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 @@ -33,22 +33,28 @@ import java.util.UUID; import reactor.core.publisher.Mono; -/** An instance of this class provides access to all the operations defined in RecommendationsClient. */ +/** + * An instance of this class provides access to all the operations defined in RecommendationsClient. + */ public final class RecommendationsClientImpl implements RecommendationsClient { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final RecommendationsService service; - /** The service client containing this operation class. */ + /** + * 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.service + = RestProxy.create(RecommendationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } @@ -59,70 +65,52 @@ public final class RecommendationsClientImpl implements RecommendationsClient { @Host("{$host}") @ServiceInterface(name = "AdvisorManagementCli") public interface RecommendationsService { - @Headers({"Content-Type: application/json"}) + @Headers({ "Content-Type: application/json" }) @Post("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations") - @ExpectedResponses({202}) + @ExpectedResponses({ 202 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono generate( - @HostParam("$host") String endpoint, - @PathParam("subscriptionId") String subscriptionId, - @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, - Context context); - - @Headers({"Content-Type: application/json"}) + Mono generate(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}") - @ExpectedResponses({202, 204}) + @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, - @HeaderParam("Accept") String accept, - Context context); - - @Headers({"Content-Type: application/json"}) + Mono> getGenerateStatus(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, @PathParam("operationId") UUID operationId, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations") - @ExpectedResponses({200}) + @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"}) + 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}) + @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"}) + 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}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) Mono> listNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("$host") String endpoint, - @HeaderParam("Accept") String accept, - Context context); + @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 A {@link Mono} that completes when a successful response is received. @@ -130,35 +118,24 @@ Mono> listNext( @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.")); + 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 Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); } final String accept = "application/json"; return FluxUtil - .withContext( - context -> - service - .generate( - this.client.getEndpoint(), - this.client.getSubscriptionId(), - this.client.getApiVersion(), - accept, - context)) + .withContext(context -> service.generate(this.client.getEndpoint(), this.client.getSubscriptionId(), + this.client.getApiVersion(), accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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. @@ -168,32 +145,23 @@ private Mono generateWithResponseAsync() { @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.")); + 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 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 - .generate( - this.client.getEndpoint(), - this.client.getSubscriptionId(), - this.client.getApiVersion(), - accept, - context); + return service.generate(this.client.getEndpoint(), this.client.getSubscriptionId(), this.client.getApiVersion(), + accept, 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 A {@link Mono} that completes when a successful response is received. @@ -206,7 +174,7 @@ private Mono generateAsync() { /** * 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. @@ -221,7 +189,7 @@ public RecommendationsGenerateResponse generateWithResponse(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. */ @@ -233,9 +201,9 @@ public void generate() { /** * 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. + * 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. @@ -244,41 +212,29 @@ public void generate() { @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.")); + 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 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.")); } final String accept = "application/json"; return FluxUtil - .withContext( - context -> - service - .getGenerateStatus( - this.client.getEndpoint(), - this.client.getSubscriptionId(), - operationId, - this.client.getApiVersion(), - accept, - context)) + .withContext(context -> service.getGenerateStatus(this.client.getEndpoint(), + this.client.getSubscriptionId(), operationId, this.client.getApiVersion(), accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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. + * 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. @@ -288,38 +244,28 @@ private Mono> getGenerateStatusWithResponseAsync(UUID operationId @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.")); + 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 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.")); } final String accept = "application/json"; context = this.client.mergeContext(context); - return service - .getGenerateStatus( - this.client.getEndpoint(), - this.client.getSubscriptionId(), - operationId, - this.client.getApiVersion(), - accept, - context); + return service.getGenerateStatus(this.client.getEndpoint(), this.client.getSubscriptionId(), operationId, + this.client.getApiVersion(), accept, 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. + * 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. @@ -333,9 +279,9 @@ private Mono getGenerateStatusAsync(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. + * 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. @@ -350,9 +296,9 @@ public Response getGenerateStatusWithResponse(UUID operationId, Context co /** * 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. + * 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. @@ -365,120 +311,81 @@ public void getGenerateStatus(UUID operationId) { /** * 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'. + * ['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 along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor recommendations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listSinglePageAsync( - String filter, Integer top, String skipToken) { + 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.")); + 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 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)) + .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)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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'. + * ['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 along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor recommendations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listSinglePageAsync( - String filter, Integer top, String skipToken, Context context) { + 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.")); + 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 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)); + .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'. + * ['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. @@ -488,14 +395,14 @@ private Mono> listSinglePageAsync */ @ServiceMethod(returns = ReturnType.COLLECTION) private PagedFlux listAsync(String filter, Integer top, String skipToken) { - return new PagedFlux<>( - () -> listSinglePageAsync(filter, top, skipToken), nextLink -> listNextSinglePageAsync(nextLink)); + 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 as paginated response with {@link PagedFlux}. @@ -505,17 +412,17 @@ 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)); + 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'. + * ['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. @@ -525,17 +432,16 @@ private PagedFlux listAsync() { * @return the list of Advisor recommendations as paginated response with {@link PagedFlux}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - private PagedFlux listAsync( - String filter, Integer top, String skipToken, Context context) { - return new PagedFlux<>( - () -> listSinglePageAsync(filter, top, skipToken, context), + 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 as paginated response with {@link PagedIterable}. @@ -551,10 +457,10 @@ public 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'. + * ['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. @@ -564,16 +470,16 @@ public PagedIterable list() { * @return the list of Advisor recommendations as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable list( - String filter, Integer top, String skipToken, Context context) { + 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. + * 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. @@ -581,13 +487,11 @@ public PagedIterable list( * @return advisor Recommendation along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> getWithResponseAsync( - String resourceUri, String recommendationId) { + 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.")); + 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.")); @@ -598,24 +502,16 @@ private Mono> getWithResponseAsync( } final String accept = "application/json"; return FluxUtil - .withContext( - context -> - service - .get( - this.client.getEndpoint(), - resourceUri, - recommendationId, - this.client.getApiVersion(), - accept, - context)) + .withContext(context -> service.get(this.client.getEndpoint(), resourceUri, recommendationId, + this.client.getApiVersion(), accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * Obtains details of a cached recommendation. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * recommendation applies. * @param recommendationId The recommendation ID. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -624,13 +520,11 @@ private Mono> getWithResponseAsync( * @return advisor Recommendation along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> getWithResponseAsync( - String resourceUri, String recommendationId, Context context) { + 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.")); + 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.")); @@ -641,16 +535,15 @@ private Mono> getWithResponseAsync( } final String accept = "application/json"; context = this.client.mergeContext(context); - return service - .get( - this.client.getEndpoint(), resourceUri, recommendationId, this.client.getApiVersion(), accept, 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. + * 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. @@ -664,9 +557,9 @@ private Mono getAsync(String resourceUri, Strin /** * Obtains details of a cached recommendation. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * recommendation applies. * @param recommendationId The recommendation ID. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -675,16 +568,16 @@ private Mono getAsync(String resourceUri, Strin * @return advisor Recommendation along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse( - String resourceUri, String recommendationId, Context context) { + public Response getWithResponse(String resourceUri, String recommendationId, + Context context) { return getWithResponseAsync(resourceUri, recommendationId, context).block(); } /** * Obtains details of a cached recommendation. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * 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. @@ -698,14 +591,13 @@ public ResourceRecommendationBaseInner get(String resourceUri, String recommenda /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of Advisor recommendations along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor recommendations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listNextSinglePageAsync(String nextLink) { @@ -713,62 +605,41 @@ private Mono> listNextSinglePageA 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.")); + 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)) + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of Advisor recommendations along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor recommendations along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listNextSinglePageAsync( - String nextLink, Context context) { + 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.")); + 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)); + 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 index 953037885d29..11d4c4fc1b0d 100644 --- 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 @@ -23,8 +23,8 @@ public final class RecommendationsImpl implements Recommendations { private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; - public RecommendationsImpl( - RecommendationsClient innerClient, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + public RecommendationsImpl(RecommendationsClient innerClient, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { this.innerClient = innerClient; this.serviceManager = serviceManager; } @@ -47,25 +47,24 @@ public void getGenerateStatus(UUID operationId) { public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); - return Utils.mapPage(inner, inner1 -> new ResourceRecommendationBaseImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, + 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 Utils.mapPage(inner, 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 ResourceManagerUtils.mapPage(inner, + inner1 -> new ResourceRecommendationBaseImpl(inner1, this.manager())); } - public Response getWithResponse( - String resourceUri, String recommendationId, Context context) { - Response inner = - this.serviceClient().getWithResponse(resourceUri, recommendationId, context); + 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(), + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), new ResourceRecommendationBaseImpl(inner.getValue(), this.manager())); } else { return null; 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/ResourceManagerUtils.java similarity index 79% rename from sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/Utils.java rename to sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceManagerUtils.java index cd4d94d8e908..b191ad151124 100644 --- 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/ResourceManagerUtils.java @@ -19,7 +19,10 @@ import java.util.stream.Stream; import reactor.core.publisher.Flux; -final class Utils { +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + static String getValueFromIdByName(String id, String name) { if (id == null) { return null; @@ -60,7 +63,7 @@ static String getValueFromIdByParameterName(String id, String pathTemplate, Stri segments.add(idSegment); idItrReverted.forEachRemaining(segments::add); Collections.reverse(segments); - if (segments.size() > 0 && segments.get(0).isEmpty()) { + if (!segments.isEmpty() && segments.get(0).isEmpty()) { segments.remove(0); } return String.join("/", segments); @@ -74,7 +77,7 @@ static String getValueFromIdByParameterName(String id, String pathTemplate, Stri } static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { - return new PagedIterableImpl(pageIterable, mapper); + return new PagedIterableImpl<>(pageIterable, mapper); } private static final class PagedIterableImpl extends PagedIterable { @@ -84,26 +87,17 @@ private static final class PagedIterableImpl extends PagedIterable { private final Function, PagedResponse> pageMapper; private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { - super( - PagedFlux - .create( - () -> - (continuationToken, pageSize) -> - Flux.fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); this.pagedIterable = pagedIterable; this.mapper = mapper; this.pageMapper = getPageMapper(mapper); } private static Function, PagedResponse> getPageMapper(Function mapper) { - return page -> - new PagedResponseBase( - page.getRequest(), - page.getStatusCode(), - page.getHeaders(), - page.getElements().stream().map(mapper).collect(Collectors.toList()), - page.getContinuationToken(), - null); + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); } @Override @@ -133,30 +127,27 @@ public Stream> streamByPage(String continuationToken, int prefe @Override public Iterator iterator() { - return new IteratorImpl(pagedIterable.iterator(), mapper); + return new IteratorImpl<>(pagedIterable.iterator(), mapper); } @Override public Iterable> iterableByPage() { - return new IterableImpl, PagedResponse>(pagedIterable.iterableByPage(), pageMapper); + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); } @Override public Iterable> iterableByPage(String continuationToken) { - return new IterableImpl, PagedResponse>( - pagedIterable.iterableByPage(continuationToken), pageMapper); + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); } @Override public Iterable> iterableByPage(int preferredPageSize) { - return new IterableImpl, PagedResponse>( - pagedIterable.iterableByPage(preferredPageSize), pageMapper); + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); } @Override public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { - return new IterableImpl, PagedResponse>( - pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); } } @@ -198,7 +189,7 @@ private IterableImpl(Iterable iterable, Function mapper) { @Override public Iterator iterator() { - return new IteratorImpl(iterable.iterator(), mapper); + return new IteratorImpl<>(iterable.iterator(), mapper); } } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceProvidersClientImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceProvidersClientImpl.java new file mode 100644 index 000000000000..9c947fb615be --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceProvidersClientImpl.java @@ -0,0 +1,179 @@ +// 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.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.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.advisor.fluent.ResourceProvidersClient; +import com.azure.resourcemanager.advisor.fluent.models.PredictionResponseInner; +import com.azure.resourcemanager.advisor.models.PredictionRequest; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ResourceProvidersClient. + */ +public final class ResourceProvidersClientImpl implements ResourceProvidersClient { + /** + * The proxy service used to perform REST calls. + */ + private final ResourceProvidersService service; + + /** + * The service client containing this operation class. + */ + private final AdvisorManagementClientImpl client; + + /** + * Initializes an instance of ResourceProvidersClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ResourceProvidersClientImpl(AdvisorManagementClientImpl client) { + this.service + = RestProxy.create(ResourceProvidersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdvisorManagementClientResourceProviders to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AdvisorManagementCli") + public interface ResourceProvidersService { + @Headers({ "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/predict") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> predict(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") PredictionRequest predictionRequest, @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Predicts a recommendation. + * + * @param predictionRequest Parameters for predict recommendation. + * @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 response used by predictions along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> predictWithResponseAsync(PredictionRequest predictionRequest) { + 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 (predictionRequest == null) { + return Mono + .error(new IllegalArgumentException("Parameter predictionRequest is required and cannot be null.")); + } else { + predictionRequest.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.predict(this.client.getEndpoint(), this.client.getSubscriptionId(), + this.client.getApiVersion(), predictionRequest, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Predicts a recommendation. + * + * @param predictionRequest Parameters for predict recommendation. + * @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 response used by predictions along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> predictWithResponseAsync(PredictionRequest predictionRequest, + 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 (predictionRequest == null) { + return Mono + .error(new IllegalArgumentException("Parameter predictionRequest is required and cannot be null.")); + } else { + predictionRequest.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.predict(this.client.getEndpoint(), this.client.getSubscriptionId(), this.client.getApiVersion(), + predictionRequest, accept, context); + } + + /** + * Predicts a recommendation. + * + * @param predictionRequest Parameters for predict recommendation. + * @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 response used by predictions on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono predictAsync(PredictionRequest predictionRequest) { + return predictWithResponseAsync(predictionRequest).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Predicts a recommendation. + * + * @param predictionRequest Parameters for predict recommendation. + * @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 response used by predictions along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response predictWithResponse(PredictionRequest predictionRequest, Context context) { + return predictWithResponseAsync(predictionRequest, context).block(); + } + + /** + * Predicts a recommendation. + * + * @param predictionRequest Parameters for predict recommendation. + * @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 response used by predictions. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public PredictionResponseInner predict(PredictionRequest predictionRequest) { + return predictWithResponse(predictionRequest, Context.NONE).getValue(); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceProvidersImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceProvidersImpl.java new file mode 100644 index 000000000000..8352ed22472e --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/ResourceProvidersImpl.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.implementation; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.fluent.ResourceProvidersClient; +import com.azure.resourcemanager.advisor.fluent.models.PredictionResponseInner; +import com.azure.resourcemanager.advisor.models.PredictionRequest; +import com.azure.resourcemanager.advisor.models.PredictionResponse; +import com.azure.resourcemanager.advisor.models.ResourceProviders; + +public final class ResourceProvidersImpl implements ResourceProviders { + private static final ClientLogger LOGGER = new ClientLogger(ResourceProvidersImpl.class); + + private final ResourceProvidersClient innerClient; + + private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; + + public ResourceProvidersImpl(ResourceProvidersClient innerClient, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response predictWithResponse(PredictionRequest predictionRequest, Context context) { + Response inner = this.serviceClient().predictWithResponse(predictionRequest, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new PredictionResponseImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public PredictionResponse predict(PredictionRequest predictionRequest) { + PredictionResponseInner inner = this.serviceClient().predict(predictionRequest); + if (inner != null) { + return new PredictionResponseImpl(inner, this.manager()); + } else { + return null; + } + } + + private ResourceProvidersClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.advisor.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 index 29b11cc28995..60ce7da5e42d 100644 --- 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 @@ -4,11 +4,13 @@ package com.azure.resourcemanager.advisor.implementation; +import com.azure.core.management.SystemData; 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; @@ -21,8 +23,8 @@ public final class ResourceRecommendationBaseImpl implements ResourceRecommendat private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; - ResourceRecommendationBaseImpl( - ResourceRecommendationBaseInner innerObject, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + ResourceRecommendationBaseImpl(ResourceRecommendationBaseInner innerObject, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { this.innerObject = innerObject; this.serviceManager = serviceManager; } @@ -39,6 +41,10 @@ public String type() { return this.innerModel().type(); } + public SystemData systemData() { + return this.innerModel().systemData(); + } + public Category category() { return this.innerModel().category(); } @@ -72,6 +78,10 @@ public String recommendationTypeId() { return this.innerModel().recommendationTypeId(); } + public Risk risk() { + return this.innerModel().risk(); + } + public ShortDescription shortDescription() { return this.innerModel().shortDescription(); } 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 index ba6ff3759533..ad8c1a0d62dd 100644 --- 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 @@ -4,6 +4,7 @@ package com.azure.resourcemanager.advisor.implementation; +import com.azure.core.management.SystemData; import com.azure.core.util.Context; import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; import com.azure.resourcemanager.advisor.models.SuppressionContract; @@ -14,8 +15,8 @@ public final class SuppressionContractImpl implements SuppressionContract, Suppr private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; - SuppressionContractImpl( - SuppressionContractInner innerObject, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + SuppressionContractImpl(SuppressionContractInner innerObject, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { this.innerObject = innerObject; this.serviceManager = serviceManager; } @@ -32,6 +33,10 @@ public String type() { return this.innerModel().type(); } + public SystemData systemData() { + return this.innerModel().systemData(); + } + public String suppressionId() { return this.innerModel().suppressionId(); } @@ -65,22 +70,18 @@ public SuppressionContractImpl withExistingRecommendation(String resourceUri, St } public SuppressionContract create() { - this.innerObject = - serviceManager - .serviceClient() - .getSuppressions() - .createWithResponse(resourceUri, recommendationId, name, this.innerModel(), Context.NONE) - .getValue(); + this.innerObject = serviceManager.serviceClient() + .getSuppressions() + .createWithResponse(resourceUri, recommendationId, name, this.innerModel(), Context.NONE) + .getValue(); return this; } public SuppressionContract create(Context context) { - this.innerObject = - serviceManager - .serviceClient() - .getSuppressions() - .createWithResponse(resourceUri, recommendationId, name, this.innerModel(), context) - .getValue(); + this.innerObject = serviceManager.serviceClient() + .getSuppressions() + .createWithResponse(resourceUri, recommendationId, name, this.innerModel(), context) + .getValue(); return this; } @@ -91,22 +92,18 @@ public SuppressionContract create(Context context) { } public SuppressionContract refresh() { - this.innerObject = - serviceManager - .serviceClient() - .getSuppressions() - .getWithResponse(resourceUri, recommendationId, name, Context.NONE) - .getValue(); + this.innerObject = serviceManager.serviceClient() + .getSuppressions() + .getWithResponse(resourceUri, recommendationId, name, Context.NONE) + .getValue(); return this; } public SuppressionContract refresh(Context context) { - this.innerObject = - serviceManager - .serviceClient() - .getSuppressions() - .getWithResponse(resourceUri, recommendationId, name, context) - .getValue(); + this.innerObject = serviceManager.serviceClient() + .getSuppressions() + .getWithResponse(resourceUri, recommendationId, name, context) + .getValue(); return this; } 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 index a28eb40ff373..c0c5ad180f11 100644 --- 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 @@ -33,22 +33,28 @@ 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. */ +/** + * An instance of this class provides access to all the operations defined in SuppressionsClient. + */ public final class SuppressionsClientImpl implements SuppressionsClient { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final SuppressionsService service; - /** The service client containing this operation class. */ + /** + * 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.service + = RestProxy.create(SuppressionsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } @@ -59,91 +65,73 @@ public final class SuppressionsClientImpl implements SuppressionsClient { @Host("{$host}") @ServiceInterface(name = "AdvisorManagementCli") public interface SuppressionsService { - @Headers({"Content-Type: application/json"}) + @Headers({ "Content-Type: application/json" }) @Get("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}") - @ExpectedResponses({200}) + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ManagementException.class, code = { 404 }) @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"}) + 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}) + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ManagementException.class, code = { 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, + 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); + @HeaderParam("Accept") String accept, Context context); - @Headers({"Content-Type: application/json"}) + @Headers({ "Content-Type: application/json" }) @Delete("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}") - @ExpectedResponses({204}) + @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, - @HeaderParam("Accept") String accept, - Context context); - - @Headers({"Content-Type: application/json"}) + Mono> delete(@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" }) @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions") - @ExpectedResponses({200}) + @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"}) + 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}) + @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) Mono> listNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("$host") String endpoint, - @HeaderParam("Accept") String accept, - Context context); + @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. + * 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 ManagementException thrown if the request is rejected by server on status code 404. * @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 along with {@link Response} on successful completion of {@link Mono}. + * the rule along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> getWithResponseAsync( - String resourceUri, String recommendationId, String name) { + 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.")); + 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.")); @@ -157,42 +145,32 @@ private Mono> getWithResponseAsync( } final String accept = "application/json"; return FluxUtil - .withContext( - context -> - service - .get( - this.client.getEndpoint(), - resourceUri, - recommendationId, - name, - this.client.getApiVersion(), - accept, - context)) + .withContext(context -> service.get(this.client.getEndpoint(), resourceUri, recommendationId, name, + this.client.getApiVersion(), accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * Obtains the details of a suppression. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * 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 ManagementException thrown if the request is rejected by server on status code 404. * @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 along with {@link Response} on successful completion of {@link Mono}. + * the rule along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> getWithResponseAsync( - String resourceUri, String recommendationId, String name, Context context) { + 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.")); + 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.")); @@ -206,29 +184,23 @@ private Mono> getWithResponseAsync( } final String accept = "application/json"; context = this.client.mergeContext(context); - return service - .get( - this.client.getEndpoint(), - resourceUri, - recommendationId, - name, - this.client.getApiVersion(), - accept, - 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. + * 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 ManagementException thrown if the request is rejected by server on status code 404. * @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 on successful completion of {@link Mono}. + * the rule on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono getAsync(String resourceUri, String recommendationId, String name) { @@ -238,36 +210,38 @@ private Mono getAsync(String resourceUri, String recom /** * Obtains the details of a suppression. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * 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 ManagementException thrown if the request is rejected by server on status code 404. * @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 along with {@link Response}. + * the rule along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse( - String resourceUri, String recommendationId, String name, Context context) { + public Response getWithResponse(String resourceUri, String recommendationId, String name, + Context context) { return getWithResponseAsync(resourceUri, recommendationId, name, context).block(); } /** * Obtains the details of a suppression. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * 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 ManagementException thrown if the request is rejected by server on status code 404. * @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. + * the rule. */ @ServiceMethod(returns = ReturnType.SINGLE) public SuppressionContractInner get(String resourceUri, String recommendationId, String name) { @@ -277,26 +251,25 @@ public SuppressionContractInner get(String resourceUri, String recommendationId, /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. + * @throws ManagementException thrown if the request is rejected by server on status code 404. * @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 along with {@link Response} on successful completion of {@link Mono}. + * the rule along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> createWithResponseAsync( - String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + 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.")); + 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.")); @@ -316,49 +289,34 @@ private Mono> createWithResponseAsync( } final String accept = "application/json"; return FluxUtil - .withContext( - context -> - service - .create( - this.client.getEndpoint(), - resourceUri, - recommendationId, - name, - this.client.getApiVersion(), - suppressionContract, - accept, - context)) + .withContext(context -> service.create(this.client.getEndpoint(), resourceUri, recommendationId, name, + this.client.getApiVersion(), suppressionContract, accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. * @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 ManagementException thrown if the request is rejected by server on status code 404. * @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 along with {@link Response} on successful completion of {@link Mono}. + * the rule along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> createWithResponseAsync( - String resourceUri, - String recommendationId, - String name, - SuppressionContractInner suppressionContract, - Context context) { + 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.")); + 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.")); @@ -378,36 +336,29 @@ private Mono> createWithResponseAsync( } 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); + 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. + * @throws ManagementException thrown if the request is rejected by server on status code 404. * @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 on successful completion of {@link Mono}. + * the rule on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono createAsync( - String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + private Mono createAsync(String resourceUri, String recommendationId, String name, + SuppressionContractInner suppressionContract) { return createWithResponseAsync(resourceUri, recommendationId, name, suppressionContract) .flatMap(res -> Mono.justOrEmpty(res.getValue())); } @@ -415,56 +366,54 @@ private Mono createAsync( /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. * @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 ManagementException thrown if the request is rejected by server on status code 404. * @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 along with {@link Response}. + * the rule along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createWithResponse( - String resourceUri, - String recommendationId, - String name, - SuppressionContractInner suppressionContract, - Context context) { + public Response createWithResponse(String resourceUri, String recommendationId, + String name, SuppressionContractInner suppressionContract, Context context) { return createWithResponseAsync(resourceUri, recommendationId, name, suppressionContract, 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. + * @throws ManagementException thrown if the request is rejected by server on status code 404. * @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. + * the rule. */ @ServiceMethod(returns = ReturnType.SINGLE) - public SuppressionContractInner create( - String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + public SuppressionContractInner create(String resourceUri, String recommendationId, String name, + SuppressionContractInner suppressionContract) { return createWithResponse(resourceUri, recommendationId, name, suppressionContract, Context.NONE).getValue(); } /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -475,10 +424,8 @@ public SuppressionContractInner create( @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.")); + 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.")); @@ -492,26 +439,17 @@ private Mono> deleteWithResponseAsync(String resourceUri, String } final String accept = "application/json"; return FluxUtil - .withContext( - context -> - service - .delete( - this.client.getEndpoint(), - resourceUri, - recommendationId, - name, - this.client.getApiVersion(), - accept, - context)) + .withContext(context -> service.delete(this.client.getEndpoint(), resourceUri, recommendationId, name, + this.client.getApiVersion(), accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param context The context to associate with this operation. @@ -521,13 +459,11 @@ private Mono> deleteWithResponseAsync(String resourceUri, String * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> deleteWithResponseAsync( - String resourceUri, String recommendationId, String name, Context context) { + 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.")); + 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.")); @@ -541,23 +477,16 @@ private Mono> deleteWithResponseAsync( } final String accept = "application/json"; context = this.client.mergeContext(context); - return service - .delete( - this.client.getEndpoint(), - resourceUri, - recommendationId, - name, - this.client.getApiVersion(), - accept, - context); + return service.delete(this.client.getEndpoint(), resourceUri, recommendationId, name, + this.client.getApiVersion(), accept, 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -573,9 +502,9 @@ private Mono deleteAsync(String resourceUri, String recommendationId, Stri /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param context The context to associate with this operation. @@ -585,17 +514,17 @@ private Mono deleteAsync(String resourceUri, String recommendationId, Stri * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteWithResponse( - String resourceUri, String recommendationId, String name, Context context) { + public Response deleteWithResponse(String resourceUri, String recommendationId, String name, + Context context) { return deleteWithResponseAsync(resourceUri, recommendationId, name, 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -610,108 +539,71 @@ public void delete(String resourceUri, String recommendationId, String name) { /** * 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 along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor suppressions along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @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.")); + 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 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)) + .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)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * 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 along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor suppressions along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listSinglePageAsync( - Integer top, String skipToken, Context context) { + 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.")); + 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 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)); + .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. @@ -721,14 +613,14 @@ private Mono> listSinglePageAsync( */ @ServiceMethod(returns = ReturnType.COLLECTION) private PagedFlux listAsync(Integer top, String skipToken) { - return new PagedFlux<>( - () -> listSinglePageAsync(top, skipToken), nextLink -> listNextSinglePageAsync(nextLink)); + 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 as paginated response with {@link PagedFlux}. @@ -737,14 +629,14 @@ private PagedFlux listAsync(Integer top, String skipTo private PagedFlux listAsync() { final Integer top = null; final String skipToken = null; - return new PagedFlux<>( - () -> listSinglePageAsync(top, skipToken), nextLink -> listNextSinglePageAsync(nextLink)); + 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. @@ -755,14 +647,14 @@ private PagedFlux listAsync() { */ @ServiceMethod(returns = ReturnType.COLLECTION) private PagedFlux listAsync(Integer top, String skipToken, Context context) { - return new PagedFlux<>( - () -> listSinglePageAsync(top, skipToken, context), nextLink -> listNextSinglePageAsync(nextLink, 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 as paginated response with {@link PagedIterable}. @@ -777,7 +669,7 @@ public 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. @@ -793,14 +685,13 @@ public PagedIterable list(Integer top, String skipToke /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of Advisor suppressions along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor suppressions along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listNextSinglePageAsync(String nextLink) { @@ -808,37 +699,26 @@ private Mono> listNextSinglePageAsync(St 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.")); + 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)) + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** * Get the next page of items. - * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. + * + * @param nextLink The URL to get the next list of items. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of Advisor suppressions along with {@link PagedResponse} on successful completion of {@link - * Mono}. + * @return the list of Advisor suppressions along with {@link PagedResponse} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listNextSinglePageAsync(String nextLink, Context context) { @@ -846,23 +726,13 @@ private Mono> listNextSinglePageAsync(St 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.")); + 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)); + 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 index b68c14218b33..331bb004d811 100644 --- 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 @@ -21,21 +21,18 @@ public final class SuppressionsImpl implements Suppressions { private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager; - public SuppressionsImpl( - SuppressionsClient innerClient, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { + public SuppressionsImpl(SuppressionsClient innerClient, + com.azure.resourcemanager.advisor.AdvisorManager serviceManager) { this.innerClient = innerClient; this.serviceManager = serviceManager; } - public Response getWithResponse( - String resourceUri, String recommendationId, String name, Context context) { - Response inner = - this.serviceClient().getWithResponse(resourceUri, recommendationId, name, context); + 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(), + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), new SuppressionContractImpl(inner.getValue(), this.manager())); } else { return null; @@ -51,8 +48,8 @@ public SuppressionContract get(String resourceUri, String recommendationId, Stri } } - public Response deleteWithResponse( - String resourceUri, String recommendationId, String name, Context context) { + public Response deleteWithResponse(String resourceUri, String recommendationId, String name, + Context context) { return this.serviceClient().deleteWithResponse(resourceUri, recommendationId, name, context); } @@ -62,174 +59,110 @@ public void delete(String resourceUri, String recommendationId, String name) { public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); - return Utils.mapPage(inner, inner1 -> new SuppressionContractImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SuppressionContractImpl(inner1, this.manager())); } public PagedIterable list(Integer top, String skipToken, Context context) { PagedIterable inner = this.serviceClient().list(top, skipToken, context); - return Utils.mapPage(inner, inner1 -> new SuppressionContractImpl(inner1, this.manager())); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SuppressionContractImpl(inner1, this.manager())); } public SuppressionContract getById(String id) { - String resourceUri = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "resourceUri"); + String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "resourceUri"); if (resourceUri == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); } - String recommendationId = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "recommendationId"); + String recommendationId = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "recommendationId"); if (recommendationId == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String - .format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id))); } - String name = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "name"); + String name = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "name"); if (name == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id))); } return this.getWithResponse(resourceUri, recommendationId, name, Context.NONE).getValue(); } public Response getByIdWithResponse(String id, Context context) { - String resourceUri = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "resourceUri"); + String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "resourceUri"); if (resourceUri == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); } - String recommendationId = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "recommendationId"); + String recommendationId = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "recommendationId"); if (recommendationId == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String - .format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id))); } - String name = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "name"); + String name = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "name"); if (name == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id))); } return this.getWithResponse(resourceUri, recommendationId, name, context); } public void deleteById(String id) { - String resourceUri = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "resourceUri"); + String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "resourceUri"); if (resourceUri == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); } - String recommendationId = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "recommendationId"); + String recommendationId = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "recommendationId"); if (recommendationId == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String - .format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id))); } - String name = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "name"); + String name = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "name"); if (name == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id))); } this.deleteWithResponse(resourceUri, recommendationId, name, Context.NONE); } public Response deleteByIdWithResponse(String id, Context context) { - String resourceUri = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "resourceUri"); + String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "resourceUri"); if (resourceUri == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); } - String recommendationId = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "recommendationId"); + String recommendationId = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "recommendationId"); if (recommendationId == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String - .format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id))); } - String name = - Utils - .getValueFromIdByParameterName( - id, - "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - "name"); + String name = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + "name"); if (name == null) { - throw LOGGER - .logExceptionAsError( - new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id))); + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id))); } return this.deleteWithResponse(resourceUri, recommendationId, name, context); } 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 index b35391d8b1bb..cf79ade45a1e 100644 --- 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 @@ -2,5 +2,8 @@ // 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 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/AdvisorScoreEntity.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScoreEntity.java new file mode 100644 index 000000000000..62a74e0fa6c3 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScoreEntity.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.management.SystemData; +import com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreEntityInner; + +/** + * An immutable client-side representation of AdvisorScoreEntity. + */ +public interface AdvisorScoreEntity { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The Advisor score data. + * + * @return the properties value. + */ + AdvisorScoreEntityProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the inner com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreEntityInner object. + * + * @return the inner object. + */ + AdvisorScoreEntityInner innerModel(); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScoreEntityProperties.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScoreEntityProperties.java new file mode 100644 index 000000000000..ee3f57320e60 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScoreEntityProperties.java @@ -0,0 +1,130 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The Advisor score data. + */ +@Fluent +public final class AdvisorScoreEntityProperties implements JsonSerializable { + /* + * The details of latest available score. + */ + private ScoreEntity lastRefreshedScore; + + /* + * The historic Advisor score data. + */ + private List timeSeries; + + /** + * Creates an instance of AdvisorScoreEntityProperties class. + */ + public AdvisorScoreEntityProperties() { + } + + /** + * Get the lastRefreshedScore property: The details of latest available score. + * + * @return the lastRefreshedScore value. + */ + public ScoreEntity lastRefreshedScore() { + return this.lastRefreshedScore; + } + + /** + * Set the lastRefreshedScore property: The details of latest available score. + * + * @param lastRefreshedScore the lastRefreshedScore value to set. + * @return the AdvisorScoreEntityProperties object itself. + */ + public AdvisorScoreEntityProperties withLastRefreshedScore(ScoreEntity lastRefreshedScore) { + this.lastRefreshedScore = lastRefreshedScore; + return this; + } + + /** + * Get the timeSeries property: The historic Advisor score data. + * + * @return the timeSeries value. + */ + public List timeSeries() { + return this.timeSeries; + } + + /** + * Set the timeSeries property: The historic Advisor score data. + * + * @param timeSeries the timeSeries value to set. + * @return the AdvisorScoreEntityProperties object itself. + */ + public AdvisorScoreEntityProperties withTimeSeries(List timeSeries) { + this.timeSeries = timeSeries; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (lastRefreshedScore() != null) { + lastRefreshedScore().validate(); + } + if (timeSeries() != null) { + timeSeries().forEach(e -> e.validate()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("lastRefreshedScore", this.lastRefreshedScore); + jsonWriter.writeArrayField("timeSeries", this.timeSeries, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AdvisorScoreEntityProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AdvisorScoreEntityProperties if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the AdvisorScoreEntityProperties. + */ + public static AdvisorScoreEntityProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AdvisorScoreEntityProperties deserializedAdvisorScoreEntityProperties = new AdvisorScoreEntityProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("lastRefreshedScore".equals(fieldName)) { + deserializedAdvisorScoreEntityProperties.lastRefreshedScore = ScoreEntity.fromJson(reader); + } else if ("timeSeries".equals(fieldName)) { + List timeSeries + = reader.readArray(reader1 -> TimeSeriesEntityItem.fromJson(reader1)); + deserializedAdvisorScoreEntityProperties.timeSeries = timeSeries; + } else { + reader.skipChildren(); + } + } + + return deserializedAdvisorScoreEntityProperties; + }); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScoreResponse.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScoreResponse.java new file mode 100644 index 000000000000..8398e34729bd --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScoreResponse.java @@ -0,0 +1,27 @@ +// 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.AdvisorScoreResponseInner; +import java.util.List; + +/** + * An immutable client-side representation of AdvisorScoreResponse. + */ +public interface AdvisorScoreResponse { + /** + * Gets the value property: The list of operations. + * + * @return the value value. + */ + List value(); + + /** + * Gets the inner com.azure.resourcemanager.advisor.fluent.models.AdvisorScoreResponseInner object. + * + * @return the inner object. + */ + AdvisorScoreResponseInner innerModel(); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScores.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScores.java new file mode 100644 index 000000000000..05526e75efa5 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/AdvisorScores.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of AdvisorScores. + */ +public interface AdvisorScores { + /** + * Gets the list of advisor scores. + * + * @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 scores along with {@link Response}. + */ + Response listWithResponse(Context context); + + /** + * Gets the list of advisor scores. + * + * @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 scores. + */ + AdvisorScoreResponse list(); + + /** + * Gets the advisor score. + * + * @param name The scope of Advisor score 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 advisor score along with {@link Response}. + */ + Response getWithResponse(String name, Context context); + + /** + * Gets the advisor score. + * + * @param name The scope of Advisor score 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 advisor score. + */ + AdvisorScoreEntity get(String name); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Aggregated.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Aggregated.java new file mode 100644 index 000000000000..442aee2a065d --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Aggregated.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The aggregation level of the score. + */ +public final class Aggregated extends ExpandableStringEnum { + /** + * Static value week for Aggregated. + */ + public static final Aggregated WEEK = fromString("week"); + + /** + * Static value day for Aggregated. + */ + public static final Aggregated DAY = fromString("day"); + + /** + * Static value month for Aggregated. + */ + public static final Aggregated MONTH = fromString("month"); + + /** + * Creates a new instance of Aggregated value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Aggregated() { + } + + /** + * Creates or finds a Aggregated from its string representation. + * + * @param name a name to look for. + * @return the corresponding Aggregated. + */ + public static Aggregated fromString(String name) { + return fromString(name, Aggregated.class); + } + + /** + * Gets known Aggregated values. + * + * @return known Aggregated values. + */ + public static Collection values() { + return values(Aggregated.class); + } +} 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 index ac22b1be5e50..bbec11a481f6 100644 --- 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 @@ -5,29 +5,40 @@ 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. */ +/** + * Defines values for Category. + */ public final class Category extends ExpandableStringEnum { - /** Static value HighAvailability for Category. */ + /** + * Static value HighAvailability for Category. + */ public static final Category HIGH_AVAILABILITY = fromString("HighAvailability"); - /** Static value Security for Category. */ + /** + * Static value Security for Category. + */ public static final Category SECURITY = fromString("Security"); - /** Static value Performance for Category. */ + /** + * Static value Performance for Category. + */ public static final Category PERFORMANCE = fromString("Performance"); - /** Static value Cost for Category. */ + /** + * Static value Cost for Category. + */ public static final Category COST = fromString("Cost"); - /** Static value OperationalExcellence for Category. */ + /** + * Static value OperationalExcellence for Category. + */ public static final Category OPERATIONAL_EXCELLENCE = fromString("OperationalExcellence"); /** * Creates a new instance of Category value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated @@ -36,18 +47,17 @@ public Category() { /** * 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); } /** * Gets known Category values. - * + * * @return known Category values. */ public static Collection values() { 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 index 361cfec26f17..9d9ef4881dc0 100644 --- 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 @@ -4,36 +4,46 @@ package com.azure.resourcemanager.advisor.models; +import com.azure.core.management.SystemData; 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. */ +/** + * 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 systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + /** * Gets the exclude property: Exclude the resource from Advisor evaluations. Valid values: False (default) or True. - * + * * @return the exclude value. */ Boolean exclude(); @@ -41,93 +51,136 @@ public interface ConfigData { /** * 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 duration property: Minimum duration for Advisor low CPU utilization evaluation. Valid only for + * subscriptions. Valid values: 7 (default), 14, 21, 30, 60 or 90. + * + * @return the duration value. + */ + DurationModel duration(); + /** * 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. */ + /** + * The entirety of the ConfigData definition. + */ interface Definition extends DefinitionStages.Blank, DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { } - /** The ConfigData definition stages. */ + + /** + * The ConfigData definition stages. + */ interface DefinitionStages { - /** The first stage of the ConfigData definition. */ + /** + * The first stage of the ConfigData definition. + */ interface Blank extends WithResourceGroup { } - /** The stage of the ConfigData definition allowing to specify parent resource. */ + + /** + * 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 { + interface WithCreate extends DefinitionStages.WithExclude, DefinitionStages.WithLowCpuThreshold, + DefinitionStages.WithDuration, 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. */ + + /** + * 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. */ + + /** + * 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. + * 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. */ + + /** + * The stage of the ConfigData definition allowing to specify duration. + */ + interface WithDuration { + /** + * Specifies the duration property: Minimum duration for Advisor low CPU utilization evaluation. Valid only + * for subscriptions. Valid values: 7 (default), 14, 21, 30, 60 or 90.. + * + * @param duration Minimum duration for Advisor low CPU utilization evaluation. Valid only for + * subscriptions. Valid values: 7 (default), 14, 21, 30, 60 or 90. + * @return the next definition stage. + */ + WithCreate withDuration(DurationModel duration); + } + + /** + * 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. */ 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 index 478e14e71a6a..abcd2de8d78f 100644 --- 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 @@ -5,32 +5,38 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; import java.util.List; -/** The list of Advisor configurations. */ +/** + * The list of Advisor configurations. + */ @Fluent -public final class ConfigurationListResult { +public final class ConfigurationListResult implements JsonSerializable { /* * 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; - /** Creates an instance of ConfigurationListResult class. */ + /** + * Creates an instance of ConfigurationListResult class. + */ public ConfigurationListResult() { } /** * Get the value property: The list of configurations. - * + * * @return the value value. */ public List value() { @@ -39,7 +45,7 @@ public List value() { /** * Set the value property: The list of configurations. - * + * * @param value the value value to set. * @return the ConfigurationListResult object itself. */ @@ -50,7 +56,7 @@ public ConfigurationListResult withValue(List value) { /** * Get the nextLink property: The link used to get the next page of configurations. - * + * * @return the nextLink value. */ public String nextLink() { @@ -59,7 +65,7 @@ public String 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. */ @@ -70,7 +76,7 @@ public ConfigurationListResult withNextLink(String nextLink) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { @@ -78,4 +84,44 @@ public void validate() { value().forEach(e -> e.validate()); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ConfigurationListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ConfigurationListResult if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the ConfigurationListResult. + */ + public static ConfigurationListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ConfigurationListResult deserializedConfigurationListResult = new ConfigurationListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> ConfigDataInner.fromJson(reader1)); + deserializedConfigurationListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedConfigurationListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedConfigurationListResult; + }); + } } 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 index 7eedd1bd9971..bbe25a80a0ec 100644 --- 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 @@ -5,17 +5,20 @@ 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. */ +/** + * Defines values for ConfigurationName. + */ public final class ConfigurationName extends ExpandableStringEnum { - /** Static value default for ConfigurationName. */ + /** + * Static value default for ConfigurationName. + */ public static final ConfigurationName DEFAULT = fromString("default"); /** * Creates a new instance of ConfigurationName value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated @@ -24,18 +27,17 @@ public ConfigurationName() { /** * 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); } /** * Gets known ConfigurationName values. - * + * * @return known ConfigurationName values. */ public static Collection values() { 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 index 16d9823335f9..582f7893c8e0 100644 --- 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 @@ -9,13 +9,15 @@ import com.azure.core.util.Context; import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; -/** Resource collection API of Configurations. */ +/** + * Resource collection API of Configurations. + */ public interface Configurations { /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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 as paginated response with {@link PagedIterable}. @@ -24,9 +26,9 @@ public interface Configurations { /** * Retrieve Azure Advisor configurations. - * - *

Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. - * + * + * 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. @@ -37,9 +39,9 @@ public interface Configurations { /** * Create/Overwrite Azure Advisor configuration. - * - *

Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. - * + * + * 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 Azure Advisor configuration data structure. * @param context The context to associate with this operation. @@ -48,14 +50,14 @@ public interface Configurations { * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the Advisor configuration data structure along with {@link Response}. */ - Response createInSubscriptionWithResponse( - ConfigurationName configurationName, ConfigDataInner configContract, Context context); + Response createInSubscriptionWithResponse(ConfigurationName configurationName, + ConfigDataInner configContract, Context context); /** * Create/Overwrite Azure Advisor configuration. - * - *

Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups. - * + * + * 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 Azure Advisor configuration data structure. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -67,7 +69,7 @@ Response createInSubscriptionWithResponse( /** * 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. @@ -78,7 +80,7 @@ Response createInSubscriptionWithResponse( /** * 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. @@ -90,7 +92,7 @@ Response createInSubscriptionWithResponse( /** * Begins definition for a new ConfigData resource. - * + * * @param name resource name. * @return the first stage of the new ConfigData definition. */ 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 index 4ea845932d19..cbbee3007566 100644 --- 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 @@ -5,7 +5,6 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; /** @@ -13,21 +12,29 @@ * 5 (default), 10, 15 or 20. */ public final class CpuThreshold extends ExpandableStringEnum { - /** Static value 5 for CpuThreshold. */ + /** + * Static value 5 for CpuThreshold. + */ public static final CpuThreshold FIVE = fromString("5"); - /** Static value 10 for CpuThreshold. */ + /** + * Static value 10 for CpuThreshold. + */ public static final CpuThreshold ONE_ZERO = fromString("10"); - /** Static value 15 for CpuThreshold. */ + /** + * Static value 15 for CpuThreshold. + */ public static final CpuThreshold ONE_FIVE = fromString("15"); - /** Static value 20 for CpuThreshold. */ + /** + * Static value 20 for CpuThreshold. + */ public static final CpuThreshold TWO_ZERO = fromString("20"); /** * Creates a new instance of CpuThreshold value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated @@ -36,18 +43,17 @@ public CpuThreshold() { /** * 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); } /** * Gets known CpuThreshold values. - * + * * @return known CpuThreshold values. */ public static Collection values() { 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 index 324f60f19919..88f476a62279 100644 --- 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 @@ -5,57 +5,59 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; -/** Advisor Digest configuration entity. */ +/** + * Advisor Digest configuration entity. + */ @Fluent -public final class DigestConfig { +public final class DigestConfig implements JsonSerializable { /* * 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; - /** Creates an instance of DigestConfig class. */ + /** + * Creates an instance of DigestConfig class. + */ public DigestConfig() { } /** * 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() { @@ -65,7 +67,7 @@ public String 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. */ @@ -76,7 +78,7 @@ public DigestConfig withName(String name) { /** * Get the actionGroupResourceId property: Action group resource id used by digest. - * + * * @return the actionGroupResourceId value. */ public String actionGroupResourceId() { @@ -85,7 +87,7 @@ public String actionGroupResourceId() { /** * Set the actionGroupResourceId property: Action group resource id used by digest. - * + * * @param actionGroupResourceId the actionGroupResourceId value to set. * @return the DigestConfig object itself. */ @@ -97,7 +99,7 @@ public DigestConfig withActionGroupResourceId(String actionGroupResourceId) { /** * 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() { @@ -107,7 +109,7 @@ public Integer 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. */ @@ -119,7 +121,7 @@ public DigestConfig withFrequency(Integer frequency) { /** * 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() { @@ -129,7 +131,7 @@ public List 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. */ @@ -141,7 +143,7 @@ public DigestConfig withCategories(List categories) { /** * 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() { @@ -151,7 +153,7 @@ public String 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. */ @@ -162,7 +164,7 @@ public DigestConfig withLanguage(String language) { /** * Get the state property: State of digest configuration. - * + * * @return the state value. */ public DigestConfigState state() { @@ -171,7 +173,7 @@ public DigestConfigState state() { /** * Set the state property: State of digest configuration. - * + * * @param state the state value to set. * @return the DigestConfig object itself. */ @@ -182,9 +184,62 @@ public DigestConfig withState(DigestConfigState state) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("actionGroupResourceId", this.actionGroupResourceId); + jsonWriter.writeNumberField("frequency", this.frequency); + jsonWriter.writeArrayField("categories", this.categories, + (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeStringField("language", this.language); + jsonWriter.writeStringField("state", this.state == null ? null : this.state.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DigestConfig from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DigestConfig if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the DigestConfig. + */ + public static DigestConfig fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DigestConfig deserializedDigestConfig = new DigestConfig(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedDigestConfig.name = reader.getString(); + } else if ("actionGroupResourceId".equals(fieldName)) { + deserializedDigestConfig.actionGroupResourceId = reader.getString(); + } else if ("frequency".equals(fieldName)) { + deserializedDigestConfig.frequency = reader.getNullable(JsonReader::getInt); + } else if ("categories".equals(fieldName)) { + List categories = reader.readArray(reader1 -> Category.fromString(reader1.getString())); + deserializedDigestConfig.categories = categories; + } else if ("language".equals(fieldName)) { + deserializedDigestConfig.language = reader.getString(); + } else if ("state".equals(fieldName)) { + deserializedDigestConfig.state = DigestConfigState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedDigestConfig; + }); + } } 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 index d12937fe24eb..aad09c377c1e 100644 --- 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 @@ -5,20 +5,25 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** State of digest configuration. */ +/** + * State of digest configuration. + */ public final class DigestConfigState extends ExpandableStringEnum { - /** Static value Active for DigestConfigState. */ + /** + * Static value Active for DigestConfigState. + */ public static final DigestConfigState ACTIVE = fromString("Active"); - /** Static value Disabled for DigestConfigState. */ + /** + * Static value Disabled for DigestConfigState. + */ public static final DigestConfigState DISABLED = fromString("Disabled"); /** * Creates a new instance of DigestConfigState value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated @@ -27,18 +32,17 @@ public DigestConfigState() { /** * 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); } /** * Gets known DigestConfigState values. - * + * * @return known DigestConfigState values. */ public static Collection values() { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/DurationModel.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/DurationModel.java new file mode 100644 index 000000000000..faad3ef4871c --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/DurationModel.java @@ -0,0 +1,72 @@ +// 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 java.util.Collection; + +/** + * Minimum duration for Advisor low CPU utilization evaluation. Valid only for subscriptions. Valid values: 7 (default), + * 14, 21, 30, 60 or 90. + */ +public final class DurationModel extends ExpandableStringEnum { + /** + * Static value 7 for DurationModel. + */ + public static final DurationModel SEVEN = fromString("7"); + + /** + * Static value 14 for DurationModel. + */ + public static final DurationModel ONE_FOUR = fromString("14"); + + /** + * Static value 21 for DurationModel. + */ + public static final DurationModel TWO_ONE = fromString("21"); + + /** + * Static value 30 for DurationModel. + */ + public static final DurationModel THREE_ZERO = fromString("30"); + + /** + * Static value 60 for DurationModel. + */ + public static final DurationModel SIX_ZERO = fromString("60"); + + /** + * Static value 90 for DurationModel. + */ + public static final DurationModel NINE_ZERO = fromString("90"); + + /** + * Creates a new instance of DurationModel value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DurationModel() { + } + + /** + * Creates or finds a DurationModel from its string representation. + * + * @param name a name to look for. + * @return the corresponding DurationModel. + */ + public static DurationModel fromString(String name) { + return fromString(name, DurationModel.class); + } + + /** + * Gets known DurationModel values. + * + * @return known DurationModel values. + */ + public static Collection values() { + return values(DurationModel.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 index 875b8389c4e3..c6f07120146d 100644 --- 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 @@ -5,23 +5,30 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.util.ExpandableStringEnum; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** The business impact of the recommendation. */ +/** + * The business impact of the recommendation. + */ public final class Impact extends ExpandableStringEnum { - /** Static value High for Impact. */ + /** + * Static value High for Impact. + */ public static final Impact HIGH = fromString("High"); - /** Static value Medium for Impact. */ + /** + * Static value Medium for Impact. + */ public static final Impact MEDIUM = fromString("Medium"); - /** Static value Low for Impact. */ + /** + * Static value Low for Impact. + */ public static final Impact LOW = fromString("Low"); /** * Creates a new instance of Impact value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated @@ -30,18 +37,17 @@ public Impact() { /** * 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); } /** * Gets known Impact values. - * + * * @return known Impact values. */ public static Collection values() { 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 index 0bdd69509b20..86e9d5296613 100644 --- 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 @@ -7,60 +7,62 @@ import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; import java.util.List; -/** An immutable client-side representation of MetadataEntity. */ +/** + * 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 index 235dc6b831c4..f74e828afe61 100644 --- 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 @@ -5,32 +5,38 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; import java.util.List; -/** The list of metadata entities. */ +/** + * The list of metadata entities. + */ @Fluent -public final class MetadataEntityListResult { +public final class MetadataEntityListResult implements JsonSerializable { /* * 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; - /** Creates an instance of MetadataEntityListResult class. */ + /** + * Creates an instance of MetadataEntityListResult class. + */ public MetadataEntityListResult() { } /** * Get the value property: The list of metadata entities. - * + * * @return the value value. */ public List value() { @@ -39,7 +45,7 @@ public List value() { /** * Set the value property: The list of metadata entities. - * + * * @param value the value value to set. * @return the MetadataEntityListResult object itself. */ @@ -50,7 +56,7 @@ public MetadataEntityListResult withValue(List value) { /** * Get the nextLink property: The link used to get the next page of metadata. - * + * * @return the nextLink value. */ public String nextLink() { @@ -59,7 +65,7 @@ public String 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. */ @@ -70,7 +76,7 @@ public MetadataEntityListResult withNextLink(String nextLink) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { @@ -78,4 +84,45 @@ public void validate() { value().forEach(e -> e.validate()); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MetadataEntityListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MetadataEntityListResult if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the MetadataEntityListResult. + */ + public static MetadataEntityListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MetadataEntityListResult deserializedMetadataEntityListResult = new MetadataEntityListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> MetadataEntityInner.fromJson(reader1)); + deserializedMetadataEntityListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedMetadataEntityListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedMetadataEntityListResult; + }); + } } 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 index 18d5cd732c2b..c1ec2a5083ad 100644 --- 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 @@ -5,30 +5,36 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; -/** The metadata supported value detail. */ +/** + * The metadata supported value detail. + */ @Fluent -public final class MetadataSupportedValueDetail { +public final class MetadataSupportedValueDetail implements JsonSerializable { /* * The id. */ - @JsonProperty(value = "id") private String id; /* * The display name. */ - @JsonProperty(value = "displayName") private String displayName; - /** Creates an instance of MetadataSupportedValueDetail class. */ + /** + * Creates an instance of MetadataSupportedValueDetail class. + */ public MetadataSupportedValueDetail() { } /** * Get the id property: The id. - * + * * @return the id value. */ public String id() { @@ -37,7 +43,7 @@ public String id() { /** * Set the id property: The id. - * + * * @param id the id value to set. * @return the MetadataSupportedValueDetail object itself. */ @@ -48,7 +54,7 @@ public MetadataSupportedValueDetail withId(String id) { /** * Get the displayName property: The display name. - * + * * @return the displayName value. */ public String displayName() { @@ -57,7 +63,7 @@ public String displayName() { /** * Set the displayName property: The display name. - * + * * @param displayName the displayName value to set. * @return the MetadataSupportedValueDetail object itself. */ @@ -68,9 +74,48 @@ public MetadataSupportedValueDetail withDisplayName(String displayName) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("displayName", this.displayName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MetadataSupportedValueDetail from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MetadataSupportedValueDetail if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the MetadataSupportedValueDetail. + */ + public static MetadataSupportedValueDetail fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MetadataSupportedValueDetail deserializedMetadataSupportedValueDetail = new MetadataSupportedValueDetail(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedMetadataSupportedValueDetail.id = reader.getString(); + } else if ("displayName".equals(fieldName)) { + deserializedMetadataSupportedValueDetail.displayName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedMetadataSupportedValueDetail; + }); + } } 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 index 625969303012..c6c39eea3622 100644 --- 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 @@ -5,42 +5,46 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** The operation supported by Advisor. */ +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The operation supported by Advisor. + */ @Fluent -public final class OperationDisplayInfo { +public final class OperationDisplayInfo implements JsonSerializable { /* * 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; - /** Creates an instance of OperationDisplayInfo class. */ + /** + * Creates an instance of OperationDisplayInfo class. + */ public OperationDisplayInfo() { } /** * Get the description property: The description of the operation. - * + * * @return the description value. */ public String description() { @@ -49,7 +53,7 @@ public String description() { /** * Set the description property: The description of the operation. - * + * * @param description the description value to set. * @return the OperationDisplayInfo object itself. */ @@ -60,7 +64,7 @@ public OperationDisplayInfo withDescription(String description) { /** * Get the operation property: The action that users can perform, based on their permission level. - * + * * @return the operation value. */ public String operation() { @@ -69,7 +73,7 @@ public String 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. */ @@ -80,7 +84,7 @@ public OperationDisplayInfo withOperation(String operation) { /** * Get the provider property: Service provider: Microsoft Advisor. - * + * * @return the provider value. */ public String provider() { @@ -89,7 +93,7 @@ public String provider() { /** * Set the provider property: Service provider: Microsoft Advisor. - * + * * @param provider the provider value to set. * @return the OperationDisplayInfo object itself. */ @@ -100,7 +104,7 @@ public OperationDisplayInfo withProvider(String provider) { /** * Get the resource property: Resource on which the operation is performed. - * + * * @return the resource value. */ public String resource() { @@ -109,7 +113,7 @@ public String resource() { /** * Set the resource property: Resource on which the operation is performed. - * + * * @param resource the resource value to set. * @return the OperationDisplayInfo object itself. */ @@ -120,9 +124,54 @@ public OperationDisplayInfo withResource(String resource) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("operation", this.operation); + jsonWriter.writeStringField("provider", this.provider); + jsonWriter.writeStringField("resource", this.resource); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationDisplayInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDisplayInfo if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationDisplayInfo. + */ + public static OperationDisplayInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationDisplayInfo deserializedOperationDisplayInfo = new OperationDisplayInfo(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("description".equals(fieldName)) { + deserializedOperationDisplayInfo.description = reader.getString(); + } else if ("operation".equals(fieldName)) { + deserializedOperationDisplayInfo.operation = reader.getString(); + } else if ("provider".equals(fieldName)) { + deserializedOperationDisplayInfo.provider = reader.getString(); + } else if ("resource".equals(fieldName)) { + deserializedOperationDisplayInfo.resource = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationDisplayInfo; + }); + } } 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 index d190a4a4138a..280181385f5a 100644 --- 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 @@ -6,25 +6,27 @@ import com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner; -/** An immutable client-side representation of OperationEntity. */ +/** + * 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 index e53cf1adfa13..5992b5bcbe65 100644 --- 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 @@ -5,32 +5,38 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; import java.util.List; -/** The list of Advisor operations. */ +/** + * The list of Advisor operations. + */ @Fluent -public final class OperationEntityListResult { +public final class OperationEntityListResult implements JsonSerializable { /* * 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; - /** Creates an instance of OperationEntityListResult class. */ + /** + * Creates an instance of OperationEntityListResult class. + */ public OperationEntityListResult() { } /** * Get the nextLink property: The link used to get the next page of operations. - * + * * @return the nextLink value. */ public String nextLink() { @@ -39,7 +45,7 @@ public String 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. */ @@ -50,7 +56,7 @@ public OperationEntityListResult withNextLink(String nextLink) { /** * Get the value property: The list of operations. - * + * * @return the value value. */ public List value() { @@ -59,7 +65,7 @@ public List value() { /** * Set the value property: The list of operations. - * + * * @param value the value value to set. * @return the OperationEntityListResult object itself. */ @@ -70,7 +76,7 @@ public OperationEntityListResult withValue(List value) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { @@ -78,4 +84,45 @@ public void validate() { value().forEach(e -> e.validate()); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("nextLink", this.nextLink); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationEntityListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationEntityListResult if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationEntityListResult. + */ + public static OperationEntityListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationEntityListResult deserializedOperationEntityListResult = new OperationEntityListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("nextLink".equals(fieldName)) { + deserializedOperationEntityListResult.nextLink = reader.getString(); + } else if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> OperationEntityInner.fromJson(reader1)); + deserializedOperationEntityListResult.value = value; + } else { + reader.skipChildren(); + } + } + + return deserializedOperationEntityListResult; + }); + } } 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 index e0ee34e42e6a..8b4261a78c14 100644 --- 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 @@ -7,11 +7,13 @@ import com.azure.core.http.rest.PagedIterable; import com.azure.core.util.Context; -/** Resource collection API of Operations. */ +/** + * 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 as paginated response with {@link PagedIterable}. @@ -20,7 +22,7 @@ public interface Operations { /** * 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. diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/PredictionRequest.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/PredictionRequest.java new file mode 100644 index 000000000000..fb397d1533a3 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/PredictionRequest.java @@ -0,0 +1,132 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.advisor.fluent.models.PredictionRequestProperties; +import java.io.IOException; + +/** + * Parameters for predict recommendation. + */ +@Fluent +public final class PredictionRequest implements JsonSerializable { + /* + * Request properties for prediction recommendation. + */ + private PredictionRequestProperties innerProperties; + + /** + * Creates an instance of PredictionRequest class. + */ + public PredictionRequest() { + } + + /** + * Get the innerProperties property: Request properties for prediction recommendation. + * + * @return the innerProperties value. + */ + private PredictionRequestProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the predictionType property: Type of the prediction. + * + * @return the predictionType value. + */ + public PredictionType predictionType() { + return this.innerProperties() == null ? null : this.innerProperties().predictionType(); + } + + /** + * Set the predictionType property: Type of the prediction. + * + * @param predictionType the predictionType value to set. + * @return the PredictionRequest object itself. + */ + public PredictionRequest withPredictionType(PredictionType predictionType) { + if (this.innerProperties() == null) { + this.innerProperties = new PredictionRequestProperties(); + } + this.innerProperties().withPredictionType(predictionType); + return this; + } + + /** + * Get the extendedProperties property: Extended properties are arguments specific for each prediction type. + * + * @return the extendedProperties value. + */ + public Object extendedProperties() { + return this.innerProperties() == null ? null : this.innerProperties().extendedProperties(); + } + + /** + * Set the extendedProperties property: Extended properties are arguments specific for each prediction type. + * + * @param extendedProperties the extendedProperties value to set. + * @return the PredictionRequest object itself. + */ + public PredictionRequest withExtendedProperties(Object extendedProperties) { + if (this.innerProperties() == null) { + this.innerProperties = new PredictionRequestProperties(); + } + this.innerProperties().withExtendedProperties(extendedProperties); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PredictionRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PredictionRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the PredictionRequest. + */ + public static PredictionRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PredictionRequest deserializedPredictionRequest = new PredictionRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("properties".equals(fieldName)) { + deserializedPredictionRequest.innerProperties = PredictionRequestProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedPredictionRequest; + }); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/PredictionResponse.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/PredictionResponse.java new file mode 100644 index 000000000000..2df2aa2d42ca --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/PredictionResponse.java @@ -0,0 +1,69 @@ +// 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.PredictionResponseInner; +import java.time.OffsetDateTime; + +/** + * An immutable client-side representation of PredictionResponse. + */ +public interface PredictionResponse { + /** + * Gets the extendedProperties property: Extended properties. + * + * @return the extendedProperties value. + */ + Object extendedProperties(); + + /** + * Gets the predictionType property: Type of the prediction. + * + * @return the predictionType value. + */ + PredictionType predictionType(); + + /** + * 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 lastUpdated property: The most recent time that Advisor checked the validity of the recommendation. + * + * @return the lastUpdated value. + */ + OffsetDateTime lastUpdated(); + + /** + * Gets the shortDescription property: A summary of the recommendation. + * + * @return the shortDescription value. + */ + ShortDescription shortDescription(); + + /** + * Gets the inner com.azure.resourcemanager.advisor.fluent.models.PredictionResponseInner object. + * + * @return the inner object. + */ + PredictionResponseInner innerModel(); +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/PredictionType.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/PredictionType.java new file mode 100644 index 000000000000..f3a1edf7b76b --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/PredictionType.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.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of the prediction. + */ +public final class PredictionType extends ExpandableStringEnum { + /** + * Static value PredictiveRightsizing for PredictionType. + */ + public static final PredictionType PREDICTIVE_RIGHTSIZING = fromString("PredictiveRightsizing"); + + /** + * Creates a new instance of PredictionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public PredictionType() { + } + + /** + * Creates or finds a PredictionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding PredictionType. + */ + public static PredictionType fromString(String name) { + return fromString(name, PredictionType.class); + } + + /** + * Gets known PredictionType values. + * + * @return known PredictionType values. + */ + public static Collection values() { + return values(PredictionType.class); + } +} 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 index dcee5fce179f..b8a047665b9f 100644 --- 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 @@ -8,15 +8,19 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.Context; -/** Resource collection API of RecommendationMetadatas. */ +/** + * Resource collection API of RecommendationMetadatas. + */ public interface RecommendationMetadatas { /** * 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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the metadata entity along with {@link Response}. */ @@ -24,10 +28,12 @@ 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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the metadata entity. */ @@ -35,7 +41,7 @@ public interface RecommendationMetadatas { /** * 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 as paginated response with {@link PagedIterable}. @@ -44,7 +50,7 @@ public interface RecommendationMetadatas { /** * 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. 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 index 406bd678fb15..5fad8e9b447e 100644 --- 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 @@ -9,12 +9,14 @@ import com.azure.core.util.Context; import java.util.UUID; -/** Resource collection API of Recommendations. */ +/** + * 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. - * + * * @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. @@ -26,7 +28,7 @@ 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. */ @@ -35,9 +37,9 @@ public interface Recommendations { /** * 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. + * 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. @@ -49,9 +51,9 @@ public interface Recommendations { /** * 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. + * 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. @@ -61,7 +63,7 @@ public interface Recommendations { /** * 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 as paginated response with {@link PagedIterable}. @@ -71,10 +73,10 @@ public interface Recommendations { /** * 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'. + * ['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. @@ -87,9 +89,9 @@ public interface Recommendations { /** * Obtains details of a cached recommendation. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * recommendation applies. * @param recommendationId The recommendation ID. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -101,9 +103,9 @@ public interface Recommendations { /** * Obtains details of a cached recommendation. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * 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. 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 index 34cb552cf0a4..2b9b3b2fcc01 100644 --- 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 @@ -7,27 +7,26 @@ import com.azure.core.annotation.Fluent; import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; -import com.fasterxml.jackson.annotation.JsonProperty; -/** The RecommendationsGenerateHeaders model. */ +/** + * The RecommendationsGenerateHeaders model. + */ @Fluent public final class RecommendationsGenerateHeaders { /* * The Retry-After property. */ - @JsonProperty(value = "Retry-After") private String retryAfter; /* * The Location property. */ - @JsonProperty(value = "Location") private String location; // HttpHeaders containing the raw property values. /** * Creates an instance of RecommendationsGenerateHeaders class. - * + * * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public RecommendationsGenerateHeaders(HttpHeaders rawHeaders) { @@ -37,7 +36,7 @@ public RecommendationsGenerateHeaders(HttpHeaders rawHeaders) { /** * Get the retryAfter property: The Retry-After property. - * + * * @return the retryAfter value. */ public String retryAfter() { @@ -46,7 +45,7 @@ public String retryAfter() { /** * Set the retryAfter property: The Retry-After property. - * + * * @param retryAfter the retryAfter value to set. * @return the RecommendationsGenerateHeaders object itself. */ @@ -57,7 +56,7 @@ public RecommendationsGenerateHeaders withRetryAfter(String retryAfter) { /** * Get the location property: The Location property. - * + * * @return the location value. */ public String location() { @@ -66,7 +65,7 @@ public String location() { /** * Set the location property: The Location property. - * + * * @param location the location value to set. * @return the RecommendationsGenerateHeaders object itself. */ @@ -77,7 +76,7 @@ public RecommendationsGenerateHeaders withLocation(String location) { /** * 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 index fe5f7f901030..7760dc61fbfa 100644 --- 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 @@ -8,22 +8,20 @@ import com.azure.core.http.HttpRequest; import com.azure.core.http.rest.ResponseBase; -/** Contains all response data for the generate operation. */ +/** + * 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, + 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 index 6b0a18b346fc..e3f385ac03bb 100644 --- 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 @@ -5,51 +5,52 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.Map; -/** Recommendation resource metadata. */ +/** + * Recommendation resource metadata. + */ @Fluent -public final class ResourceMetadata { +public final class ResourceMetadata implements JsonSerializable { /* * 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; /* * The action to view resource. */ - @JsonProperty(value = "action") - @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) private Map action; /* * The singular user friendly name of resource type. eg: virtual machine */ - @JsonProperty(value = "singular") private String singular; /* * The plural user friendly name of resource type. eg: virtual machines */ - @JsonProperty(value = "plural") private String plural; - /** Creates an instance of ResourceMetadata class. */ + /** + * Creates an instance of ResourceMetadata class. + */ public ResourceMetadata() { } /** * Get the resourceId property: Azure resource Id of the assessed resource. - * + * * @return the resourceId value. */ public String resourceId() { @@ -58,7 +59,7 @@ public String resourceId() { /** * Set the resourceId property: Azure resource Id of the assessed resource. - * + * * @param resourceId the resourceId value to set. * @return the ResourceMetadata object itself. */ @@ -69,7 +70,7 @@ public ResourceMetadata withResourceId(String resourceId) { /** * Get the source property: Source from which recommendation is generated. - * + * * @return the source value. */ public String source() { @@ -78,7 +79,7 @@ public String source() { /** * Set the source property: Source from which recommendation is generated. - * + * * @param source the source value to set. * @return the ResourceMetadata object itself. */ @@ -89,7 +90,7 @@ public ResourceMetadata withSource(String source) { /** * Get the action property: The action to view resource. - * + * * @return the action value. */ public Map action() { @@ -98,7 +99,7 @@ public Map action() { /** * Set the action property: The action to view resource. - * + * * @param action the action value to set. * @return the ResourceMetadata object itself. */ @@ -109,7 +110,7 @@ public ResourceMetadata withAction(Map action) { /** * Get the singular property: The singular user friendly name of resource type. eg: virtual machine. - * + * * @return the singular value. */ public String singular() { @@ -118,7 +119,7 @@ public String singular() { /** * Set the singular property: The singular user friendly name of resource type. eg: virtual machine. - * + * * @param singular the singular value to set. * @return the ResourceMetadata object itself. */ @@ -129,7 +130,7 @@ public ResourceMetadata withSingular(String singular) { /** * Get the plural property: The plural user friendly name of resource type. eg: virtual machines. - * + * * @return the plural value. */ public String plural() { @@ -138,7 +139,7 @@ public String plural() { /** * Set the plural property: The plural user friendly name of resource type. eg: virtual machines. - * + * * @param plural the plural value to set. * @return the ResourceMetadata object itself. */ @@ -149,9 +150,58 @@ public ResourceMetadata withPlural(String plural) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("resourceId", this.resourceId); + jsonWriter.writeStringField("source", this.source); + jsonWriter.writeMapField("action", this.action, (writer, element) -> writer.writeUntyped(element)); + jsonWriter.writeStringField("singular", this.singular); + jsonWriter.writeStringField("plural", this.plural); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceMetadata from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceMetadata if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ResourceMetadata. + */ + public static ResourceMetadata fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceMetadata deserializedResourceMetadata = new ResourceMetadata(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("resourceId".equals(fieldName)) { + deserializedResourceMetadata.resourceId = reader.getString(); + } else if ("source".equals(fieldName)) { + deserializedResourceMetadata.source = reader.getString(); + } else if ("action".equals(fieldName)) { + Map action = reader.readMap(reader1 -> reader1.readUntyped()); + deserializedResourceMetadata.action = action; + } else if ("singular".equals(fieldName)) { + deserializedResourceMetadata.singular = reader.getString(); + } else if ("plural".equals(fieldName)) { + deserializedResourceMetadata.plural = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceMetadata; + }); + } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceProviders.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceProviders.java new file mode 100644 index 000000000000..fee0d452794c --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ResourceProviders.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.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of ResourceProviders. + */ +public interface ResourceProviders { + /** + * Predicts a recommendation. + * + * @param predictionRequest Parameters for predict recommendation. + * @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 response used by predictions along with {@link Response}. + */ + Response predictWithResponse(PredictionRequest predictionRequest, Context context); + + /** + * Predicts a recommendation. + * + * @param predictionRequest Parameters for predict recommendation. + * @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 response used by predictions. + */ + PredictionResponse predict(PredictionRequest predictionRequest); +} 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 index 7375a28c37be..0c6e4e5040d3 100644 --- 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 @@ -4,150 +4,167 @@ package com.azure.resourcemanager.advisor.models; +import com.azure.core.management.SystemData; 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. */ +/** + * 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 systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + /** * 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 description property: The detailed description of recommendation. - * + * * @return the description value. */ String description(); /** * Gets the label property: The label of recommendation. - * + * * @return the label value. */ String label(); /** * Gets the learnMoreLink property: The link to learn more about recommendation and generation logic. - * + * * @return the learnMoreLink value. */ String learnMoreLink(); /** * Gets the potentialBenefits property: The potential benefit of implementing recommendation. - * + * * @return the potentialBenefits value. */ String potentialBenefits(); /** * Gets the actions property: The list of recommended actions to implement recommendation. - * + * * @return the actions value. */ List> actions(); /** * Gets the remediation property: The automated way to apply recommendation. - * + * * @return the remediation value. */ Map remediation(); @@ -155,14 +172,14 @@ public interface ResourceRecommendationBase { /** * Gets the exposedMetadataProperties property: The recommendation metadata properties exposed to customer to * provide additional information. - * + * * @return the exposedMetadataProperties value. */ Map exposedMetadataProperties(); /** * 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 index 9a283b15fe7f..35a3205c83cc 100644 --- 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 @@ -5,32 +5,39 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; import java.util.List; -/** The list of Advisor recommendations. */ +/** + * The list of Advisor recommendations. + */ @Fluent -public final class ResourceRecommendationBaseListResult { +public final class ResourceRecommendationBaseListResult + implements JsonSerializable { /* * 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; - /** Creates an instance of ResourceRecommendationBaseListResult class. */ + /** + * Creates an instance of ResourceRecommendationBaseListResult class. + */ public ResourceRecommendationBaseListResult() { } /** * Get the nextLink property: The link used to get the next page of recommendations. - * + * * @return the nextLink value. */ public String nextLink() { @@ -39,7 +46,7 @@ public String 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. */ @@ -50,7 +57,7 @@ public ResourceRecommendationBaseListResult withNextLink(String nextLink) { /** * Get the value property: The list of recommendations. - * + * * @return the value value. */ public List value() { @@ -59,7 +66,7 @@ public List value() { /** * Set the value property: The list of recommendations. - * + * * @param value the value value to set. * @return the ResourceRecommendationBaseListResult object itself. */ @@ -70,7 +77,7 @@ public ResourceRecommendationBaseListResult withValue(List e.validate()); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("nextLink", this.nextLink); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceRecommendationBaseListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceRecommendationBaseListResult if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ResourceRecommendationBaseListResult. + */ + public static ResourceRecommendationBaseListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceRecommendationBaseListResult deserializedResourceRecommendationBaseListResult + = new ResourceRecommendationBaseListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("nextLink".equals(fieldName)) { + deserializedResourceRecommendationBaseListResult.nextLink = reader.getString(); + } else if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> ResourceRecommendationBaseInner.fromJson(reader1)); + deserializedResourceRecommendationBaseListResult.value = value; + } else { + reader.skipChildren(); + } + } + + return deserializedResourceRecommendationBaseListResult; + }); + } } 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..e91b7b050ded --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/Risk.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The potential risk of not implementing the recommendation. + */ +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 a new instance of Risk value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Risk() { + } + + /** + * Creates or finds a Risk from its string representation. + * + * @param name a name to look for. + * @return the corresponding Risk. + */ + public static Risk fromString(String name) { + return fromString(name, Risk.class); + } + + /** + * Gets known Risk values. + * + * @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 index d3f041ff2a84..8152e8f5719a 100644 --- 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 @@ -5,17 +5,20 @@ 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. */ +/** + * Defines values for Scenario. + */ public final class Scenario extends ExpandableStringEnum { - /** Static value Alerts for Scenario. */ + /** + * Static value Alerts for Scenario. + */ public static final Scenario ALERTS = fromString("Alerts"); /** * Creates a new instance of Scenario value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated @@ -24,18 +27,17 @@ public Scenario() { /** * 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); } /** * Gets known Scenario values. - * + * * @return known Scenario values. */ public static Collection values() { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ScoreEntity.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ScoreEntity.java new file mode 100644 index 000000000000..c92969ba88fb --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/ScoreEntity.java @@ -0,0 +1,224 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The details of Advisor Score. + */ +@Fluent +public final class ScoreEntity implements JsonSerializable { + /* + * The date score was calculated. + */ + private String date; + + /* + * The percentage score. + */ + private Float score; + + /* + * The consumption units for the score. + */ + private Float consumptionUnits; + + /* + * The number of impacted resources. + */ + private Float impactedResourceCount; + + /* + * The potential percentage increase in overall score at subscription level once all recommendations in this scope + * are implemented. + */ + private Float potentialScoreIncrease; + + /* + * The count of impacted categories. + */ + private Float categoryCount; + + /** + * Creates an instance of ScoreEntity class. + */ + public ScoreEntity() { + } + + /** + * Get the date property: The date score was calculated. + * + * @return the date value. + */ + public String date() { + return this.date; + } + + /** + * Set the date property: The date score was calculated. + * + * @param date the date value to set. + * @return the ScoreEntity object itself. + */ + public ScoreEntity withDate(String date) { + this.date = date; + return this; + } + + /** + * Get the score property: The percentage score. + * + * @return the score value. + */ + public Float score() { + return this.score; + } + + /** + * Set the score property: The percentage score. + * + * @param score the score value to set. + * @return the ScoreEntity object itself. + */ + public ScoreEntity withScore(Float score) { + this.score = score; + return this; + } + + /** + * Get the consumptionUnits property: The consumption units for the score. + * + * @return the consumptionUnits value. + */ + public Float consumptionUnits() { + return this.consumptionUnits; + } + + /** + * Set the consumptionUnits property: The consumption units for the score. + * + * @param consumptionUnits the consumptionUnits value to set. + * @return the ScoreEntity object itself. + */ + public ScoreEntity withConsumptionUnits(Float consumptionUnits) { + this.consumptionUnits = consumptionUnits; + return this; + } + + /** + * Get the impactedResourceCount property: The number of impacted resources. + * + * @return the impactedResourceCount value. + */ + public Float impactedResourceCount() { + return this.impactedResourceCount; + } + + /** + * Set the impactedResourceCount property: The number of impacted resources. + * + * @param impactedResourceCount the impactedResourceCount value to set. + * @return the ScoreEntity object itself. + */ + public ScoreEntity withImpactedResourceCount(Float impactedResourceCount) { + this.impactedResourceCount = impactedResourceCount; + return this; + } + + /** + * Get the potentialScoreIncrease property: The potential percentage increase in overall score at subscription level + * once all recommendations in this scope are implemented. + * + * @return the potentialScoreIncrease value. + */ + public Float potentialScoreIncrease() { + return this.potentialScoreIncrease; + } + + /** + * Set the potentialScoreIncrease property: The potential percentage increase in overall score at subscription level + * once all recommendations in this scope are implemented. + * + * @param potentialScoreIncrease the potentialScoreIncrease value to set. + * @return the ScoreEntity object itself. + */ + public ScoreEntity withPotentialScoreIncrease(Float potentialScoreIncrease) { + this.potentialScoreIncrease = potentialScoreIncrease; + return this; + } + + /** + * Get the categoryCount property: The count of impacted categories. + * + * @return the categoryCount value. + */ + public Float categoryCount() { + return this.categoryCount; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("date", this.date); + jsonWriter.writeNumberField("score", this.score); + jsonWriter.writeNumberField("consumptionUnits", this.consumptionUnits); + jsonWriter.writeNumberField("impactedResourceCount", this.impactedResourceCount); + jsonWriter.writeNumberField("potentialScoreIncrease", this.potentialScoreIncrease); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ScoreEntity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ScoreEntity if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ScoreEntity. + */ + public static ScoreEntity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ScoreEntity deserializedScoreEntity = new ScoreEntity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("date".equals(fieldName)) { + deserializedScoreEntity.date = reader.getString(); + } else if ("score".equals(fieldName)) { + deserializedScoreEntity.score = reader.getNullable(JsonReader::getFloat); + } else if ("consumptionUnits".equals(fieldName)) { + deserializedScoreEntity.consumptionUnits = reader.getNullable(JsonReader::getFloat); + } else if ("impactedResourceCount".equals(fieldName)) { + deserializedScoreEntity.impactedResourceCount = reader.getNullable(JsonReader::getFloat); + } else if ("potentialScoreIncrease".equals(fieldName)) { + deserializedScoreEntity.potentialScoreIncrease = reader.getNullable(JsonReader::getFloat); + } else if ("categoryCount".equals(fieldName)) { + deserializedScoreEntity.categoryCount = reader.getNullable(JsonReader::getFloat); + } else { + reader.skipChildren(); + } + } + + return deserializedScoreEntity; + }); + } +} 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 index 893bf1f0b55b..55228f2bd1b6 100644 --- 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 @@ -5,30 +5,36 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; -/** A summary of the recommendation. */ +/** + * A summary of the recommendation. + */ @Fluent -public final class ShortDescription { +public final class ShortDescription implements JsonSerializable { /* * The issue or opportunity identified by the recommendation and proposed solution. */ - @JsonProperty(value = "problem") private String problem; /* * The issue or opportunity identified by the recommendation and proposed solution. */ - @JsonProperty(value = "solution") private String solution; - /** Creates an instance of ShortDescription class. */ + /** + * Creates an instance of ShortDescription class. + */ public ShortDescription() { } /** * Get the problem property: The issue or opportunity identified by the recommendation and proposed solution. - * + * * @return the problem value. */ public String problem() { @@ -37,7 +43,7 @@ public String problem() { /** * Set the problem property: The issue or opportunity identified by the recommendation and proposed solution. - * + * * @param problem the problem value to set. * @return the ShortDescription object itself. */ @@ -48,7 +54,7 @@ public ShortDescription withProblem(String problem) { /** * Get the solution property: The issue or opportunity identified by the recommendation and proposed solution. - * + * * @return the solution value. */ public String solution() { @@ -57,7 +63,7 @@ public String solution() { /** * Set the solution property: The issue or opportunity identified by the recommendation and proposed solution. - * + * * @param solution the solution value to set. * @return the ShortDescription object itself. */ @@ -68,9 +74,48 @@ public ShortDescription withSolution(String solution) { /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("problem", this.problem); + jsonWriter.writeStringField("solution", this.solution); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ShortDescription from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ShortDescription if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ShortDescription. + */ + public static ShortDescription fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ShortDescription deserializedShortDescription = new ShortDescription(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("problem".equals(fieldName)) { + deserializedShortDescription.problem = reader.getString(); + } else if ("solution".equals(fieldName)) { + deserializedShortDescription.solution = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedShortDescription; + }); + } } 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 index fdad947c4f24..9ea9acff4e62 100644 --- 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 @@ -4,82 +4,103 @@ package com.azure.resourcemanager.advisor.models; +import com.azure.core.management.SystemData; import com.azure.core.util.Context; import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; import java.time.OffsetDateTime; -/** An immutable client-side representation of SuppressionContract. */ +/** + * 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 systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + /** * 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(); - /** The entirety of the SuppressionContract definition. */ + /** + * The entirety of the SuppressionContract definition. + */ interface Definition extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { } - /** The SuppressionContract definition stages. */ + + /** + * The SuppressionContract definition stages. + */ interface DefinitionStages { - /** The first stage of the SuppressionContract definition. */ + /** + * The first stage of the SuppressionContract definition. + */ interface Blank extends WithParentResource { } - /** The stage of the SuppressionContract definition allowing to specify parent resource. */ + + /** + * The stage of the SuppressionContract definition allowing to specify parent resource. + */ interface WithParentResource { /** * Specifies resourceUri, recommendationId. - * + * * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the - * recommendation applies. + * recommendation applies. * @param recommendationId The recommendation ID. * @return the next definition stage. */ WithCreate withExistingRecommendation(String resourceUri, String recommendationId); } + /** * The stage of the SuppressionContract 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. @@ -87,50 +108,57 @@ interface WithParentResource { interface WithCreate extends DefinitionStages.WithSuppressionId, DefinitionStages.WithTtl { /** * Executes the create request. - * + * * @return the created resource. */ SuppressionContract create(); /** * Executes the create request. - * + * * @param context The context to associate with this operation. * @return the created resource. */ SuppressionContract create(Context context); } - /** The stage of the SuppressionContract definition allowing to specify suppressionId. */ + + /** + * The stage of the SuppressionContract definition allowing to specify suppressionId. + */ interface WithSuppressionId { /** * Specifies the suppressionId property: The GUID of the suppression.. - * + * * @param suppressionId The GUID of the suppression. * @return the next definition stage. */ WithCreate withSuppressionId(String suppressionId); } - /** The stage of the SuppressionContract definition allowing to specify ttl. */ + + /** + * The stage of the SuppressionContract definition allowing to specify ttl. + */ interface WithTtl { /** * Specifies the ttl property: The duration for which the suppression is valid.. - * + * * @param ttl The duration for which the suppression is valid. * @return the next definition stage. */ WithCreate withTtl(String ttl); } } + /** * Refreshes the resource to sync with Azure. - * + * * @return the refreshed resource. */ SuppressionContract refresh(); /** * Refreshes the resource to sync with Azure. - * + * * @param context The context to associate with this operation. * @return the refreshed resource. */ 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 index 712537878f64..90bd98ba2e14 100644 --- 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 @@ -5,32 +5,38 @@ package com.azure.resourcemanager.advisor.models; import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; import java.util.List; -/** The list of Advisor suppressions. */ +/** + * The list of Advisor suppressions. + */ @Fluent -public final class SuppressionContractListResult { +public final class SuppressionContractListResult implements JsonSerializable { /* * 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; - /** Creates an instance of SuppressionContractListResult class. */ + /** + * Creates an instance of SuppressionContractListResult class. + */ public SuppressionContractListResult() { } /** * Get the nextLink property: The link used to get the next page of suppressions. - * + * * @return the nextLink value. */ public String nextLink() { @@ -39,7 +45,7 @@ public String 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. */ @@ -50,7 +56,7 @@ public SuppressionContractListResult withNextLink(String nextLink) { /** * Get the value property: The list of suppressions. - * + * * @return the value value. */ public List value() { @@ -59,7 +65,7 @@ public List value() { /** * Set the value property: The list of suppressions. - * + * * @param value the value value to set. * @return the SuppressionContractListResult object itself. */ @@ -70,7 +76,7 @@ public SuppressionContractListResult withValue(List va /** * Validates the instance. - * + * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { @@ -78,4 +84,46 @@ public void validate() { value().forEach(e -> e.validate()); } } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("nextLink", this.nextLink); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SuppressionContractListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SuppressionContractListResult if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the SuppressionContractListResult. + */ + public static SuppressionContractListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SuppressionContractListResult deserializedSuppressionContractListResult + = new SuppressionContractListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("nextLink".equals(fieldName)) { + deserializedSuppressionContractListResult.nextLink = reader.getString(); + } else if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> SuppressionContractInner.fromJson(reader1)); + deserializedSuppressionContractListResult.value = value; + } else { + reader.skipChildren(); + } + } + + return deserializedSuppressionContractListResult; + }); + } } 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 index a9bd757bd858..d4f47a57f088 100644 --- 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 @@ -8,46 +8,52 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.Context; -/** Resource collection API of Suppressions. */ +/** + * 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. + * 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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @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 along with {@link Response}. + * the rule along with {@link Response}. */ - Response getWithResponse( - String resourceUri, String recommendationId, String name, Context context); + Response getWithResponse(String resourceUri, String recommendationId, String name, + 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. + * 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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @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. + * the rule. */ SuppressionContract get(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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param context The context to associate with this operation. @@ -61,9 +67,9 @@ Response getWithResponse( /** * 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. + * recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -75,7 +81,7 @@ Response getWithResponse( /** * 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 as paginated response with {@link PagedIterable}. @@ -85,7 +91,7 @@ Response getWithResponse( /** * 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. @@ -98,33 +104,37 @@ Response getWithResponse( /** * Obtains the details of a suppression. - * + * * @param id the resource ID. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @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 along with {@link Response}. + * the rule along with {@link Response}. */ SuppressionContract getById(String id); /** * Obtains the details of a suppression. - * + * * @param id the resource ID. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 404. * @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 along with {@link Response}. + * the rule along with {@link Response}. */ Response getByIdWithResponse(String id, 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 id the resource ID. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -135,7 +145,7 @@ Response getWithResponse( /** * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a * recommendation is referred to as a suppression. - * + * * @param id the resource ID. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. @@ -147,7 +157,7 @@ Response getWithResponse( /** * Begins definition for a new SuppressionContract resource. - * + * * @param name resource name. * @return the first stage of the new SuppressionContract definition. */ diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/TimeSeriesEntityItem.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/TimeSeriesEntityItem.java new file mode 100644 index 000000000000..05a0cb8f4e77 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/models/TimeSeriesEntityItem.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The data from different aggregation levels. + */ +@Fluent +public final class TimeSeriesEntityItem implements JsonSerializable { + /* + * The aggregation level of the score. + */ + private Aggregated aggregationLevel; + + /* + * The past score data + */ + private List scoreHistory; + + /** + * Creates an instance of TimeSeriesEntityItem class. + */ + public TimeSeriesEntityItem() { + } + + /** + * Get the aggregationLevel property: The aggregation level of the score. + * + * @return the aggregationLevel value. + */ + public Aggregated aggregationLevel() { + return this.aggregationLevel; + } + + /** + * Set the aggregationLevel property: The aggregation level of the score. + * + * @param aggregationLevel the aggregationLevel value to set. + * @return the TimeSeriesEntityItem object itself. + */ + public TimeSeriesEntityItem withAggregationLevel(Aggregated aggregationLevel) { + this.aggregationLevel = aggregationLevel; + return this; + } + + /** + * Get the scoreHistory property: The past score data. + * + * @return the scoreHistory value. + */ + public List scoreHistory() { + return this.scoreHistory; + } + + /** + * Set the scoreHistory property: The past score data. + * + * @param scoreHistory the scoreHistory value to set. + * @return the TimeSeriesEntityItem object itself. + */ + public TimeSeriesEntityItem withScoreHistory(List scoreHistory) { + this.scoreHistory = scoreHistory; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (scoreHistory() != null) { + scoreHistory().forEach(e -> e.validate()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("aggregationLevel", + this.aggregationLevel == null ? null : this.aggregationLevel.toString()); + jsonWriter.writeArrayField("scoreHistory", this.scoreHistory, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TimeSeriesEntityItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TimeSeriesEntityItem if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the TimeSeriesEntityItem. + */ + public static TimeSeriesEntityItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TimeSeriesEntityItem deserializedTimeSeriesEntityItem = new TimeSeriesEntityItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("aggregationLevel".equals(fieldName)) { + deserializedTimeSeriesEntityItem.aggregationLevel = Aggregated.fromString(reader.getString()); + } else if ("scoreHistory".equals(fieldName)) { + List scoreHistory = reader.readArray(reader1 -> ScoreEntity.fromJson(reader1)); + deserializedTimeSeriesEntityItem.scoreHistory = scoreHistory; + } else { + reader.skipChildren(); + } + } + + return deserializedTimeSeriesEntityItem; + }); + } +} 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 index ecd0b9d76f93..75e290de332a 100644 --- 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 @@ -2,5 +2,8 @@ // 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 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 index afbe5cce63d0..0ac51ed23782 100644 --- 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 @@ -2,5 +2,8 @@ // 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 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 index a3210b22e261..e74b563bb887 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/module-info.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/module-info.java @@ -10,10 +10,6 @@ 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; + opens com.azure.resourcemanager.advisor.fluent.models to com.azure.core; + opens com.azure.resourcemanager.advisor.models to com.azure.core; } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-advisor/proxy-config.json b/sdk/advisor/azure-resourcemanager-advisor/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-advisor/proxy-config.json new file mode 100644 index 000000000000..28007d658a8c --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-advisor/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.advisor.implementation.AdvisorScoresClientImpl$AdvisorScoresService"],["com.azure.resourcemanager.advisor.implementation.ConfigurationsClientImpl$ConfigurationsService"],["com.azure.resourcemanager.advisor.implementation.OperationsClientImpl$OperationsService"],["com.azure.resourcemanager.advisor.implementation.RecommendationMetadatasClientImpl$RecommendationMetadatasService"],["com.azure.resourcemanager.advisor.implementation.RecommendationsClientImpl$RecommendationsService"],["com.azure.resourcemanager.advisor.implementation.ResourceProvidersClientImpl$ResourceProvidersService"],["com.azure.resourcemanager.advisor.implementation.SuppressionsClientImpl$SuppressionsService"]] \ No newline at end of file diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-advisor/reflect-config.json b/sdk/advisor/azure-resourcemanager-advisor/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-advisor/reflect-config.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-advisor/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/AdvisorScoresGetSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/AdvisorScoresGetSamples.java new file mode 100644 index 000000000000..60b2ee1b0d7a --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/AdvisorScoresGetSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.generated; + +/** + * Samples for AdvisorScores Get. + */ +public final class AdvisorScoresGetSamples { + /* + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/GetAdvisorScoreDetail.json + */ + /** + * Sample code: GetAdvisorScoreDetail. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getAdvisorScoreDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.advisorScores().getWithResponse("Cost", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/AdvisorScoresListSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/AdvisorScoresListSamples.java new file mode 100644 index 000000000000..affbd6fc2a10 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/AdvisorScoresListSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.generated; + +/** + * Samples for AdvisorScores List. + */ +public final class AdvisorScoresListSamples { + /* + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListAdvisorScore.json + */ + /** + * Sample code: ListAdvisorScore. + * + * @param manager Entry point to AdvisorManager. + */ + public static void listAdvisorScore(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.advisorScores().listWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInResourceGroupSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInResourceGroupSamples.java index b546b9b94783..3af049b1621f 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInResourceGroupSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInResourceGroupSamples.java @@ -9,43 +9,37 @@ import com.azure.resourcemanager.advisor.models.CpuThreshold; import com.azure.resourcemanager.advisor.models.DigestConfig; import com.azure.resourcemanager.advisor.models.DigestConfigState; +import com.azure.resourcemanager.advisor.models.DurationModel; import java.util.Arrays; -/** Samples for Configurations CreateInResourceGroup. */ +/** + * Samples for Configurations CreateInResourceGroup. + */ public final class ConfigurationsCreateInResourceGroupSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateConfiguration.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/CreateConfiguration.json */ /** * Sample code: PutConfigurations. - * + * * @param manager Entry point to AdvisorManager. */ public static void putConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .configurations() + manager.configurations() .define(ConfigurationName.DEFAULT) .withExistingResourceGroup("resourceGroup") .withExclude(true) .withLowCpuThreshold(CpuThreshold.FIVE) - .withDigests( - Arrays - .asList( - new DigestConfig() - .withName("digestConfigName") - .withActionGroupResourceId( - "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName") - .withFrequency(30) - .withCategories( - Arrays - .asList( - Category.HIGH_AVAILABILITY, - Category.SECURITY, - Category.PERFORMANCE, - Category.COST, - Category.OPERATIONAL_EXCELLENCE)) - .withLanguage("en") - .withState(DigestConfigState.ACTIVE))) + .withDuration(DurationModel.SEVEN) + .withDigests(Arrays.asList(new DigestConfig().withName("digestConfigName") + .withActionGroupResourceId( + "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName") + .withFrequency(30) + .withCategories(Arrays.asList(Category.HIGH_AVAILABILITY, Category.SECURITY, Category.PERFORMANCE, + Category.COST, Category.OPERATIONAL_EXCELLENCE)) + .withLanguage("en") + .withState(DigestConfigState.ACTIVE))) .create(); } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInSubscriptionSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInSubscriptionSamples.java index 2e7cbafefc35..4de5e66f483c 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInSubscriptionSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInSubscriptionSamples.java @@ -10,44 +10,35 @@ import com.azure.resourcemanager.advisor.models.CpuThreshold; import com.azure.resourcemanager.advisor.models.DigestConfig; import com.azure.resourcemanager.advisor.models.DigestConfigState; +import com.azure.resourcemanager.advisor.models.DurationModel; import java.util.Arrays; -/** Samples for Configurations CreateInSubscription. */ +/** + * Samples for Configurations CreateInSubscription. + */ public final class ConfigurationsCreateInSubscriptionSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateConfiguration.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/CreateConfiguration.json */ /** * Sample code: PutConfigurations. - * + * * @param manager Entry point to AdvisorManager. */ public static void putConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .configurations() - .createInSubscriptionWithResponse( - ConfigurationName.DEFAULT, - new ConfigDataInner() - .withExclude(true) - .withLowCpuThreshold(CpuThreshold.FIVE) - .withDigests( - Arrays - .asList( - new DigestConfig() - .withName("digestConfigName") - .withActionGroupResourceId( - "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName") - .withFrequency(30) - .withCategories( - Arrays - .asList( - Category.HIGH_AVAILABILITY, - Category.SECURITY, - Category.PERFORMANCE, - Category.COST, - Category.OPERATIONAL_EXCELLENCE)) - .withLanguage("en") - .withState(DigestConfigState.ACTIVE))), + manager.configurations() + .createInSubscriptionWithResponse(ConfigurationName.DEFAULT, new ConfigDataInner().withExclude(true) + .withLowCpuThreshold(CpuThreshold.FIVE) + .withDuration(DurationModel.SEVEN) + .withDigests(Arrays.asList(new DigestConfig().withName("digestConfigName") + .withActionGroupResourceId( + "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName") + .withFrequency(30) + .withCategories(Arrays.asList(Category.HIGH_AVAILABILITY, Category.SECURITY, Category.PERFORMANCE, + Category.COST, Category.OPERATIONAL_EXCELLENCE)) + .withLanguage("en") + .withState(DigestConfigState.ACTIVE))), com.azure.core.util.Context.NONE); } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListByResourceGroupSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListByResourceGroupSamples.java index a99f3d9eabba..f2b8a99d9616 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListByResourceGroupSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListByResourceGroupSamples.java @@ -4,14 +4,17 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Configurations ListByResourceGroup. */ +/** + * Samples for Configurations ListByResourceGroup. + */ public final class ConfigurationsListByResourceGroupSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListConfigurations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListConfigurations.json */ /** * Sample code: GetConfigurations. - * + * * @param manager Entry point to AdvisorManager. */ public static void getConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListSamples.java index 64567f44c1f5..1748738294c8 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListSamples.java @@ -4,14 +4,17 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Configurations List. */ +/** + * Samples for Configurations List. + */ public final class ConfigurationsListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListConfigurations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListConfigurations.json */ /** * Sample code: GetConfigurations. - * + * * @param manager Entry point to AdvisorManager. */ public static void getConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/OperationsListSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/OperationsListSamples.java index a11cbccf898f..1d613e3ea067 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/OperationsListSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/OperationsListSamples.java @@ -4,17 +4,20 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Operations List. */ +/** + * Samples for Operations List. + */ public final class OperationsListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListOperations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/OperationsList.json */ /** - * Sample code: ListRecommendations. - * + * Sample code: OperationsList. + * * @param manager Entry point to AdvisorManager. */ - public static void listRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + public static void operationsList(com.azure.resourcemanager.advisor.AdvisorManager manager) { manager.operations().list(com.azure.core.util.Context.NONE); } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataGetSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataGetSamples.java index ded5453c338b..dc2018005a0f 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataGetSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataGetSamples.java @@ -4,14 +4,17 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for RecommendationMetadata Get. */ +/** + * Samples for RecommendationMetadata Get. + */ public final class RecommendationMetadataGetSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetRecommendationMetadataEntity.json + * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ + * GetRecommendationMetadataEntity.json */ /** * Sample code: GetMetadata. - * + * * @param manager Entry point to AdvisorManager. */ public static void getMetadata(com.azure.resourcemanager.advisor.AdvisorManager manager) { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataListSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataListSamples.java index 671b0062e491..acaa022fbd83 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataListSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataListSamples.java @@ -4,14 +4,18 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for RecommendationMetadata List. */ +/** + * Samples for RecommendationMetadata List. + */ public final class RecommendationMetadataListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListRecommendationMetadata.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListRecommendationMetadata. + * json */ /** * Sample code: GetMetadata. - * + * * @param manager Entry point to AdvisorManager. */ public static void getMetadata(com.azure.resourcemanager.advisor.AdvisorManager manager) { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGenerateSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGenerateSamples.java index 5a1e960b5fa6..1b6b3e0a20f4 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGenerateSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGenerateSamples.java @@ -4,14 +4,17 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Recommendations Generate. */ +/** + * Samples for Recommendations Generate. + */ public final class RecommendationsGenerateSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GenerateRecommendations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/GenerateRecommendations.json */ /** * Sample code: GenerateRecommendations. - * + * * @param manager Entry point to AdvisorManager. */ public static void generateRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetGenerateStatusSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetGenerateStatusSamples.java index a27593274fda..1fd3ed2b1daa 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetGenerateStatusSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetGenerateStatusSamples.java @@ -6,20 +6,22 @@ import java.util.UUID; -/** Samples for Recommendations GetGenerateStatus. */ +/** + * Samples for Recommendations GetGenerateStatus. + */ public final class RecommendationsGetGenerateStatusSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/EmptyResponse.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/EmptyResponse.json */ /** * Sample code: GetGenerateStatus. - * + * * @param manager Entry point to AdvisorManager. */ public static void getGenerateStatus(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .recommendations() - .getGenerateStatusWithResponse( - UUID.fromString("00000000-0000-0000-0000-000000000000"), com.azure.core.util.Context.NONE); + manager.recommendations() + .getGenerateStatusWithResponse(UUID.fromString("123e4567-e89b-12d3-a456-426614174000"), + com.azure.core.util.Context.NONE); } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetSamples.java index 6c8bb856f1c1..de5370340bc6 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetSamples.java @@ -4,14 +4,17 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Recommendations Get. */ +/** + * Samples for Recommendations Get. + */ public final class RecommendationsGetSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetRecommendationDetail.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/GetRecommendationDetail.json */ /** * Sample code: GetRecommendationDetail. - * + * * @param manager Entry point to AdvisorManager. */ public static void getRecommendationDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsListSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsListSamples.java index 08b9d14f7401..9693074e47dd 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsListSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsListSamples.java @@ -4,14 +4,17 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Recommendations List. */ +/** + * Samples for Recommendations List. + */ public final class RecommendationsListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListRecommendations.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListRecommendations.json */ /** * Sample code: ListRecommendations. - * + * * @param manager Entry point to AdvisorManager. */ public static void listRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ResourceProviderPredictSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ResourceProviderPredictSamples.java new file mode 100644 index 000000000000..702310612862 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ResourceProviderPredictSamples.java @@ -0,0 +1,35 @@ +// 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.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.advisor.models.PredictionRequest; +import com.azure.resourcemanager.advisor.models.PredictionType; +import java.io.IOException; + +/** + * Samples for ResourceProvider Predict. + */ +public final class ResourceProviderPredictSamples { + /* + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/Predict.json + */ + /** + * Sample code: Predict. + * + * @param manager Entry point to AdvisorManager. + */ + public static void predict(com.azure.resourcemanager.advisor.AdvisorManager manager) throws IOException { + manager.resourceProviders() + .predictWithResponse(new PredictionRequest().withPredictionType(PredictionType.PREDICTIVE_RIGHTSIZING) + .withExtendedProperties(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize( + "{\"type\":\"iaas\",\"deploymentType\":\"Linux_IaaS_Software_Store\",\"numberOfInstances\":10,\"region\":\"CentralUS\",\"sku\":\"Standard_Dv4\"}", + Object.class, SerializerEncoding.JSON)), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsCreateSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsCreateSamples.java index 2d0933834073..791522714850 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsCreateSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsCreateSamples.java @@ -4,19 +4,21 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Suppressions Create. */ +/** + * Samples for Suppressions Create. + */ public final class SuppressionsCreateSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateSuppression.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/CreateSuppression.json */ /** * Sample code: CreateSuppression. - * + * * @param manager Entry point to AdvisorManager. */ public static void createSuppression(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .suppressions() + manager.suppressions() .define("suppressionName1") .withExistingRecommendation("resourceUri", "recommendationId") .withTtl("07:00:00:00") diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsDeleteSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsDeleteSamples.java index d67406a3d0ab..c620b84a202e 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsDeleteSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsDeleteSamples.java @@ -4,20 +4,22 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Suppressions Delete. */ +/** + * Samples for Suppressions Delete. + */ public final class SuppressionsDeleteSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/DeleteSuppression.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/DeleteSuppression.json */ /** * Sample code: DeleteSuppression. - * + * * @param manager Entry point to AdvisorManager. */ public static void deleteSuppression(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .suppressions() - .deleteWithResponse( - "resourceUri", "recommendationId", "suppressionName1", com.azure.core.util.Context.NONE); + manager.suppressions() + .deleteWithResponse("resourceUri", "recommendationId", "suppressionName1", + com.azure.core.util.Context.NONE); } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsGetSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsGetSamples.java index 444e6a703960..4a37fdef98c5 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsGetSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsGetSamples.java @@ -4,19 +4,21 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Suppressions Get. */ +/** + * Samples for Suppressions Get. + */ public final class SuppressionsGetSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetSuppressionDetail.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/GetSuppressionDetail.json */ /** * Sample code: GetSuppressionDetail. - * + * * @param manager Entry point to AdvisorManager. */ public static void getSuppressionDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { - manager - .suppressions() + manager.suppressions() .getWithResponse("resourceUri", "recommendationId", "suppressionName1", com.azure.core.util.Context.NONE); } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsListSamples.java b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsListSamples.java index 1c51fa684271..3f1bcc2843a6 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsListSamples.java +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsListSamples.java @@ -4,14 +4,17 @@ package com.azure.resourcemanager.advisor.generated; -/** Samples for Suppressions List. */ +/** + * Samples for Suppressions List. + */ public final class SuppressionsListSamples { /* - * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListSuppressions.json + * x-ms-original-file: + * specification/advisor/resource-manager/Microsoft.Advisor/stable/2023-01-01/examples/ListSuppressions.json */ /** * Sample code: ListSuppressions. - * + * * @param manager Entry point to AdvisorManager. */ public static void listSuppressions(com.azure.resourcemanager.advisor.AdvisorManager manager) { diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigDataInnerTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigDataInnerTests.java deleted file mode 100644 index cce55e546afb..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigDataInnerTests.java +++ /dev/null @@ -1,64 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; -import com.azure.resourcemanager.advisor.models.CpuThreshold; -import com.azure.resourcemanager.advisor.models.DigestConfig; -import com.azure.resourcemanager.advisor.models.DigestConfigState; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; - -public final class ConfigDataInnerTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - ConfigDataInner model = - BinaryData - .fromString( - "{\"properties\":{\"exclude\":false,\"lowCpuThreshold\":\"10\",\"digests\":[{\"name\":\"hanufhfcbjysagi\",\"actionGroupResourceId\":\"xqhabi\",\"frequency\":1105410727,\"categories\":[],\"language\":\"wczbys\",\"state\":\"Active\"},{\"name\":\"x\",\"actionGroupResourceId\":\"ivyqniwbybrkxvd\",\"frequency\":920256064,\"categories\":[],\"language\":\"tfwvukxgaudc\",\"state\":\"Disabled\"}]},\"id\":\"h\",\"name\":\"jcny\",\"type\":\"j\"}") - .toObject(ConfigDataInner.class); - Assertions.assertEquals(false, model.exclude()); - Assertions.assertEquals(CpuThreshold.ONE_ZERO, model.lowCpuThreshold()); - Assertions.assertEquals("hanufhfcbjysagi", model.digests().get(0).name()); - Assertions.assertEquals("xqhabi", model.digests().get(0).actionGroupResourceId()); - Assertions.assertEquals(1105410727, model.digests().get(0).frequency()); - Assertions.assertEquals("wczbys", model.digests().get(0).language()); - Assertions.assertEquals(DigestConfigState.ACTIVE, model.digests().get(0).state()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - ConfigDataInner model = - new ConfigDataInner() - .withExclude(false) - .withLowCpuThreshold(CpuThreshold.ONE_ZERO) - .withDigests( - Arrays - .asList( - new DigestConfig() - .withName("hanufhfcbjysagi") - .withActionGroupResourceId("xqhabi") - .withFrequency(1105410727) - .withCategories(Arrays.asList()) - .withLanguage("wczbys") - .withState(DigestConfigState.ACTIVE), - new DigestConfig() - .withName("x") - .withActionGroupResourceId("ivyqniwbybrkxvd") - .withFrequency(920256064) - .withCategories(Arrays.asList()) - .withLanguage("tfwvukxgaudc") - .withState(DigestConfigState.DISABLED))); - model = BinaryData.fromObject(model).toObject(ConfigDataInner.class); - Assertions.assertEquals(false, model.exclude()); - Assertions.assertEquals(CpuThreshold.ONE_ZERO, model.lowCpuThreshold()); - Assertions.assertEquals("hanufhfcbjysagi", model.digests().get(0).name()); - Assertions.assertEquals("xqhabi", model.digests().get(0).actionGroupResourceId()); - Assertions.assertEquals(1105410727, model.digests().get(0).frequency()); - Assertions.assertEquals("wczbys", model.digests().get(0).language()); - Assertions.assertEquals(DigestConfigState.ACTIVE, model.digests().get(0).state()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigDataPropertiesTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigDataPropertiesTests.java deleted file mode 100644 index 2f3fdb7350fe..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigDataPropertiesTests.java +++ /dev/null @@ -1,75 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.ConfigDataProperties; -import com.azure.resourcemanager.advisor.models.Category; -import com.azure.resourcemanager.advisor.models.CpuThreshold; -import com.azure.resourcemanager.advisor.models.DigestConfig; -import com.azure.resourcemanager.advisor.models.DigestConfigState; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; - -public final class ConfigDataPropertiesTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - ConfigDataProperties model = - BinaryData - .fromString( - "{\"exclude\":true,\"lowCpuThreshold\":\"20\",\"digests\":[{\"name\":\"pczwlo\",\"actionGroupResourceId\":\"yemkkvnip\",\"frequency\":348606393,\"categories\":[\"Performance\",\"HighAvailability\"],\"language\":\"gejspodmailzyde\",\"state\":\"Disabled\"},{\"name\":\"yahux\",\"actionGroupResourceId\":\"pmqnja\",\"frequency\":1876507017,\"categories\":[\"Performance\",\"Performance\",\"Performance\"],\"language\":\"zvcputegjvwmfda\",\"state\":\"Active\"},{\"name\":\"dvpjhulsuuvmk\",\"actionGroupResourceId\":\"zkrwfn\",\"frequency\":287620729,\"categories\":[\"Performance\",\"Cost\"],\"language\":\"w\",\"state\":\"Disabled\"}]}") - .toObject(ConfigDataProperties.class); - Assertions.assertEquals(true, model.exclude()); - Assertions.assertEquals(CpuThreshold.TWO_ZERO, model.lowCpuThreshold()); - Assertions.assertEquals("pczwlo", model.digests().get(0).name()); - Assertions.assertEquals("yemkkvnip", model.digests().get(0).actionGroupResourceId()); - Assertions.assertEquals(348606393, model.digests().get(0).frequency()); - Assertions.assertEquals(Category.PERFORMANCE, model.digests().get(0).categories().get(0)); - Assertions.assertEquals("gejspodmailzyde", model.digests().get(0).language()); - Assertions.assertEquals(DigestConfigState.DISABLED, model.digests().get(0).state()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - ConfigDataProperties model = - new ConfigDataProperties() - .withExclude(true) - .withLowCpuThreshold(CpuThreshold.TWO_ZERO) - .withDigests( - Arrays - .asList( - new DigestConfig() - .withName("pczwlo") - .withActionGroupResourceId("yemkkvnip") - .withFrequency(348606393) - .withCategories(Arrays.asList(Category.PERFORMANCE, Category.HIGH_AVAILABILITY)) - .withLanguage("gejspodmailzyde") - .withState(DigestConfigState.DISABLED), - new DigestConfig() - .withName("yahux") - .withActionGroupResourceId("pmqnja") - .withFrequency(1876507017) - .withCategories( - Arrays.asList(Category.PERFORMANCE, Category.PERFORMANCE, Category.PERFORMANCE)) - .withLanguage("zvcputegjvwmfda") - .withState(DigestConfigState.ACTIVE), - new DigestConfig() - .withName("dvpjhulsuuvmk") - .withActionGroupResourceId("zkrwfn") - .withFrequency(287620729) - .withCategories(Arrays.asList(Category.PERFORMANCE, Category.COST)) - .withLanguage("w") - .withState(DigestConfigState.DISABLED))); - model = BinaryData.fromObject(model).toObject(ConfigDataProperties.class); - Assertions.assertEquals(true, model.exclude()); - Assertions.assertEquals(CpuThreshold.TWO_ZERO, model.lowCpuThreshold()); - Assertions.assertEquals("pczwlo", model.digests().get(0).name()); - Assertions.assertEquals("yemkkvnip", model.digests().get(0).actionGroupResourceId()); - Assertions.assertEquals(348606393, model.digests().get(0).frequency()); - Assertions.assertEquals(Category.PERFORMANCE, model.digests().get(0).categories().get(0)); - Assertions.assertEquals("gejspodmailzyde", model.digests().get(0).language()); - Assertions.assertEquals(DigestConfigState.DISABLED, model.digests().get(0).state()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationListResultTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationListResultTests.java deleted file mode 100644 index abda2c65f316..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationListResultTests.java +++ /dev/null @@ -1,52 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; -import com.azure.resourcemanager.advisor.models.ConfigurationListResult; -import com.azure.resourcemanager.advisor.models.CpuThreshold; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; - -public final class ConfigurationListResultTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - ConfigurationListResult model = - BinaryData - .fromString( - "{\"value\":[{\"properties\":{\"exclude\":false,\"lowCpuThreshold\":\"5\",\"digests\":[]},\"id\":\"urkdtmlx\",\"name\":\"ekuksjtx\",\"type\":\"kc\"},{\"properties\":{\"exclude\":true,\"lowCpuThreshold\":\"10\",\"digests\":[]},\"id\":\"y\",\"name\":\"anzwuxzdxta\",\"type\":\"rlhm\"},{\"properties\":{\"exclude\":false,\"lowCpuThreshold\":\"10\",\"digests\":[]},\"id\":\"obmtukk\",\"name\":\"ryrtihfxtijbpzv\",\"type\":\"nwzsymg\"}],\"nextLink\":\"uf\"}") - .toObject(ConfigurationListResult.class); - Assertions.assertEquals(false, model.value().get(0).exclude()); - Assertions.assertEquals(CpuThreshold.FIVE, model.value().get(0).lowCpuThreshold()); - Assertions.assertEquals("uf", model.nextLink()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - ConfigurationListResult model = - new ConfigurationListResult() - .withValue( - Arrays - .asList( - new ConfigDataInner() - .withExclude(false) - .withLowCpuThreshold(CpuThreshold.FIVE) - .withDigests(Arrays.asList()), - new ConfigDataInner() - .withExclude(true) - .withLowCpuThreshold(CpuThreshold.ONE_ZERO) - .withDigests(Arrays.asList()), - new ConfigDataInner() - .withExclude(false) - .withLowCpuThreshold(CpuThreshold.ONE_ZERO) - .withDigests(Arrays.asList()))) - .withNextLink("uf"); - model = BinaryData.fromObject(model).toObject(ConfigurationListResult.class); - Assertions.assertEquals(false, model.value().get(0).exclude()); - Assertions.assertEquals(CpuThreshold.FIVE, model.value().get(0).lowCpuThreshold()); - Assertions.assertEquals("uf", model.nextLink()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInResourceGroupWithResponseMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInResourceGroupWithResponseMockTests.java deleted file mode 100644 index 8df7fc344390..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInResourceGroupWithResponseMockTests.java +++ /dev/null @@ -1,78 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.ConfigData; -import com.azure.resourcemanager.advisor.models.ConfigurationName; -import com.azure.resourcemanager.advisor.models.CpuThreshold; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class ConfigurationsCreateInResourceGroupWithResponseMockTests { - @Test - public void testCreateInResourceGroupWithResponse() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"properties\":{\"exclude\":true,\"lowCpuThreshold\":\"20\",\"digests\":[]},\"id\":\"vwhheunmmqhgyx\",\"name\":\"konocu\",\"type\":\"oklyaxuconuq\"}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - ConfigData response = - manager - .configurations() - .define(ConfigurationName.DEFAULT) - .withExistingResourceGroup("zbinjeputtm") - .withExclude(false) - .withLowCpuThreshold(CpuThreshold.TWO_ZERO) - .withDigests(Arrays.asList()) - .create(); - - Assertions.assertEquals(true, response.exclude()); - Assertions.assertEquals(CpuThreshold.TWO_ZERO, response.lowCpuThreshold()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInSubscriptionWithResponseMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInSubscriptionWithResponseMockTests.java deleted file mode 100644 index 930da3f06712..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInSubscriptionWithResponseMockTests.java +++ /dev/null @@ -1,81 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -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 java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class ConfigurationsCreateInSubscriptionWithResponseMockTests { - @Test - public void testCreateInSubscriptionWithResponse() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"properties\":{\"exclude\":false,\"lowCpuThreshold\":\"20\",\"digests\":[]},\"id\":\"r\",\"name\":\"j\",\"type\":\"dpydn\"}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - ConfigData response = - manager - .configurations() - .createInSubscriptionWithResponse( - ConfigurationName.DEFAULT, - new ConfigDataInner() - .withExclude(true) - .withLowCpuThreshold(CpuThreshold.ONE_FIVE) - .withDigests(Arrays.asList()), - com.azure.core.util.Context.NONE) - .getValue(); - - Assertions.assertEquals(false, response.exclude()); - Assertions.assertEquals(CpuThreshold.TWO_ZERO, response.lowCpuThreshold()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListByResourceGroupMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListByResourceGroupMockTests.java deleted file mode 100644 index e6a92b671ea8..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListByResourceGroupMockTests.java +++ /dev/null @@ -1,70 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.ConfigData; -import com.azure.resourcemanager.advisor.models.CpuThreshold; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class ConfigurationsListByResourceGroupMockTests { - @Test - public void testListByResourceGroup() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"value\":[{\"properties\":{\"exclude\":false,\"lowCpuThreshold\":\"15\",\"digests\":[]},\"id\":\"bishcbkhajdeyea\",\"name\":\"dphagalpbuxwgip\",\"type\":\"honowkgshwank\"}]}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - PagedIterable response = - manager.configurations().listByResourceGroup("yhxdeoejzicwi", com.azure.core.util.Context.NONE); - - Assertions.assertEquals(false, response.iterator().next().exclude()); - Assertions.assertEquals(CpuThreshold.ONE_FIVE, response.iterator().next().lowCpuThreshold()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListMockTests.java deleted file mode 100644 index 139590dac4fb..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListMockTests.java +++ /dev/null @@ -1,69 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.ConfigData; -import com.azure.resourcemanager.advisor.models.CpuThreshold; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class ConfigurationsListMockTests { - @Test - public void testList() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"value\":[{\"properties\":{\"exclude\":true,\"lowCpuThreshold\":\"5\",\"digests\":[]},\"id\":\"xxjnspydptk\",\"name\":\"enkouknvudw\",\"type\":\"iukbldngkpoci\"}]}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - PagedIterable response = manager.configurations().list(com.azure.core.util.Context.NONE); - - Assertions.assertEquals(true, response.iterator().next().exclude()); - Assertions.assertEquals(CpuThreshold.FIVE, response.iterator().next().lowCpuThreshold()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/DigestConfigTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/DigestConfigTests.java deleted file mode 100644 index 181899cb9426..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/DigestConfigTests.java +++ /dev/null @@ -1,48 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.models.Category; -import com.azure.resourcemanager.advisor.models.DigestConfig; -import com.azure.resourcemanager.advisor.models.DigestConfigState; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; - -public final class DigestConfigTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - DigestConfig model = - BinaryData - .fromString( - "{\"name\":\"vwryoqpso\",\"actionGroupResourceId\":\"ctazakljlahbcryf\",\"frequency\":1389039399,\"categories\":[\"Performance\",\"Performance\"],\"language\":\"expa\",\"state\":\"Disabled\"}") - .toObject(DigestConfig.class); - Assertions.assertEquals("vwryoqpso", model.name()); - Assertions.assertEquals("ctazakljlahbcryf", model.actionGroupResourceId()); - Assertions.assertEquals(1389039399, model.frequency()); - Assertions.assertEquals(Category.PERFORMANCE, model.categories().get(0)); - Assertions.assertEquals("expa", model.language()); - Assertions.assertEquals(DigestConfigState.DISABLED, model.state()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - DigestConfig model = - new DigestConfig() - .withName("vwryoqpso") - .withActionGroupResourceId("ctazakljlahbcryf") - .withFrequency(1389039399) - .withCategories(Arrays.asList(Category.PERFORMANCE, Category.PERFORMANCE)) - .withLanguage("expa") - .withState(DigestConfigState.DISABLED); - model = BinaryData.fromObject(model).toObject(DigestConfig.class); - Assertions.assertEquals("vwryoqpso", model.name()); - Assertions.assertEquals("ctazakljlahbcryf", model.actionGroupResourceId()); - Assertions.assertEquals(1389039399, model.frequency()); - Assertions.assertEquals(Category.PERFORMANCE, model.categories().get(0)); - Assertions.assertEquals("expa", model.language()); - Assertions.assertEquals(DigestConfigState.DISABLED, model.state()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataEntityInnerTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataEntityInnerTests.java deleted file mode 100644 index 5c09b7fbf20c..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataEntityInnerTests.java +++ /dev/null @@ -1,57 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; -import com.azure.resourcemanager.advisor.models.MetadataSupportedValueDetail; -import com.azure.resourcemanager.advisor.models.Scenario; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; - -public final class MetadataEntityInnerTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - MetadataEntityInner model = - BinaryData - .fromString( - "{\"id\":\"mhquvgjxp\",\"type\":\"czmehmtzopbsp\",\"name\":\"upi\",\"properties\":{\"displayName\":\"ybbejhph\",\"dependsOn\":[\"msxaobhd\",\"bmtqioq\",\"zehtbmu\"],\"applicableScenarios\":[\"Alerts\",\"Alerts\"],\"supportedValues\":[{\"id\":\"hwlrx\",\"displayName\":\"qsoqijgkd\"},{\"id\":\"pazlobcufpdz\",\"displayName\":\"btcqq\"}]}}") - .toObject(MetadataEntityInner.class); - Assertions.assertEquals("mhquvgjxp", model.id()); - Assertions.assertEquals("czmehmtzopbsp", model.type()); - Assertions.assertEquals("upi", model.name()); - Assertions.assertEquals("ybbejhph", model.displayName()); - Assertions.assertEquals("msxaobhd", model.dependsOn().get(0)); - Assertions.assertEquals(Scenario.ALERTS, model.applicableScenarios().get(0)); - Assertions.assertEquals("hwlrx", model.supportedValues().get(0).id()); - Assertions.assertEquals("qsoqijgkd", model.supportedValues().get(0).displayName()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - MetadataEntityInner model = - new MetadataEntityInner() - .withId("mhquvgjxp") - .withType("czmehmtzopbsp") - .withName("upi") - .withDisplayName("ybbejhph") - .withDependsOn(Arrays.asList("msxaobhd", "bmtqioq", "zehtbmu")) - .withApplicableScenarios(Arrays.asList(Scenario.ALERTS, Scenario.ALERTS)) - .withSupportedValues( - Arrays - .asList( - new MetadataSupportedValueDetail().withId("hwlrx").withDisplayName("qsoqijgkd"), - new MetadataSupportedValueDetail().withId("pazlobcufpdz").withDisplayName("btcqq"))); - model = BinaryData.fromObject(model).toObject(MetadataEntityInner.class); - Assertions.assertEquals("mhquvgjxp", model.id()); - Assertions.assertEquals("czmehmtzopbsp", model.type()); - Assertions.assertEquals("upi", model.name()); - Assertions.assertEquals("ybbejhph", model.displayName()); - Assertions.assertEquals("msxaobhd", model.dependsOn().get(0)); - Assertions.assertEquals(Scenario.ALERTS, model.applicableScenarios().get(0)); - Assertions.assertEquals("hwlrx", model.supportedValues().get(0).id()); - Assertions.assertEquals("qsoqijgkd", model.supportedValues().get(0).displayName()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataEntityListResultTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataEntityListResultTests.java deleted file mode 100644 index 9c6d50c6fa48..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataEntityListResultTests.java +++ /dev/null @@ -1,51 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityInner; -import com.azure.resourcemanager.advisor.models.MetadataEntityListResult; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; - -public final class MetadataEntityListResultTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - MetadataEntityListResult model = - BinaryData - .fromString( - "{\"value\":[{\"id\":\"fdkfogk\",\"type\":\"gjofjd\",\"name\":\"qs\",\"properties\":{\"displayName\":\"upewnwreitjzy\",\"dependsOn\":[],\"applicableScenarios\":[],\"supportedValues\":[]}}],\"nextLink\":\"rh\"}") - .toObject(MetadataEntityListResult.class); - Assertions.assertEquals("fdkfogk", model.value().get(0).id()); - Assertions.assertEquals("gjofjd", model.value().get(0).type()); - Assertions.assertEquals("qs", model.value().get(0).name()); - Assertions.assertEquals("upewnwreitjzy", model.value().get(0).displayName()); - Assertions.assertEquals("rh", model.nextLink()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - MetadataEntityListResult model = - new MetadataEntityListResult() - .withValue( - Arrays - .asList( - new MetadataEntityInner() - .withId("fdkfogk") - .withType("gjofjd") - .withName("qs") - .withDisplayName("upewnwreitjzy") - .withDependsOn(Arrays.asList()) - .withApplicableScenarios(Arrays.asList()) - .withSupportedValues(Arrays.asList()))) - .withNextLink("rh"); - model = BinaryData.fromObject(model).toObject(MetadataEntityListResult.class); - Assertions.assertEquals("fdkfogk", model.value().get(0).id()); - Assertions.assertEquals("gjofjd", model.value().get(0).type()); - Assertions.assertEquals("qs", model.value().get(0).name()); - Assertions.assertEquals("upewnwreitjzy", model.value().get(0).displayName()); - Assertions.assertEquals("rh", model.nextLink()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataEntityPropertiesTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataEntityPropertiesTests.java deleted file mode 100644 index 6c1197e14e81..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataEntityPropertiesTests.java +++ /dev/null @@ -1,49 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.MetadataEntityProperties; -import com.azure.resourcemanager.advisor.models.MetadataSupportedValueDetail; -import com.azure.resourcemanager.advisor.models.Scenario; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; - -public final class MetadataEntityPropertiesTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - MetadataEntityProperties model = - BinaryData - .fromString( - "{\"displayName\":\"qglhq\",\"dependsOn\":[\"foooj\"],\"applicableScenarios\":[\"Alerts\",\"Alerts\",\"Alerts\",\"Alerts\"],\"supportedValues\":[{\"id\":\"gdf\",\"displayName\":\"lzl\"},{\"id\":\"xrifkwmrvkts\",\"displayName\":\"nt\"}]}") - .toObject(MetadataEntityProperties.class); - Assertions.assertEquals("qglhq", model.displayName()); - Assertions.assertEquals("foooj", model.dependsOn().get(0)); - Assertions.assertEquals(Scenario.ALERTS, model.applicableScenarios().get(0)); - Assertions.assertEquals("gdf", model.supportedValues().get(0).id()); - Assertions.assertEquals("lzl", model.supportedValues().get(0).displayName()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - MetadataEntityProperties model = - new MetadataEntityProperties() - .withDisplayName("qglhq") - .withDependsOn(Arrays.asList("foooj")) - .withApplicableScenarios( - Arrays.asList(Scenario.ALERTS, Scenario.ALERTS, Scenario.ALERTS, Scenario.ALERTS)) - .withSupportedValues( - Arrays - .asList( - new MetadataSupportedValueDetail().withId("gdf").withDisplayName("lzl"), - new MetadataSupportedValueDetail().withId("xrifkwmrvkts").withDisplayName("nt"))); - model = BinaryData.fromObject(model).toObject(MetadataEntityProperties.class); - Assertions.assertEquals("qglhq", model.displayName()); - Assertions.assertEquals("foooj", model.dependsOn().get(0)); - Assertions.assertEquals(Scenario.ALERTS, model.applicableScenarios().get(0)); - Assertions.assertEquals("gdf", model.supportedValues().get(0).id()); - Assertions.assertEquals("lzl", model.supportedValues().get(0).displayName()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataSupportedValueDetailTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataSupportedValueDetailTests.java deleted file mode 100644 index 8dcf56a68d84..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/MetadataSupportedValueDetailTests.java +++ /dev/null @@ -1,30 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.models.MetadataSupportedValueDetail; -import org.junit.jupiter.api.Assertions; - -public final class MetadataSupportedValueDetailTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - MetadataSupportedValueDetail model = - BinaryData - .fromString("{\"id\":\"ipa\",\"displayName\":\"ajpsquc\"}") - .toObject(MetadataSupportedValueDetail.class); - Assertions.assertEquals("ipa", model.id()); - Assertions.assertEquals("ajpsquc", model.displayName()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - MetadataSupportedValueDetail model = - new MetadataSupportedValueDetail().withId("ipa").withDisplayName("ajpsquc"); - model = BinaryData.fromObject(model).toObject(MetadataSupportedValueDetail.class); - Assertions.assertEquals("ipa", model.id()); - Assertions.assertEquals("ajpsquc", model.displayName()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationDisplayInfoTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationDisplayInfoTests.java deleted file mode 100644 index 4bdea31605fc..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationDisplayInfoTests.java +++ /dev/null @@ -1,39 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.models.OperationDisplayInfo; -import org.junit.jupiter.api.Assertions; - -public final class OperationDisplayInfoTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - OperationDisplayInfo model = - BinaryData - .fromString( - "{\"description\":\"ae\",\"operation\":\"fhyhltrpmopjmcma\",\"provider\":\"okth\",\"resource\":\"iuaod\"}") - .toObject(OperationDisplayInfo.class); - Assertions.assertEquals("ae", model.description()); - Assertions.assertEquals("fhyhltrpmopjmcma", model.operation()); - Assertions.assertEquals("okth", model.provider()); - Assertions.assertEquals("iuaod", model.resource()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - OperationDisplayInfo model = - new OperationDisplayInfo() - .withDescription("ae") - .withOperation("fhyhltrpmopjmcma") - .withProvider("okth") - .withResource("iuaod"); - model = BinaryData.fromObject(model).toObject(OperationDisplayInfo.class); - Assertions.assertEquals("ae", model.description()); - Assertions.assertEquals("fhyhltrpmopjmcma", model.operation()); - Assertions.assertEquals("okth", model.provider()); - Assertions.assertEquals("iuaod", model.resource()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationEntityInnerTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationEntityInnerTests.java deleted file mode 100644 index 818be0ea1fe3..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationEntityInnerTests.java +++ /dev/null @@ -1,45 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner; -import com.azure.resourcemanager.advisor.models.OperationDisplayInfo; -import org.junit.jupiter.api.Assertions; - -public final class OperationEntityInnerTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - OperationEntityInner model = - BinaryData - .fromString( - "{\"name\":\"jrefovgmkqsle\",\"display\":{\"description\":\"xyqj\",\"operation\":\"cattpngjcrcczsq\",\"provider\":\"hvmdajvnysounq\",\"resource\":\"a\"}}") - .toObject(OperationEntityInner.class); - Assertions.assertEquals("jrefovgmkqsle", model.name()); - Assertions.assertEquals("xyqj", model.display().description()); - Assertions.assertEquals("cattpngjcrcczsq", model.display().operation()); - Assertions.assertEquals("hvmdajvnysounq", model.display().provider()); - Assertions.assertEquals("a", model.display().resource()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - OperationEntityInner model = - new OperationEntityInner() - .withName("jrefovgmkqsle") - .withDisplay( - new OperationDisplayInfo() - .withDescription("xyqj") - .withOperation("cattpngjcrcczsq") - .withProvider("hvmdajvnysounq") - .withResource("a")); - model = BinaryData.fromObject(model).toObject(OperationEntityInner.class); - Assertions.assertEquals("jrefovgmkqsle", model.name()); - Assertions.assertEquals("xyqj", model.display().description()); - Assertions.assertEquals("cattpngjcrcczsq", model.display().operation()); - Assertions.assertEquals("hvmdajvnysounq", model.display().provider()); - Assertions.assertEquals("a", model.display().resource()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationEntityListResultTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationEntityListResultTests.java deleted file mode 100644 index 78bab232fcab..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationEntityListResultTests.java +++ /dev/null @@ -1,78 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.OperationEntityInner; -import com.azure.resourcemanager.advisor.models.OperationDisplayInfo; -import com.azure.resourcemanager.advisor.models.OperationEntityListResult; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; - -public final class OperationEntityListResultTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - OperationEntityListResult model = - BinaryData - .fromString( - "{\"nextLink\":\"ochcbonqvpkvl\",\"value\":[{\"name\":\"ea\",\"display\":{\"description\":\"pheoflokeyy\",\"operation\":\"nj\",\"provider\":\"lwtgrhpdj\",\"resource\":\"umasxazjpq\"}},{\"name\":\"gual\",\"display\":{\"description\":\"xhejjzzvdud\",\"operation\":\"dslfhotwmcy\",\"provider\":\"wlbjnpgacftade\",\"resource\":\"nltyfsoppusuesnz\"}},{\"name\":\"ej\",\"display\":{\"description\":\"orxzdmohctbqvud\",\"operation\":\"dndnvow\",\"provider\":\"jjugwdkcglhslaz\",\"resource\":\"yggdtjixh\"}},{\"name\":\"uofqwe\",\"display\":{\"description\":\"menevfyexfwh\",\"operation\":\"cibvyvdcsitynn\",\"provider\":\"mdectehfiqscjey\",\"resource\":\"hezrkgq\"}}]}") - .toObject(OperationEntityListResult.class); - Assertions.assertEquals("ochcbonqvpkvl", model.nextLink()); - Assertions.assertEquals("ea", model.value().get(0).name()); - Assertions.assertEquals("pheoflokeyy", model.value().get(0).display().description()); - Assertions.assertEquals("nj", model.value().get(0).display().operation()); - Assertions.assertEquals("lwtgrhpdj", model.value().get(0).display().provider()); - Assertions.assertEquals("umasxazjpq", model.value().get(0).display().resource()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - OperationEntityListResult model = - new OperationEntityListResult() - .withNextLink("ochcbonqvpkvl") - .withValue( - Arrays - .asList( - new OperationEntityInner() - .withName("ea") - .withDisplay( - new OperationDisplayInfo() - .withDescription("pheoflokeyy") - .withOperation("nj") - .withProvider("lwtgrhpdj") - .withResource("umasxazjpq")), - new OperationEntityInner() - .withName("gual") - .withDisplay( - new OperationDisplayInfo() - .withDescription("xhejjzzvdud") - .withOperation("dslfhotwmcy") - .withProvider("wlbjnpgacftade") - .withResource("nltyfsoppusuesnz")), - new OperationEntityInner() - .withName("ej") - .withDisplay( - new OperationDisplayInfo() - .withDescription("orxzdmohctbqvud") - .withOperation("dndnvow") - .withProvider("jjugwdkcglhslaz") - .withResource("yggdtjixh")), - new OperationEntityInner() - .withName("uofqwe") - .withDisplay( - new OperationDisplayInfo() - .withDescription("menevfyexfwh") - .withOperation("cibvyvdcsitynn") - .withProvider("mdectehfiqscjey") - .withResource("hezrkgq")))); - model = BinaryData.fromObject(model).toObject(OperationEntityListResult.class); - Assertions.assertEquals("ochcbonqvpkvl", model.nextLink()); - Assertions.assertEquals("ea", model.value().get(0).name()); - Assertions.assertEquals("pheoflokeyy", model.value().get(0).display().description()); - Assertions.assertEquals("nj", model.value().get(0).display().operation()); - Assertions.assertEquals("lwtgrhpdj", model.value().get(0).display().provider()); - Assertions.assertEquals("umasxazjpq", model.value().get(0).display().resource()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationsListMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationsListMockTests.java deleted file mode 100644 index f8f725232399..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/OperationsListMockTests.java +++ /dev/null @@ -1,71 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.OperationEntity; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class OperationsListMockTests { - @Test - public void testList() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"value\":[{\"name\":\"fmisg\",\"display\":{\"description\":\"b\",\"operation\":\"ldawkzbaliourqha\",\"provider\":\"uhashsfwx\",\"resource\":\"owzxcu\"}}]}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - PagedIterable response = manager.operations().list(com.azure.core.util.Context.NONE); - - Assertions.assertEquals("fmisg", response.iterator().next().name()); - Assertions.assertEquals("b", response.iterator().next().display().description()); - Assertions.assertEquals("ldawkzbaliourqha", response.iterator().next().display().operation()); - Assertions.assertEquals("uhashsfwx", response.iterator().next().display().provider()); - Assertions.assertEquals("owzxcu", response.iterator().next().display().resource()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadatasGetWithResponseMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadatasGetWithResponseMockTests.java deleted file mode 100644 index a14a0478ed82..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadatasGetWithResponseMockTests.java +++ /dev/null @@ -1,73 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.MetadataEntity; -import com.azure.resourcemanager.advisor.models.Scenario; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class RecommendationMetadatasGetWithResponseMockTests { - @Test - public void testGetWithResponse() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"id\":\"sovmyokacspkwl\",\"type\":\"dobpxjmflbvvn\",\"name\":\"rkcciwwzjuqk\",\"properties\":{\"displayName\":\"ajiwkuo\",\"dependsOn\":[\"kg\",\"sauuimj\",\"vxieduugidyj\"],\"applicableScenarios\":[\"Alerts\"],\"supportedValues\":[]}}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - MetadataEntity response = - manager.recommendationMetadatas().getWithResponse("iqzbq", com.azure.core.util.Context.NONE).getValue(); - - Assertions.assertEquals("sovmyokacspkwl", response.id()); - Assertions.assertEquals("dobpxjmflbvvn", response.type()); - Assertions.assertEquals("rkcciwwzjuqk", response.name()); - Assertions.assertEquals("ajiwkuo", response.displayName()); - Assertions.assertEquals("kg", response.dependsOn().get(0)); - Assertions.assertEquals(Scenario.ALERTS, response.applicableScenarios().get(0)); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadatasListMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadatasListMockTests.java deleted file mode 100644 index a3b58cee5c76..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadatasListMockTests.java +++ /dev/null @@ -1,74 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.MetadataEntity; -import com.azure.resourcemanager.advisor.models.Scenario; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class RecommendationMetadatasListMockTests { - @Test - public void testList() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"value\":[{\"id\":\"svexcsonpclhoco\",\"type\":\"lkevle\",\"name\":\"zfbuhf\",\"properties\":{\"displayName\":\"axkffei\",\"dependsOn\":[\"lvmezyvshxmzsbbz\"],\"applicableScenarios\":[\"Alerts\"],\"supportedValues\":[]}}]}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - PagedIterable response = - manager.recommendationMetadatas().list(com.azure.core.util.Context.NONE); - - Assertions.assertEquals("svexcsonpclhoco", response.iterator().next().id()); - Assertions.assertEquals("lkevle", response.iterator().next().type()); - Assertions.assertEquals("zfbuhf", response.iterator().next().name()); - Assertions.assertEquals("axkffei", response.iterator().next().displayName()); - Assertions.assertEquals("lvmezyvshxmzsbbz", response.iterator().next().dependsOn().get(0)); - Assertions.assertEquals(Scenario.ALERTS, response.iterator().next().applicableScenarios().get(0)); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationPropertiesTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationPropertiesTests.java deleted file mode 100644 index f53d7875cbc8..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationPropertiesTests.java +++ /dev/null @@ -1,147 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.RecommendationProperties; -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.ShortDescription; -import java.time.OffsetDateTime; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Assertions; - -public final class RecommendationPropertiesTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - RecommendationProperties model = - BinaryData - .fromString( - "{\"category\":\"OperationalExcellence\",\"impact\":\"Medium\",\"impactedField\":\"irsoodqxhcrmnohj\",\"impactedValue\":\"kwh\",\"lastUpdated\":\"2021-05-11T08:11:32Z\",\"metadata\":{\"pjxsqwpgrjbznor\":\"dataiy\",\"ocpcy\":\"datajxvsnbyxqabn\",\"gpbtoqcjmklj\":\"datahurzafblj\",\"qajzyulpkudjkr\":\"datavbqid\"},\"recommendationTypeId\":\"hbzhfepg\",\"shortDescription\":{\"problem\":\"e\",\"solution\":\"locx\"},\"suppressionIds\":[\"6b445862-0f55-4f3d-858d-420859a95f61\",\"e41a5c93-9e36-4f1a-b2cc-9640330c27f2\"],\"extendedProperties\":{\"jtjaodxobnbdxkq\":\"erhhbcsglumm\",\"ajionpimexgstxg\":\"xo\",\"gmaajrm\":\"po\",\"clwhijcoejctbz\":\"djwzrlov\"},\"resourceMetadata\":{\"resourceId\":\"qsycbkbfkgu\",\"source\":\"kexxppof\",\"action\":{\"fjpgddtocjjxhvp\":\"datax\",\"exhd\":\"datao\",\"bzv\":\"dataxibqeojnx\",\"pzaoqvuhr\":\"datadntwndeicbtw\"},\"singular\":\"f\",\"plural\":\"yd\"},\"description\":\"lmjthjq\",\"label\":\"pyeicxm\",\"learnMoreLink\":\"iwqvhkh\",\"potentialBenefits\":\"uigdtopbobjog\",\"actions\":[{\"m\":\"datau\"}],\"remediation\":{\"t\":\"datarzayv\",\"ln\":\"datagvdfgiotkftutq\",\"qmi\":\"dataxlefgugnxkrx\",\"abhjybi\":\"datatthzrvqd\"},\"exposedMetadataProperties\":{\"zlcuiywgqywgndrv\":\"dataoqfbowskanyk\"}}") - .toObject(RecommendationProperties.class); - Assertions.assertEquals(Category.OPERATIONAL_EXCELLENCE, model.category()); - Assertions.assertEquals(Impact.MEDIUM, model.impact()); - Assertions.assertEquals("irsoodqxhcrmnohj", model.impactedField()); - Assertions.assertEquals("kwh", model.impactedValue()); - Assertions.assertEquals(OffsetDateTime.parse("2021-05-11T08:11:32Z"), model.lastUpdated()); - Assertions.assertEquals("hbzhfepg", model.recommendationTypeId()); - Assertions.assertEquals("e", model.shortDescription().problem()); - Assertions.assertEquals("locx", model.shortDescription().solution()); - Assertions.assertEquals(UUID.fromString("6b445862-0f55-4f3d-858d-420859a95f61"), model.suppressionIds().get(0)); - Assertions.assertEquals("erhhbcsglumm", model.extendedProperties().get("jtjaodxobnbdxkq")); - Assertions.assertEquals("qsycbkbfkgu", model.resourceMetadata().resourceId()); - Assertions.assertEquals("kexxppof", model.resourceMetadata().source()); - Assertions.assertEquals("f", model.resourceMetadata().singular()); - Assertions.assertEquals("yd", model.resourceMetadata().plural()); - Assertions.assertEquals("lmjthjq", model.description()); - Assertions.assertEquals("pyeicxm", model.label()); - Assertions.assertEquals("iwqvhkh", model.learnMoreLink()); - Assertions.assertEquals("uigdtopbobjog", model.potentialBenefits()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - RecommendationProperties model = - new RecommendationProperties() - .withCategory(Category.OPERATIONAL_EXCELLENCE) - .withImpact(Impact.MEDIUM) - .withImpactedField("irsoodqxhcrmnohj") - .withImpactedValue("kwh") - .withLastUpdated(OffsetDateTime.parse("2021-05-11T08:11:32Z")) - .withMetadata( - mapOf( - "pjxsqwpgrjbznor", - "dataiy", - "ocpcy", - "datajxvsnbyxqabn", - "gpbtoqcjmklj", - "datahurzafblj", - "qajzyulpkudjkr", - "datavbqid")) - .withRecommendationTypeId("hbzhfepg") - .withShortDescription(new ShortDescription().withProblem("e").withSolution("locx")) - .withSuppressionIds( - Arrays - .asList( - UUID.fromString("6b445862-0f55-4f3d-858d-420859a95f61"), - UUID.fromString("e41a5c93-9e36-4f1a-b2cc-9640330c27f2"))) - .withExtendedProperties( - mapOf( - "jtjaodxobnbdxkq", - "erhhbcsglumm", - "ajionpimexgstxg", - "xo", - "gmaajrm", - "po", - "clwhijcoejctbz", - "djwzrlov")) - .withResourceMetadata( - new ResourceMetadata() - .withResourceId("qsycbkbfkgu") - .withSource("kexxppof") - .withAction( - mapOf( - "fjpgddtocjjxhvp", - "datax", - "exhd", - "datao", - "bzv", - "dataxibqeojnx", - "pzaoqvuhr", - "datadntwndeicbtw")) - .withSingular("f") - .withPlural("yd")) - .withDescription("lmjthjq") - .withLabel("pyeicxm") - .withLearnMoreLink("iwqvhkh") - .withPotentialBenefits("uigdtopbobjog") - .withActions(Arrays.asList(mapOf("m", "datau"))) - .withRemediation( - mapOf( - "t", - "datarzayv", - "ln", - "datagvdfgiotkftutq", - "qmi", - "dataxlefgugnxkrx", - "abhjybi", - "datatthzrvqd")) - .withExposedMetadataProperties(mapOf("zlcuiywgqywgndrv", "dataoqfbowskanyk")); - model = BinaryData.fromObject(model).toObject(RecommendationProperties.class); - Assertions.assertEquals(Category.OPERATIONAL_EXCELLENCE, model.category()); - Assertions.assertEquals(Impact.MEDIUM, model.impact()); - Assertions.assertEquals("irsoodqxhcrmnohj", model.impactedField()); - Assertions.assertEquals("kwh", model.impactedValue()); - Assertions.assertEquals(OffsetDateTime.parse("2021-05-11T08:11:32Z"), model.lastUpdated()); - Assertions.assertEquals("hbzhfepg", model.recommendationTypeId()); - Assertions.assertEquals("e", model.shortDescription().problem()); - Assertions.assertEquals("locx", model.shortDescription().solution()); - Assertions.assertEquals(UUID.fromString("6b445862-0f55-4f3d-858d-420859a95f61"), model.suppressionIds().get(0)); - Assertions.assertEquals("erhhbcsglumm", model.extendedProperties().get("jtjaodxobnbdxkq")); - Assertions.assertEquals("qsycbkbfkgu", model.resourceMetadata().resourceId()); - Assertions.assertEquals("kexxppof", model.resourceMetadata().source()); - Assertions.assertEquals("f", model.resourceMetadata().singular()); - Assertions.assertEquals("yd", model.resourceMetadata().plural()); - Assertions.assertEquals("lmjthjq", model.description()); - Assertions.assertEquals("pyeicxm", model.label()); - Assertions.assertEquals("iwqvhkh", model.learnMoreLink()); - Assertions.assertEquals("uigdtopbobjog", model.potentialBenefits()); - } - - @SuppressWarnings("unchecked") - private static Map mapOf(Object... inputs) { - Map map = new HashMap<>(); - for (int i = 0; i < inputs.length; i += 2) { - String key = (String) inputs[i]; - T value = (T) inputs[i + 1]; - map.put(key, value); - } - return map; - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsGenerateWithResponseMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsGenerateWithResponseMockTests.java deleted file mode 100644 index ff15c79d60a5..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsGenerateWithResponseMockTests.java +++ /dev/null @@ -1,61 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class RecommendationsGenerateWithResponseMockTests { - @Test - public void testGenerateWithResponse() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = "{}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(202); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - manager.recommendations().generateWithResponse(com.azure.core.util.Context.NONE); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetGenerateStatusWithResponseMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetGenerateStatusWithResponseMockTests.java deleted file mode 100644 index 1c3b36612071..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetGenerateStatusWithResponseMockTests.java +++ /dev/null @@ -1,65 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class RecommendationsGetGenerateStatusWithResponseMockTests { - @Test - public void testGetGenerateStatusWithResponse() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = "{}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(202); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - manager - .recommendations() - .getGenerateStatusWithResponse( - UUID.fromString("7c3b7a3d-6567-4550-b20b-ac600881a76b"), com.azure.core.util.Context.NONE); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetWithResponseMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetWithResponseMockTests.java deleted file mode 100644 index c4c7cf62f43c..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetWithResponseMockTests.java +++ /dev/null @@ -1,88 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.Category; -import com.azure.resourcemanager.advisor.models.Impact; -import com.azure.resourcemanager.advisor.models.ResourceRecommendationBase; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import java.util.UUID; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class RecommendationsGetWithResponseMockTests { - @Test - public void testGetWithResponse() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"properties\":{\"category\":\"Security\",\"impact\":\"High\",\"impactedField\":\"kfssxqukkf\",\"impactedValue\":\"gmgsxnkjzkde\",\"lastUpdated\":\"2021-08-30T18:12:55Z\",\"metadata\":{\"ighxpk\":\"dataopwi\",\"baumnyqupedeoj\":\"datawzbaiue\"},\"recommendationTypeId\":\"bckhsmtxpsi\",\"shortDescription\":{\"problem\":\"fhvpesaps\",\"solution\":\"dqmh\"},\"suppressionIds\":[\"b1eecfad-1b6f-4eda-bd1b-d71c2a0d518d\",\"b8b70fe5-ab05-4fed-a3d9-903cb3756293\",\"10d00cfa-8b19-45c1-be70-06062e19c80a\"],\"extendedProperties\":{\"ws\":\"ldwkyzxuutkn\",\"vnm\":\"wsvlxotogtwrupqs\",\"eil\":\"cykvceo\"},\"resourceMetadata\":{\"resourceId\":\"oty\",\"source\":\"fcnj\",\"action\":{},\"singular\":\"nxdhbt\",\"plural\":\"phywpnvj\"},\"description\":\"qnermclfplphoxu\",\"label\":\"rpabg\",\"learnMoreLink\":\"psbjta\",\"potentialBenefits\":\"ugxywpmueef\",\"actions\":[{\"onobglaocqx\":\"dataqkqujidsu\",\"yudxytlmoy\":\"dataccm\"},{\"hl\":\"datavwfudwpzntxhd\"}],\"remediation\":{\"kfrlhrxsbky\":\"databh\",\"afkuwb\":\"datapycanuzbpz\",\"ehhseyvjusrts\":\"datarnwb\"},\"exposedMetadataProperties\":{\"elmqk\":\"datapkdeemaofmxagkvt\",\"hcdhmdual\":\"datahahvljuahaq\"}},\"id\":\"exq\",\"name\":\"vfadmws\",\"type\":\"crgvxpvgom\"}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - ResourceRecommendationBase response = - manager.recommendations().getWithResponse("ovplw", "bhvgy", com.azure.core.util.Context.NONE).getValue(); - - Assertions.assertEquals(Category.SECURITY, response.category()); - Assertions.assertEquals(Impact.HIGH, response.impact()); - Assertions.assertEquals("kfssxqukkf", response.impactedField()); - Assertions.assertEquals("gmgsxnkjzkde", response.impactedValue()); - Assertions.assertEquals(OffsetDateTime.parse("2021-08-30T18:12:55Z"), response.lastUpdated()); - Assertions.assertEquals("bckhsmtxpsi", response.recommendationTypeId()); - Assertions.assertEquals("fhvpesaps", response.shortDescription().problem()); - Assertions.assertEquals("dqmh", response.shortDescription().solution()); - Assertions - .assertEquals(UUID.fromString("b1eecfad-1b6f-4eda-bd1b-d71c2a0d518d"), response.suppressionIds().get(0)); - Assertions.assertEquals("ldwkyzxuutkn", response.extendedProperties().get("ws")); - Assertions.assertEquals("oty", response.resourceMetadata().resourceId()); - Assertions.assertEquals("fcnj", response.resourceMetadata().source()); - Assertions.assertEquals("nxdhbt", response.resourceMetadata().singular()); - Assertions.assertEquals("phywpnvj", response.resourceMetadata().plural()); - Assertions.assertEquals("qnermclfplphoxu", response.description()); - Assertions.assertEquals("rpabg", response.label()); - Assertions.assertEquals("psbjta", response.learnMoreLink()); - Assertions.assertEquals("ugxywpmueef", response.potentialBenefits()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsListMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsListMockTests.java deleted file mode 100644 index 8320a4a65d08..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/RecommendationsListMockTests.java +++ /dev/null @@ -1,91 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.Category; -import com.azure.resourcemanager.advisor.models.Impact; -import com.azure.resourcemanager.advisor.models.ResourceRecommendationBase; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import java.util.UUID; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class RecommendationsListMockTests { - @Test - public void testList() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"value\":[{\"properties\":{\"category\":\"HighAvailability\",\"impact\":\"Medium\",\"impactedField\":\"vvjektcxsenhwlrs\",\"impactedValue\":\"rzpwvlqdqgbiq\",\"lastUpdated\":\"2021-02-23T11:21:53Z\",\"metadata\":{\"kymuctqhjfbebr\":\"dataaetcktvfcivfs\"},\"recommendationTypeId\":\"xerf\",\"shortDescription\":{\"problem\":\"tttxfvjrb\",\"solution\":\"phxepcyvahf\"},\"suppressionIds\":[\"240ce7b3-f1ad-44b8-97ad-777c1c4a1715\"],\"extendedProperties\":{\"uujqgidokgjljyo\":\"qxj\"},\"resourceMetadata\":{\"resourceId\":\"cltbgsncghkjesz\",\"source\":\"bijhtxfvgxbf\",\"action\":{},\"singular\":\"nehmpvecx\",\"plural\":\"debfqkkrbmpukgri\"},\"description\":\"lzlfbxzpuz\",\"label\":\"ispnqzahmgkbrp\",\"learnMoreLink\":\"dhibnuq\",\"potentialBenefits\":\"pikad\",\"actions\":[{\"ijggmebfsiar\":\"dataqagnbuyn\",\"pnazzm\":\"datautrc\",\"bh\":\"datajrunmpxtt\"}],\"remediation\":{\"nkxmyskpbhenbtk\":\"datal\",\"yxczfclh\":\"dataxywnytnrsynlqidy\",\"wrqlfktsthsuco\":\"dataaxdbabph\"},\"exposedMetadataProperties\":{\"wrqpue\":\"datayyazttbt\",\"xibxujwbhqwalm\":\"datackzywbiexzfeyue\",\"ux\":\"datazyoxaepdkzjan\",\"zt\":\"datahdwbavxbniwdjs\"}},\"id\":\"dbpgnxytxhp\",\"name\":\"xbzpfzab\",\"type\":\"lcuhxwtctyqiklb\"}]}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - PagedIterable response = - manager.recommendations().list("zf", 585426916, "eyp", com.azure.core.util.Context.NONE); - - Assertions.assertEquals(Category.HIGH_AVAILABILITY, response.iterator().next().category()); - Assertions.assertEquals(Impact.MEDIUM, response.iterator().next().impact()); - Assertions.assertEquals("vvjektcxsenhwlrs", response.iterator().next().impactedField()); - Assertions.assertEquals("rzpwvlqdqgbiq", response.iterator().next().impactedValue()); - Assertions.assertEquals(OffsetDateTime.parse("2021-02-23T11:21:53Z"), response.iterator().next().lastUpdated()); - Assertions.assertEquals("xerf", response.iterator().next().recommendationTypeId()); - Assertions.assertEquals("tttxfvjrb", response.iterator().next().shortDescription().problem()); - Assertions.assertEquals("phxepcyvahf", response.iterator().next().shortDescription().solution()); - Assertions - .assertEquals( - UUID.fromString("240ce7b3-f1ad-44b8-97ad-777c1c4a1715"), - response.iterator().next().suppressionIds().get(0)); - Assertions.assertEquals("qxj", response.iterator().next().extendedProperties().get("uujqgidokgjljyo")); - Assertions.assertEquals("cltbgsncghkjesz", response.iterator().next().resourceMetadata().resourceId()); - Assertions.assertEquals("bijhtxfvgxbf", response.iterator().next().resourceMetadata().source()); - Assertions.assertEquals("nehmpvecx", response.iterator().next().resourceMetadata().singular()); - Assertions.assertEquals("debfqkkrbmpukgri", response.iterator().next().resourceMetadata().plural()); - Assertions.assertEquals("lzlfbxzpuz", response.iterator().next().description()); - Assertions.assertEquals("ispnqzahmgkbrp", response.iterator().next().label()); - Assertions.assertEquals("dhibnuq", response.iterator().next().learnMoreLink()); - Assertions.assertEquals("pikad", response.iterator().next().potentialBenefits()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ResourceMetadataTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ResourceMetadataTests.java deleted file mode 100644 index afbf1ccfab0d..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ResourceMetadataTests.java +++ /dev/null @@ -1,53 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.models.ResourceMetadata; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Assertions; - -public final class ResourceMetadataTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - ResourceMetadata model = - BinaryData - .fromString( - "{\"resourceId\":\"zevgb\",\"source\":\"jqabcypmivkwlzuv\",\"action\":{\"onlebxetqgtzxdpn\":\"datawnfnbacf\",\"eallnwsubisnj\":\"databqqwxrj\"},\"singular\":\"pmng\",\"plural\":\"scxaq\"}") - .toObject(ResourceMetadata.class); - Assertions.assertEquals("zevgb", model.resourceId()); - Assertions.assertEquals("jqabcypmivkwlzuv", model.source()); - Assertions.assertEquals("pmng", model.singular()); - Assertions.assertEquals("scxaq", model.plural()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - ResourceMetadata model = - new ResourceMetadata() - .withResourceId("zevgb") - .withSource("jqabcypmivkwlzuv") - .withAction(mapOf("onlebxetqgtzxdpn", "datawnfnbacf", "eallnwsubisnj", "databqqwxrj")) - .withSingular("pmng") - .withPlural("scxaq"); - model = BinaryData.fromObject(model).toObject(ResourceMetadata.class); - Assertions.assertEquals("zevgb", model.resourceId()); - Assertions.assertEquals("jqabcypmivkwlzuv", model.source()); - Assertions.assertEquals("pmng", model.singular()); - Assertions.assertEquals("scxaq", model.plural()); - } - - @SuppressWarnings("unchecked") - private static Map mapOf(Object... inputs) { - Map map = new HashMap<>(); - for (int i = 0; i < inputs.length; i += 2) { - String key = (String) inputs[i]; - T value = (T) inputs[i + 1]; - map.put(key, value); - } - return map; - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ResourceRecommendationBaseInnerTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ResourceRecommendationBaseInnerTests.java deleted file mode 100644 index a45bd7d9e905..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ResourceRecommendationBaseInnerTests.java +++ /dev/null @@ -1,135 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -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.ShortDescription; -import java.time.OffsetDateTime; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Assertions; - -public final class ResourceRecommendationBaseInnerTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - ResourceRecommendationBaseInner model = - BinaryData - .fromString( - "{\"properties\":{\"category\":\"Performance\",\"impact\":\"Low\",\"impactedField\":\"njbiksqrglssain\",\"impactedValue\":\"jwnzlljfmp\",\"lastUpdated\":\"2021-09-21T11:36:48Z\",\"metadata\":{\"yqduujit\":\"datamgxsab\",\"rwpdappdsbdkvwrw\":\"datajczdzevndh\"},\"recommendationTypeId\":\"eusnhutj\",\"shortDescription\":{\"problem\":\"mrldhu\",\"solution\":\"zzd\"},\"suppressionIds\":[\"7edaf309-156b-4fa8-84db-d97fe78c459e\",\"5b410fd8-362a-4c4a-8624-92464dd7bd45\",\"3852d285-8e67-49f3-8463-59bd01ee8d65\",\"84cbe077-afa8-46e3-bf17-3e31cbf738af\"],\"extendedProperties\":{\"geablgphuticndvk\":\"oc\",\"ftyxolniw\":\"ozwyiftyhxhuro\"},\"resourceMetadata\":{\"resourceId\":\"ukjfkgiawxklr\",\"source\":\"lwckbasyypnddhs\",\"action\":{\"qgoulznd\":\"dataacphejkoty\",\"wyqkgfgibm\":\"datai\",\"qsrxybzqqed\":\"datadgak\"},\"singular\":\"tbciqfouflmm\",\"plural\":\"zsm\"},\"description\":\"mglougpbkw\",\"label\":\"utduqktapspwgcu\",\"learnMoreLink\":\"tumkdosvqwhbm\",\"potentialBenefits\":\"bbjfddgmbmbexp\",\"actions\":[{\"rolfpfp\":\"dataq\"},{\"yjgzjaoyfhrtxiln\":\"datalgbquxig\",\"vlejuvfqa\":\"datarkujy\",\"xgjvtbv\":\"datarlyxwjkcprbnw\",\"uouq\":\"dataysszdnrujqguh\"},{\"itnwuizgazxufi\":\"datarwzwbng\",\"hr\":\"datauckyf\",\"zwdzuh\":\"dataidf\",\"wxmnteiwao\":\"dataymwisdkft\"}],\"remediation\":{\"pymzidnsezcxtbzs\":\"datamijcmmxdcufufs\"},\"exposedMetadataProperties\":{\"sne\":\"datac\"}},\"id\":\"mdwzjeiachboo\",\"name\":\"flnrosfqpteehzz\",\"type\":\"ypyqrimzinp\"}") - .toObject(ResourceRecommendationBaseInner.class); - Assertions.assertEquals(Category.PERFORMANCE, model.category()); - Assertions.assertEquals(Impact.LOW, model.impact()); - Assertions.assertEquals("njbiksqrglssain", model.impactedField()); - Assertions.assertEquals("jwnzlljfmp", model.impactedValue()); - Assertions.assertEquals(OffsetDateTime.parse("2021-09-21T11:36:48Z"), model.lastUpdated()); - Assertions.assertEquals("eusnhutj", model.recommendationTypeId()); - Assertions.assertEquals("mrldhu", model.shortDescription().problem()); - Assertions.assertEquals("zzd", model.shortDescription().solution()); - Assertions.assertEquals(UUID.fromString("7edaf309-156b-4fa8-84db-d97fe78c459e"), model.suppressionIds().get(0)); - Assertions.assertEquals("oc", model.extendedProperties().get("geablgphuticndvk")); - Assertions.assertEquals("ukjfkgiawxklr", model.resourceMetadata().resourceId()); - Assertions.assertEquals("lwckbasyypnddhs", model.resourceMetadata().source()); - Assertions.assertEquals("tbciqfouflmm", model.resourceMetadata().singular()); - Assertions.assertEquals("zsm", model.resourceMetadata().plural()); - Assertions.assertEquals("mglougpbkw", model.description()); - Assertions.assertEquals("utduqktapspwgcu", model.label()); - Assertions.assertEquals("tumkdosvqwhbm", model.learnMoreLink()); - Assertions.assertEquals("bbjfddgmbmbexp", model.potentialBenefits()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - ResourceRecommendationBaseInner model = - new ResourceRecommendationBaseInner() - .withCategory(Category.PERFORMANCE) - .withImpact(Impact.LOW) - .withImpactedField("njbiksqrglssain") - .withImpactedValue("jwnzlljfmp") - .withLastUpdated(OffsetDateTime.parse("2021-09-21T11:36:48Z")) - .withMetadata(mapOf("yqduujit", "datamgxsab", "rwpdappdsbdkvwrw", "datajczdzevndh")) - .withRecommendationTypeId("eusnhutj") - .withShortDescription(new ShortDescription().withProblem("mrldhu").withSolution("zzd")) - .withSuppressionIds( - Arrays - .asList( - UUID.fromString("7edaf309-156b-4fa8-84db-d97fe78c459e"), - UUID.fromString("5b410fd8-362a-4c4a-8624-92464dd7bd45"), - UUID.fromString("3852d285-8e67-49f3-8463-59bd01ee8d65"), - UUID.fromString("84cbe077-afa8-46e3-bf17-3e31cbf738af"))) - .withExtendedProperties(mapOf("geablgphuticndvk", "oc", "ftyxolniw", "ozwyiftyhxhuro")) - .withResourceMetadata( - new ResourceMetadata() - .withResourceId("ukjfkgiawxklr") - .withSource("lwckbasyypnddhs") - .withAction( - mapOf("qgoulznd", "dataacphejkoty", "wyqkgfgibm", "datai", "qsrxybzqqed", "datadgak")) - .withSingular("tbciqfouflmm") - .withPlural("zsm")) - .withDescription("mglougpbkw") - .withLabel("utduqktapspwgcu") - .withLearnMoreLink("tumkdosvqwhbm") - .withPotentialBenefits("bbjfddgmbmbexp") - .withActions( - Arrays - .asList( - mapOf("rolfpfp", "dataq"), - mapOf( - "yjgzjaoyfhrtxiln", - "datalgbquxig", - "vlejuvfqa", - "datarkujy", - "xgjvtbv", - "datarlyxwjkcprbnw", - "uouq", - "dataysszdnrujqguh"), - mapOf( - "itnwuizgazxufi", - "datarwzwbng", - "hr", - "datauckyf", - "zwdzuh", - "dataidf", - "wxmnteiwao", - "dataymwisdkft"))) - .withRemediation(mapOf("pymzidnsezcxtbzs", "datamijcmmxdcufufs")) - .withExposedMetadataProperties(mapOf("sne", "datac")); - model = BinaryData.fromObject(model).toObject(ResourceRecommendationBaseInner.class); - Assertions.assertEquals(Category.PERFORMANCE, model.category()); - Assertions.assertEquals(Impact.LOW, model.impact()); - Assertions.assertEquals("njbiksqrglssain", model.impactedField()); - Assertions.assertEquals("jwnzlljfmp", model.impactedValue()); - Assertions.assertEquals(OffsetDateTime.parse("2021-09-21T11:36:48Z"), model.lastUpdated()); - Assertions.assertEquals("eusnhutj", model.recommendationTypeId()); - Assertions.assertEquals("mrldhu", model.shortDescription().problem()); - Assertions.assertEquals("zzd", model.shortDescription().solution()); - Assertions.assertEquals(UUID.fromString("7edaf309-156b-4fa8-84db-d97fe78c459e"), model.suppressionIds().get(0)); - Assertions.assertEquals("oc", model.extendedProperties().get("geablgphuticndvk")); - Assertions.assertEquals("ukjfkgiawxklr", model.resourceMetadata().resourceId()); - Assertions.assertEquals("lwckbasyypnddhs", model.resourceMetadata().source()); - Assertions.assertEquals("tbciqfouflmm", model.resourceMetadata().singular()); - Assertions.assertEquals("zsm", model.resourceMetadata().plural()); - Assertions.assertEquals("mglougpbkw", model.description()); - Assertions.assertEquals("utduqktapspwgcu", model.label()); - Assertions.assertEquals("tumkdosvqwhbm", model.learnMoreLink()); - Assertions.assertEquals("bbjfddgmbmbexp", model.potentialBenefits()); - } - - @SuppressWarnings("unchecked") - private static Map mapOf(Object... inputs) { - Map map = new HashMap<>(); - for (int i = 0; i < inputs.length; i += 2) { - String key = (String) inputs[i]; - T value = (T) inputs[i + 1]; - map.put(key, value); - } - return map; - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ResourceRecommendationBaseListResultTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ResourceRecommendationBaseListResultTests.java deleted file mode 100644 index 66449fe33888..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ResourceRecommendationBaseListResultTests.java +++ /dev/null @@ -1,105 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -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.ResourceRecommendationBaseListResult; -import java.time.OffsetDateTime; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Assertions; - -public final class ResourceRecommendationBaseListResultTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - ResourceRecommendationBaseListResult model = - BinaryData - .fromString( - "{\"nextLink\":\"hmsbzjhcrzevdp\",\"value\":[{\"properties\":{\"category\":\"HighAvailability\",\"impact\":\"Low\",\"impactedField\":\"trg\",\"impactedValue\":\"bpf\",\"lastUpdated\":\"2021-02-22T07:39:39Z\",\"metadata\":{},\"recommendationTypeId\":\"zgvfcjrwz\",\"suppressionIds\":[],\"extendedProperties\":{},\"description\":\"elluwfziton\",\"label\":\"qfpjk\",\"learnMoreLink\":\"xofpdvhpfxxypi\",\"potentialBenefits\":\"nmayhuybb\",\"actions\":[],\"remediation\":{},\"exposedMetadataProperties\":{}},\"id\":\"epoo\",\"name\":\"inuvamiheogn\",\"type\":\"rxzxtheo\"},{\"properties\":{\"category\":\"Performance\",\"impact\":\"High\",\"impactedField\":\"v\",\"impactedValue\":\"iqihn\",\"lastUpdated\":\"2021-07-19T03:18:26Z\",\"metadata\":{},\"recommendationTypeId\":\"wjzrnfygxgisp\",\"suppressionIds\":[],\"extendedProperties\":{},\"description\":\"kufubljo\",\"label\":\"qeof\",\"learnMoreLink\":\"e\",\"potentialBenefits\":\"hqjbasvmsmj\",\"actions\":[],\"remediation\":{},\"exposedMetadataProperties\":{}},\"id\":\"gsntnbybkzgcwr\",\"name\":\"clxxwrljdo\",\"type\":\"skcqvkocrcjd\"}]}") - .toObject(ResourceRecommendationBaseListResult.class); - Assertions.assertEquals("hmsbzjhcrzevdp", model.nextLink()); - Assertions.assertEquals(Category.HIGH_AVAILABILITY, model.value().get(0).category()); - Assertions.assertEquals(Impact.LOW, model.value().get(0).impact()); - Assertions.assertEquals("trg", model.value().get(0).impactedField()); - Assertions.assertEquals("bpf", model.value().get(0).impactedValue()); - Assertions.assertEquals(OffsetDateTime.parse("2021-02-22T07:39:39Z"), model.value().get(0).lastUpdated()); - Assertions.assertEquals("zgvfcjrwz", model.value().get(0).recommendationTypeId()); - Assertions.assertEquals("elluwfziton", model.value().get(0).description()); - Assertions.assertEquals("qfpjk", model.value().get(0).label()); - Assertions.assertEquals("xofpdvhpfxxypi", model.value().get(0).learnMoreLink()); - Assertions.assertEquals("nmayhuybb", model.value().get(0).potentialBenefits()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - ResourceRecommendationBaseListResult model = - new ResourceRecommendationBaseListResult() - .withNextLink("hmsbzjhcrzevdp") - .withValue( - Arrays - .asList( - new ResourceRecommendationBaseInner() - .withCategory(Category.HIGH_AVAILABILITY) - .withImpact(Impact.LOW) - .withImpactedField("trg") - .withImpactedValue("bpf") - .withLastUpdated(OffsetDateTime.parse("2021-02-22T07:39:39Z")) - .withMetadata(mapOf()) - .withRecommendationTypeId("zgvfcjrwz") - .withSuppressionIds(Arrays.asList()) - .withExtendedProperties(mapOf()) - .withDescription("elluwfziton") - .withLabel("qfpjk") - .withLearnMoreLink("xofpdvhpfxxypi") - .withPotentialBenefits("nmayhuybb") - .withActions(Arrays.asList()) - .withRemediation(mapOf()) - .withExposedMetadataProperties(mapOf()), - new ResourceRecommendationBaseInner() - .withCategory(Category.PERFORMANCE) - .withImpact(Impact.HIGH) - .withImpactedField("v") - .withImpactedValue("iqihn") - .withLastUpdated(OffsetDateTime.parse("2021-07-19T03:18:26Z")) - .withMetadata(mapOf()) - .withRecommendationTypeId("wjzrnfygxgisp") - .withSuppressionIds(Arrays.asList()) - .withExtendedProperties(mapOf()) - .withDescription("kufubljo") - .withLabel("qeof") - .withLearnMoreLink("e") - .withPotentialBenefits("hqjbasvmsmj") - .withActions(Arrays.asList()) - .withRemediation(mapOf()) - .withExposedMetadataProperties(mapOf()))); - model = BinaryData.fromObject(model).toObject(ResourceRecommendationBaseListResult.class); - Assertions.assertEquals("hmsbzjhcrzevdp", model.nextLink()); - Assertions.assertEquals(Category.HIGH_AVAILABILITY, model.value().get(0).category()); - Assertions.assertEquals(Impact.LOW, model.value().get(0).impact()); - Assertions.assertEquals("trg", model.value().get(0).impactedField()); - Assertions.assertEquals("bpf", model.value().get(0).impactedValue()); - Assertions.assertEquals(OffsetDateTime.parse("2021-02-22T07:39:39Z"), model.value().get(0).lastUpdated()); - Assertions.assertEquals("zgvfcjrwz", model.value().get(0).recommendationTypeId()); - Assertions.assertEquals("elluwfziton", model.value().get(0).description()); - Assertions.assertEquals("qfpjk", model.value().get(0).label()); - Assertions.assertEquals("xofpdvhpfxxypi", model.value().get(0).learnMoreLink()); - Assertions.assertEquals("nmayhuybb", model.value().get(0).potentialBenefits()); - } - - @SuppressWarnings("unchecked") - private static Map mapOf(Object... inputs) { - Map map = new HashMap<>(); - for (int i = 0; i < inputs.length; i += 2) { - String key = (String) inputs[i]; - T value = (T) inputs[i + 1]; - map.put(key, value); - } - return map; - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ShortDescriptionTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ShortDescriptionTests.java deleted file mode 100644 index e6f7ba81d249..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/ShortDescriptionTests.java +++ /dev/null @@ -1,29 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.models.ShortDescription; -import org.junit.jupiter.api.Assertions; - -public final class ShortDescriptionTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - ShortDescription model = - BinaryData - .fromString("{\"problem\":\"hzgpphrcgyncocpe\",\"solution\":\"vmmcoofs\"}") - .toObject(ShortDescription.class); - Assertions.assertEquals("hzgpphrcgyncocpe", model.problem()); - Assertions.assertEquals("vmmcoofs", model.solution()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - ShortDescription model = new ShortDescription().withProblem("hzgpphrcgyncocpe").withSolution("vmmcoofs"); - model = BinaryData.fromObject(model).toObject(ShortDescription.class); - Assertions.assertEquals("hzgpphrcgyncocpe", model.problem()); - Assertions.assertEquals("vmmcoofs", model.solution()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionContractInnerTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionContractInnerTests.java deleted file mode 100644 index b9eb67a3ba2c..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionContractInnerTests.java +++ /dev/null @@ -1,31 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; -import org.junit.jupiter.api.Assertions; - -public final class SuppressionContractInnerTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - SuppressionContractInner model = - BinaryData - .fromString( - "{\"properties\":{\"suppressionId\":\"pk\",\"ttl\":\"odpuozmyzydag\",\"expirationTimeStamp\":\"2021-10-21T07:36:04Z\"},\"id\":\"xbezyiuokktwh\",\"name\":\"dxwzywqsmbsurexi\",\"type\":\"o\"}") - .toObject(SuppressionContractInner.class); - Assertions.assertEquals("pk", model.suppressionId()); - Assertions.assertEquals("odpuozmyzydag", model.ttl()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - SuppressionContractInner model = - new SuppressionContractInner().withSuppressionId("pk").withTtl("odpuozmyzydag"); - model = BinaryData.fromObject(model).toObject(SuppressionContractInner.class); - Assertions.assertEquals("pk", model.suppressionId()); - Assertions.assertEquals("odpuozmyzydag", model.ttl()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionContractListResultTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionContractListResultTests.java deleted file mode 100644 index ef6b0e3e2a9d..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionContractListResultTests.java +++ /dev/null @@ -1,39 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner; -import com.azure.resourcemanager.advisor.models.SuppressionContractListResult; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; - -public final class SuppressionContractListResultTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - SuppressionContractListResult model = - BinaryData - .fromString( - "{\"nextLink\":\"ys\",\"value\":[{\"properties\":{\"suppressionId\":\"xhqyudxorrqnb\",\"ttl\":\"czvyifq\",\"expirationTimeStamp\":\"2020-12-25T17:33:53Z\"},\"id\":\"dvjsllrmvvdf\",\"name\":\"atkpnp\",\"type\":\"lexxbczwtru\"}]}") - .toObject(SuppressionContractListResult.class); - Assertions.assertEquals("ys", model.nextLink()); - Assertions.assertEquals("xhqyudxorrqnb", model.value().get(0).suppressionId()); - Assertions.assertEquals("czvyifq", model.value().get(0).ttl()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - SuppressionContractListResult model = - new SuppressionContractListResult() - .withNextLink("ys") - .withValue( - Arrays - .asList(new SuppressionContractInner().withSuppressionId("xhqyudxorrqnb").withTtl("czvyifq"))); - model = BinaryData.fromObject(model).toObject(SuppressionContractListResult.class); - Assertions.assertEquals("ys", model.nextLink()); - Assertions.assertEquals("xhqyudxorrqnb", model.value().get(0).suppressionId()); - Assertions.assertEquals("czvyifq", model.value().get(0).ttl()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionPropertiesTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionPropertiesTests.java deleted file mode 100644 index ac3bb758c87d..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionPropertiesTests.java +++ /dev/null @@ -1,30 +0,0 @@ -// 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.generated; - -import com.azure.core.util.BinaryData; -import com.azure.resourcemanager.advisor.fluent.models.SuppressionProperties; -import org.junit.jupiter.api.Assertions; - -public final class SuppressionPropertiesTests { - @org.junit.jupiter.api.Test - public void testDeserialize() throws Exception { - SuppressionProperties model = - BinaryData - .fromString( - "{\"suppressionId\":\"ocfs\",\"ttl\":\"s\",\"expirationTimeStamp\":\"2021-06-13T04:15:30Z\"}") - .toObject(SuppressionProperties.class); - Assertions.assertEquals("ocfs", model.suppressionId()); - Assertions.assertEquals("s", model.ttl()); - } - - @org.junit.jupiter.api.Test - public void testSerialize() throws Exception { - SuppressionProperties model = new SuppressionProperties().withSuppressionId("ocfs").withTtl("s"); - model = BinaryData.fromObject(model).toObject(SuppressionProperties.class); - Assertions.assertEquals("ocfs", model.suppressionId()); - Assertions.assertEquals("s", model.ttl()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsCreateWithResponseMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsCreateWithResponseMockTests.java deleted file mode 100644 index 26c49ea1932a..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsCreateWithResponseMockTests.java +++ /dev/null @@ -1,74 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.SuppressionContract; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class SuppressionsCreateWithResponseMockTests { - @Test - public void testCreateWithResponse() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"properties\":{\"suppressionId\":\"savjcbpwxqps\",\"ttl\":\"nftguvriuhpr\",\"expirationTimeStamp\":\"2021-02-04T08:02:16Z\"},\"id\":\"yvxqtayriwwroy\",\"name\":\"bexrmcq\",\"type\":\"bycnojvkn\"}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - SuppressionContract response = - manager - .suppressions() - .define("wxzvlvqhjkb") - .withExistingRecommendation("fgb", "c") - .withSuppressionId("btn") - .withTtl("iebwwaloayqcgwrt") - .create(); - - Assertions.assertEquals("savjcbpwxqps", response.suppressionId()); - Assertions.assertEquals("nftguvriuhpr", response.ttl()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsDeleteWithResponseMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsDeleteWithResponseMockTests.java deleted file mode 100644 index 36ff7106a9b9..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsDeleteWithResponseMockTests.java +++ /dev/null @@ -1,63 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class SuppressionsDeleteWithResponseMockTests { - @Test - public void testDeleteWithResponse() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = "{}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(204); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - manager - .suppressions() - .deleteWithResponse("qwgxhniskx", "bkpyc", "klwndnhjdauwhv", com.azure.core.util.Context.NONE); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsGetWithResponseMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsGetWithResponseMockTests.java deleted file mode 100644 index 4e6a1ca8d218..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsGetWithResponseMockTests.java +++ /dev/null @@ -1,71 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.SuppressionContract; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class SuppressionsGetWithResponseMockTests { - @Test - public void testGetWithResponse() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"properties\":{\"suppressionId\":\"vbvmeu\",\"ttl\":\"ivyhzceuojgjrwju\",\"expirationTimeStamp\":\"2020-12-24T14:08:30Z\"},\"id\":\"twm\",\"name\":\"dytdxwitx\",\"type\":\"rjaw\"}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - SuppressionContract response = - manager - .suppressions() - .getWithResponse("i", "jooxdjebw", "ucww", com.azure.core.util.Context.NONE) - .getValue(); - - Assertions.assertEquals("vbvmeu", response.suppressionId()); - Assertions.assertEquals("ivyhzceuojgjrwju", response.ttl()); - } -} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsListMockTests.java b/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsListMockTests.java deleted file mode 100644 index 0777d051afc1..000000000000 --- a/sdk/advisor/azure-resourcemanager-advisor/src/test/java/com/azure/resourcemanager/advisor/generated/SuppressionsListMockTests.java +++ /dev/null @@ -1,69 +0,0 @@ -// 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.generated; - -import com.azure.core.credential.AccessToken; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.management.AzureEnvironment; -import com.azure.core.management.profile.AzureProfile; -import com.azure.resourcemanager.advisor.AdvisorManager; -import com.azure.resourcemanager.advisor.models.SuppressionContract; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public final class SuppressionsListMockTests { - @Test - public void testList() throws Exception { - HttpClient httpClient = Mockito.mock(HttpClient.class); - HttpResponse httpResponse = Mockito.mock(HttpResponse.class); - ArgumentCaptor httpRequest = ArgumentCaptor.forClass(HttpRequest.class); - - String responseStr = - "{\"value\":[{\"properties\":{\"suppressionId\":\"bm\",\"ttl\":\"wuwprzqlv\",\"expirationTimeStamp\":\"2021-02-01T23:11:32Z\"},\"id\":\"lupj\",\"name\":\"khfxobbcswsrt\",\"type\":\"riplrbpbewtg\"}]}"; - - Mockito.when(httpResponse.getStatusCode()).thenReturn(200); - Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders()); - Mockito - .when(httpResponse.getBody()) - .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8)))); - Mockito - .when(httpResponse.getBodyAsByteArray()) - .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8))); - Mockito - .when(httpClient.send(httpRequest.capture(), Mockito.any())) - .thenReturn( - Mono - .defer( - () -> { - Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue()); - return Mono.just(httpResponse); - })); - - AdvisorManager manager = - AdvisorManager - .configure() - .withHttpClient(httpClient) - .authenticate( - tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), - new AzureProfile("", "", AzureEnvironment.AZURE)); - - PagedIterable response = - manager.suppressions().list(26018404, "wzbtdhxu", com.azure.core.util.Context.NONE); - - Assertions.assertEquals("bm", response.iterator().next().suppressionId()); - Assertions.assertEquals("wuwprzqlv", response.iterator().next().ttl()); - } -}