diff --git a/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md b/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md index 16ab1f416970..daf1059fa0ec 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md +++ b/sdk/advisor/azure-resourcemanager-advisor/CHANGELOG.md @@ -1,7 +1,8 @@ # Release History -## 1.0.0-beta.2 (Unreleased) +## 1.0.0-beta.1 (2021-12-28) +- 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). ## 1.0.0-beta.1 (2021-04-12) diff --git a/sdk/advisor/azure-resourcemanager-advisor/README.md b/sdk/advisor/azure-resourcemanager-advisor/README.md index 002b37ebfdb7..dee46db52937 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/README.md +++ b/sdk/advisor/azure-resourcemanager-advisor/README.md @@ -32,7 +32,7 @@ Various documentation is available to help you get started com.azure.resourcemanager azure-resourcemanager-advisor - 1.0.0-beta.1 + 1.0.0-beta.2 ``` [//]: # ({x-version-update-end}) @@ -74,6 +74,9 @@ See [API design][design] for general introduction on design and key concepts on ## Examples +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/advisor/azure-resourcemanager-advisor/SAMPLE.md) + + ## Troubleshooting ## Next steps diff --git a/sdk/advisor/azure-resourcemanager-advisor/SAMPLE.md b/sdk/advisor/azure-resourcemanager-advisor/SAMPLE.md new file mode 100644 index 000000000000..659610b703a9 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/SAMPLE.md @@ -0,0 +1,387 @@ +# Code snippets and samples + + +## Configurations + +- [CreateInResourceGroup](#configurations_createinresourcegroup) +- [CreateInSubscription](#configurations_createinsubscription) +- [List](#configurations_list) +- [ListByResourceGroup](#configurations_listbyresourcegroup) + +## RecommendationMetadata + +- [Get](#recommendationmetadata_get) +- [List](#recommendationmetadata_list) + +## Recommendations + +- [Generate](#recommendations_generate) +- [Get](#recommendations_get) +- [GetGenerateStatus](#recommendations_getgeneratestatus) +- [List](#recommendations_list) + +## Suppressions + +- [Create](#suppressions_create) +- [Delete](#suppressions_delete) +- [Get](#suppressions_get) +- [List](#suppressions_list) +### Configurations_CreateInResourceGroup + +```java +import com.azure.resourcemanager.advisor.models.Category; +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 java.util.Arrays; + +/** 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 + */ + /** + * Sample code: PutConfigurations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void putConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + 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))) + .create(); + } +} +``` + +### Configurations_CreateInSubscription + +```java +import com.azure.core.util.Context; +import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; +import com.azure.resourcemanager.advisor.models.Category; +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 java.util.Arrays; + +/** 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 + */ + /** + * 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))), + Context.NONE); + } +} +``` + +### Configurations_List + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * Sample code: GetConfigurations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.configurations().list(Context.NONE); + } +} +``` + +### Configurations_ListByResourceGroup + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * Sample code: GetConfigurations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.configurations().listByResourceGroup("resourceGroup", Context.NONE); + } +} +``` + +### RecommendationMetadata_Get + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * Sample code: GetMetadata. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getMetadata(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendationMetadatas().getWithResponse("types", Context.NONE); + } +} +``` + +### RecommendationMetadata_List + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * Sample code: GetMetadata. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getMetadata(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendationMetadatas().list(Context.NONE); + } +} +``` + +### Recommendations_Generate + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * Sample code: GenerateRecommendations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void generateRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendations().generateWithResponse(Context.NONE); + } +} +``` + +### Recommendations_Get + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * Sample code: GetRecommendationDetail. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getRecommendationDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendations().getWithResponse("resourceUri", "recommendationId", Context.NONE); + } +} +``` + +### Recommendations_GetGenerateStatus + +```java +import com.azure.core.util.Context; +import java.util.UUID; + +/** 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 + */ + /** + * Sample code: GetGenerateStatus. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getGenerateStatus(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendations().getGenerateStatusWithResponse(UUID.fromString("operationGUID"), Context.NONE); + } +} +``` + +### Recommendations_List + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * Sample code: ListRecommendations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void listRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendations().list(null, 10, null, Context.NONE); + } +} +``` + +### Suppressions_Create + +```java +/** 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 + */ + /** + * Sample code: CreateSuppression. + * + * @param manager Entry point to AdvisorManager. + */ + public static void createSuppression(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager + .suppressions() + .define("suppressionName1") + .withExistingRecommendation("resourceUri", "recommendationId") + .withTtl("07:00:00:00") + .create(); + } +} +``` + +### Suppressions_Delete + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * 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", Context.NONE); + } +} +``` + +### Suppressions_Get + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * Sample code: GetSuppressionDetail. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getSuppressionDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.suppressions().getWithResponse("resourceUri", "recommendationId", "suppressionName1", Context.NONE); + } +} +``` + +### Suppressions_List + +```java +import com.azure.core.util.Context; + +/** 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 + */ + /** + * Sample code: ListSuppressions. + * + * @param manager Entry point to AdvisorManager. + */ + public static void listSuppressions(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.suppressions().list(null, null, Context.NONE); + } +} +``` + diff --git a/sdk/advisor/azure-resourcemanager-advisor/pom.xml b/sdk/advisor/azure-resourcemanager-advisor/pom.xml index c71e745c9c46..a85a1a5cf144 100644 --- a/sdk/advisor/azure-resourcemanager-advisor/pom.xml +++ b/sdk/advisor/azure-resourcemanager-advisor/pom.xml @@ -1,58 +1,81 @@ - 4.0.0 - - com.azure - azure-client-sdk-parent - 1.7.0 - ../../parents/azure-client-sdk-parent - + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + - com.azure.resourcemanager - azure-resourcemanager-advisor - 1.0.0-beta.2 - jar + com.azure.resourcemanager + azure-resourcemanager-advisor + 1.0.0-beta.2 + 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. - https://github.com/Azure/azure-sdk-for-java + 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. + https://github.com/Azure/azure-sdk-for-java - - - The MIT License (MIT) - http://opensource.org/licenses/MIT - repo - - + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + - - https://github.com/Azure/azure-sdk-for-java - scm:git:git@github.com:Azure/azure-sdk-for-java.git - scm:git:git@github.com:Azure/azure-sdk-for-java.git - HEAD - - - - microsoft - Microsoft - - - - UTF-8 - true + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + true false - - - - com.azure - azure-core - 1.23.1 - - - com.azure - azure-core-management - 1.4.4 - - + + + + com.azure + azure-core + 1.23.1 + + + com.azure + azure-core-management + 1.4.4 + + + + + + org.revapi + revapi-maven-plugin + 0.11.2 + + + + + java.method.addedToInterface + + + true + .* + com\.azure\.resourcemanager(\.[^.]+)+\.fluent(\.[^.]+)* + + + + + + + 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 794674c3ab09..7ba6384547c9 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 @@ -8,8 +8,8 @@ import com.azure.core.http.HttpClient; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; import com.azure.core.http.policy.AddDatePolicy; -import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpLoggingPolicy; import com.azure.core.http.policy.HttpPipelinePolicy; @@ -17,6 +17,7 @@ import com.azure.core.http.policy.RequestIdPolicy; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy; import com.azure.core.management.profile.AzureProfile; import com.azure.core.util.Configuration; import com.azure.core.util.logging.ClientLogger; @@ -37,6 +38,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** Entry point to AdvisorManager. REST APIs for Azure Advisor. */ public final class AdvisorManager { @@ -93,6 +95,7 @@ public static final class Configurable { private HttpClient httpClient; private HttpLogOptions httpLogOptions; private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); private RetryPolicy retryPolicy; private Duration defaultPollInterval; @@ -132,6 +135,17 @@ public Configurable withPolicy(HttpPipelinePolicy policy) { return this; } + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + /** * Sets the retry policy to the HTTP pipeline. * @@ -188,20 +202,33 @@ public AdvisorManager authenticate(TokenCredential credential, AzureProfile prof userAgentBuilder.append(" (auto-generated)"); } + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } if (retryPolicy == null) { retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); } List policies = new ArrayList<>(); policies.add(new UserAgentPolicy(userAgentBuilder.toString())); policies.add(new RequestIdPolicy()); + policies + .addAll( + this + .policies + .stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new AddDatePolicy()); + policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); policies - .add( - new BearerTokenAuthenticationPolicy( - credential, profile.getEnvironment().getManagementEndpoint() + "/.default")); - policies.addAll(this.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 = 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 7c84cd0db0ac..054f30d5e9a5 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 @@ -5,7 +5,6 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.JsonFlatten; import com.azure.core.management.ProxyResource; import com.azure.core.util.logging.ClientLogger; import com.azure.resourcemanager.advisor.models.CpuThreshold; @@ -15,30 +14,24 @@ import java.util.List; /** The Advisor configuration data structure. */ -@JsonFlatten @Fluent -public class ConfigDataInner extends ProxyResource { +public final class ConfigDataInner extends ProxyResource { @JsonIgnore private final ClientLogger logger = new ClientLogger(ConfigDataInner.class); /* - * Exclude the resource from Advisor evaluations. Valid values: False - * (default) or True. + * The Advisor configuration data structure. */ - @JsonProperty(value = "properties.exclude") - private Boolean exclude; + @JsonProperty(value = "properties") + private ConfigDataProperties innerProperties; - /* - * Minimum percentage threshold for Advisor low CPU utilization evaluation. - * Valid only for subscriptions. Valid values: 5 (default), 10, 15 or 20. - */ - @JsonProperty(value = "properties.lowCpuThreshold") - private CpuThreshold lowCpuThreshold; - - /* - * Advisor digest configuration. Valid only for subscriptions + /** + * Get the innerProperties property: The Advisor configuration data structure. + * + * @return the innerProperties value. */ - @JsonProperty(value = "properties.digests") - private List digests; + private ConfigDataProperties innerProperties() { + return this.innerProperties; + } /** * Get the exclude property: Exclude the resource from Advisor evaluations. Valid values: False (default) or True. @@ -46,7 +39,7 @@ public class ConfigDataInner extends ProxyResource { * @return the exclude value. */ public Boolean exclude() { - return this.exclude; + return this.innerProperties() == null ? null : this.innerProperties().exclude(); } /** @@ -56,7 +49,10 @@ public Boolean exclude() { * @return the ConfigDataInner object itself. */ public ConfigDataInner withExclude(Boolean exclude) { - this.exclude = exclude; + if (this.innerProperties() == null) { + this.innerProperties = new ConfigDataProperties(); + } + this.innerProperties().withExclude(exclude); return this; } @@ -67,7 +63,7 @@ public ConfigDataInner withExclude(Boolean exclude) { * @return the lowCpuThreshold value. */ public CpuThreshold lowCpuThreshold() { - return this.lowCpuThreshold; + return this.innerProperties() == null ? null : this.innerProperties().lowCpuThreshold(); } /** @@ -78,7 +74,10 @@ public CpuThreshold lowCpuThreshold() { * @return the ConfigDataInner object itself. */ public ConfigDataInner withLowCpuThreshold(CpuThreshold lowCpuThreshold) { - this.lowCpuThreshold = lowCpuThreshold; + if (this.innerProperties() == null) { + this.innerProperties = new ConfigDataProperties(); + } + this.innerProperties().withLowCpuThreshold(lowCpuThreshold); return this; } @@ -88,7 +87,7 @@ public ConfigDataInner withLowCpuThreshold(CpuThreshold lowCpuThreshold) { * @return the digests value. */ public List digests() { - return this.digests; + return this.innerProperties() == null ? null : this.innerProperties().digests(); } /** @@ -98,7 +97,10 @@ public List digests() { * @return the ConfigDataInner object itself. */ public ConfigDataInner withDigests(List digests) { - this.digests = digests; + if (this.innerProperties() == null) { + this.innerProperties = new ConfigDataProperties(); + } + this.innerProperties().withDigests(digests); return this; } @@ -108,8 +110,8 @@ public ConfigDataInner withDigests(List digests) { * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { - if (digests() != null) { - digests().forEach(e -> e.validate()); + if (innerProperties() != null) { + innerProperties().validate(); } } } 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 new file mode 100644 index 000000000000..357f9f309649 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ConfigDataProperties.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.models.CpuThreshold; +import com.azure.resourcemanager.advisor.models.DigestConfig; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Configuration data properties. */ +@Fluent +public final class ConfigDataProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ConfigDataProperties.class); + + /* + * 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; + + /* + * Advisor digest configuration. Valid only for subscriptions + */ + @JsonProperty(value = "digests") + private List digests; + + /** + * Get the exclude property: Exclude the resource from Advisor evaluations. Valid values: False (default) or True. + * + * @return the exclude value. + */ + public Boolean exclude() { + return this.exclude; + } + + /** + * Set the exclude property: Exclude the resource from Advisor evaluations. Valid values: False (default) or True. + * + * @param exclude the exclude value to set. + * @return the ConfigDataProperties object itself. + */ + public ConfigDataProperties withExclude(Boolean exclude) { + this.exclude = exclude; + return this; + } + + /** + * Get the lowCpuThreshold property: Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid + * only for subscriptions. Valid values: 5 (default), 10, 15 or 20. + * + * @return the lowCpuThreshold value. + */ + public CpuThreshold lowCpuThreshold() { + return this.lowCpuThreshold; + } + + /** + * Set the lowCpuThreshold property: Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid + * only for subscriptions. Valid values: 5 (default), 10, 15 or 20. + * + * @param lowCpuThreshold the lowCpuThreshold value to set. + * @return the ConfigDataProperties object itself. + */ + public ConfigDataProperties withLowCpuThreshold(CpuThreshold lowCpuThreshold) { + this.lowCpuThreshold = lowCpuThreshold; + return this; + } + + /** + * Get the digests property: Advisor digest configuration. Valid only for subscriptions. + * + * @return the digests value. + */ + public List digests() { + return this.digests; + } + + /** + * Set the digests property: Advisor digest configuration. Valid only for subscriptions. + * + * @param digests the digests value to set. + * @return the ConfigDataProperties object itself. + */ + public ConfigDataProperties withDigests(List digests) { + this.digests = digests; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (digests() != null) { + digests().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityInner.java index d3152dea8d5c..b0edf35c27b3 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,7 +5,6 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.JsonFlatten; import com.azure.core.util.logging.ClientLogger; import com.azure.resourcemanager.advisor.models.MetadataSupportedValueDetail; import com.azure.resourcemanager.advisor.models.Scenario; @@ -14,9 +13,8 @@ import java.util.List; /** The metadata entity contract. */ -@JsonFlatten @Fluent -public class MetadataEntityInner { +public final class MetadataEntityInner { @JsonIgnore private final ClientLogger logger = new ClientLogger(MetadataEntityInner.class); /* @@ -38,28 +36,10 @@ public class MetadataEntityInner { private String name; /* - * The display name. + * The metadata entity properties. */ - @JsonProperty(value = "properties.displayName") - private String displayName; - - /* - * The list of keys on which this entity depends on. - */ - @JsonProperty(value = "properties.dependsOn") - private List dependsOn; - - /* - * The list of scenarios applicable to this metadata entity. - */ - @JsonProperty(value = "properties.applicableScenarios") - private List applicableScenarios; - - /* - * The list of supported values. - */ - @JsonProperty(value = "properties.supportedValues") - private List supportedValues; + @JsonProperty(value = "properties") + private MetadataEntityProperties innerProperties; /** * Get the id property: The resource Id of the metadata entity. @@ -121,13 +101,22 @@ public MetadataEntityInner withName(String name) { return this; } + /** + * Get the innerProperties property: The metadata entity properties. + * + * @return the innerProperties value. + */ + private MetadataEntityProperties innerProperties() { + return this.innerProperties; + } + /** * Get the displayName property: The display name. * * @return the displayName value. */ public String displayName() { - return this.displayName; + return this.innerProperties() == null ? null : this.innerProperties().displayName(); } /** @@ -137,7 +126,10 @@ public String displayName() { * @return the MetadataEntityInner object itself. */ public MetadataEntityInner withDisplayName(String displayName) { - this.displayName = displayName; + if (this.innerProperties() == null) { + this.innerProperties = new MetadataEntityProperties(); + } + this.innerProperties().withDisplayName(displayName); return this; } @@ -147,7 +139,7 @@ public MetadataEntityInner withDisplayName(String displayName) { * @return the dependsOn value. */ public List dependsOn() { - return this.dependsOn; + return this.innerProperties() == null ? null : this.innerProperties().dependsOn(); } /** @@ -157,7 +149,10 @@ public List dependsOn() { * @return the MetadataEntityInner object itself. */ public MetadataEntityInner withDependsOn(List dependsOn) { - this.dependsOn = dependsOn; + if (this.innerProperties() == null) { + this.innerProperties = new MetadataEntityProperties(); + } + this.innerProperties().withDependsOn(dependsOn); return this; } @@ -167,7 +162,7 @@ public MetadataEntityInner withDependsOn(List dependsOn) { * @return the applicableScenarios value. */ public List applicableScenarios() { - return this.applicableScenarios; + return this.innerProperties() == null ? null : this.innerProperties().applicableScenarios(); } /** @@ -177,7 +172,10 @@ public List applicableScenarios() { * @return the MetadataEntityInner object itself. */ public MetadataEntityInner withApplicableScenarios(List applicableScenarios) { - this.applicableScenarios = applicableScenarios; + if (this.innerProperties() == null) { + this.innerProperties = new MetadataEntityProperties(); + } + this.innerProperties().withApplicableScenarios(applicableScenarios); return this; } @@ -187,7 +185,7 @@ public MetadataEntityInner withApplicableScenarios(List applicableScen * @return the supportedValues value. */ public List supportedValues() { - return this.supportedValues; + return this.innerProperties() == null ? null : this.innerProperties().supportedValues(); } /** @@ -197,7 +195,10 @@ public List supportedValues() { * @return the MetadataEntityInner object itself. */ public MetadataEntityInner withSupportedValues(List supportedValues) { - this.supportedValues = supportedValues; + if (this.innerProperties() == null) { + this.innerProperties = new MetadataEntityProperties(); + } + this.innerProperties().withSupportedValues(supportedValues); return this; } @@ -207,8 +208,8 @@ public MetadataEntityInner withSupportedValues(List e.validate()); + if (innerProperties() != null) { + innerProperties().validate(); } } } 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 new file mode 100644 index 000000000000..fd63d0202697 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/MetadataEntityProperties.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.models.MetadataSupportedValueDetail; +import com.azure.resourcemanager.advisor.models.Scenario; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The metadata entity properties. */ +@Fluent +public final class MetadataEntityProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(MetadataEntityProperties.class); + + /* + * 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; + + /** + * Get the displayName property: The display name. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: The display name. + * + * @param displayName the displayName value to set. + * @return the MetadataEntityProperties object itself. + */ + public MetadataEntityProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the dependsOn property: The list of keys on which this entity depends on. + * + * @return the dependsOn value. + */ + public List dependsOn() { + return this.dependsOn; + } + + /** + * Set the dependsOn property: The list of keys on which this entity depends on. + * + * @param dependsOn the dependsOn value to set. + * @return the MetadataEntityProperties object itself. + */ + public MetadataEntityProperties withDependsOn(List dependsOn) { + this.dependsOn = dependsOn; + return this; + } + + /** + * Get the applicableScenarios property: The list of scenarios applicable to this metadata entity. + * + * @return the applicableScenarios value. + */ + public List applicableScenarios() { + return this.applicableScenarios; + } + + /** + * Set the applicableScenarios property: The list of scenarios applicable to this metadata entity. + * + * @param applicableScenarios the applicableScenarios value to set. + * @return the MetadataEntityProperties object itself. + */ + public MetadataEntityProperties withApplicableScenarios(List applicableScenarios) { + this.applicableScenarios = applicableScenarios; + return this; + } + + /** + * Get the supportedValues property: The list of supported values. + * + * @return the supportedValues value. + */ + public List supportedValues() { + return this.supportedValues; + } + + /** + * Set the supportedValues property: The list of supported values. + * + * @param supportedValues the supportedValues value to set. + * @return the MetadataEntityProperties object itself. + */ + public MetadataEntityProperties withSupportedValues(List supportedValues) { + this.supportedValues = supportedValues; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (supportedValues() != null) { + supportedValues().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/RecommendationProperties.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/RecommendationProperties.java new file mode 100644 index 000000000000..56dab7a0aed4 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/RecommendationProperties.java @@ -0,0 +1,542 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.advisor.models.Category; +import com.azure.resourcemanager.advisor.models.Impact; +import com.azure.resourcemanager.advisor.models.ResourceMetadata; +import com.azure.resourcemanager.advisor.models.Risk; +import com.azure.resourcemanager.advisor.models.ShortDescription; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** The properties of the recommendation. */ +@Fluent +public final class RecommendationProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(RecommendationProperties.class); + + /* + * 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. + */ + @JsonProperty(value = "risk") + 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; + + /** + * 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 RecommendationProperties object itself. + */ + public RecommendationProperties 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 RecommendationProperties object itself. + */ + public RecommendationProperties 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 RecommendationProperties object itself. + */ + public RecommendationProperties withImpactedField(String impactedField) { + this.impactedField = impactedField; + return this; + } + + /** + * Get the impactedValue property: The resource identified by Advisor. + * + * @return the impactedValue value. + */ + public String impactedValue() { + return this.impactedValue; + } + + /** + * Set the impactedValue property: The resource identified by Advisor. + * + * @param impactedValue the impactedValue value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withImpactedValue(String impactedValue) { + this.impactedValue = impactedValue; + return this; + } + + /** + * Get the lastUpdated property: The most recent time that Advisor checked the validity of the recommendation. + * + * @return the lastUpdated value. + */ + public OffsetDateTime lastUpdated() { + return this.lastUpdated; + } + + /** + * Set the lastUpdated property: The most recent time that Advisor checked the validity of the recommendation. + * + * @param lastUpdated the lastUpdated value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withLastUpdated(OffsetDateTime lastUpdated) { + this.lastUpdated = lastUpdated; + return this; + } + + /** + * Get the metadata property: The recommendation metadata. + * + * @return the metadata value. + */ + public Map metadata() { + return this.metadata; + } + + /** + * Set the metadata property: The recommendation metadata. + * + * @param metadata the metadata value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Get the recommendationTypeId property: The recommendation-type GUID. + * + * @return the recommendationTypeId value. + */ + public String recommendationTypeId() { + return this.recommendationTypeId; + } + + /** + * Set the recommendationTypeId property: The recommendation-type GUID. + * + * @param recommendationTypeId the recommendationTypeId value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withRecommendationTypeId(String recommendationTypeId) { + this.recommendationTypeId = recommendationTypeId; + return this; + } + + /** + * Get the risk property: The potential risk of not implementing the recommendation. + * + * @return the risk value. + */ + public Risk risk() { + return this.risk; + } + + /** + * Set the risk property: The potential risk of not implementing the recommendation. + * + * @param risk the risk value to set. + * @return the 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() { + return this.shortDescription; + } + + /** + * Set the shortDescription property: A summary of the recommendation. + * + * @param shortDescription the shortDescription value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withShortDescription(ShortDescription shortDescription) { + this.shortDescription = shortDescription; + return this; + } + + /** + * Get the suppressionIds property: The list of snoozed and dismissed rules for the recommendation. + * + * @return the suppressionIds value. + */ + public List suppressionIds() { + return this.suppressionIds; + } + + /** + * Set the suppressionIds property: The list of snoozed and dismissed rules for the recommendation. + * + * @param suppressionIds the suppressionIds value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withSuppressionIds(List suppressionIds) { + this.suppressionIds = suppressionIds; + return this; + } + + /** + * Get the extendedProperties property: Extended properties. + * + * @return the extendedProperties value. + */ + public Map extendedProperties() { + return this.extendedProperties; + } + + /** + * Set the extendedProperties property: Extended properties. + * + * @param extendedProperties the extendedProperties value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withExtendedProperties(Map extendedProperties) { + this.extendedProperties = extendedProperties; + return this; + } + + /** + * Get the resourceMetadata property: Metadata of resource that was assessed. + * + * @return the resourceMetadata value. + */ + public ResourceMetadata resourceMetadata() { + return this.resourceMetadata; + } + + /** + * Set the resourceMetadata property: Metadata of resource that was assessed. + * + * @param resourceMetadata the resourceMetadata value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withResourceMetadata(ResourceMetadata resourceMetadata) { + this.resourceMetadata = resourceMetadata; + return this; + } + + /** + * Get the description property: The detailed description of recommendation. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: The detailed description of recommendation. + * + * @param description the description value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the label property: The label of recommendation. + * + * @return the label value. + */ + public String label() { + return this.label; + } + + /** + * Set the label property: The label of recommendation. + * + * @param label the label value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withLabel(String label) { + this.label = label; + return this; + } + + /** + * Get the learnMoreLink property: The link to learn more about recommendation and generation logic. + * + * @return the learnMoreLink value. + */ + public String learnMoreLink() { + return this.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. + */ + public RecommendationProperties withLearnMoreLink(String learnMoreLink) { + this.learnMoreLink = learnMoreLink; + return this; + } + + /** + * Get the potentialBenefits property: The potential benefit of implementing recommendation. + * + * @return the potentialBenefits value. + */ + public String potentialBenefits() { + return this.potentialBenefits; + } + + /** + * Set the potentialBenefits property: The potential benefit of implementing recommendation. + * + * @param potentialBenefits the potentialBenefits value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withPotentialBenefits(String potentialBenefits) { + this.potentialBenefits = potentialBenefits; + return this; + } + + /** + * Get the actions property: The list of recommended actions to implement recommendation. + * + * @return the actions value. + */ + public List> actions() { + return this.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. + */ + public RecommendationProperties withActions(List> actions) { + this.actions = actions; + return this; + } + + /** + * Get the remediation property: The automated way to apply recommendation. + * + * @return the remediation value. + */ + public Map remediation() { + return this.remediation; + } + + /** + * Set the remediation property: The automated way to apply recommendation. + * + * @param remediation the remediation value to set. + * @return the RecommendationProperties object itself. + */ + public RecommendationProperties withRemediation(Map remediation) { + this.remediation = remediation; + return this; + } + + /** + * Get the exposedMetadataProperties property: The recommendation metadata properties exposed to customer to provide + * additional information. + * + * @return the exposedMetadataProperties value. + */ + public Map exposedMetadataProperties() { + return this.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. + */ + public RecommendationProperties withExposedMetadataProperties(Map exposedMetadataProperties) { + this.exposedMetadataProperties = exposedMetadataProperties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (shortDescription() != null) { + shortDescription().validate(); + } + if (resourceMetadata() != null) { + resourceMetadata().validate(); + } + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ResourceRecommendationBaseInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/ResourceRecommendationBaseInner.java index 086a36659354..f2e33c0f2b0e 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 @@ -5,7 +5,6 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.JsonFlatten; import com.azure.core.management.ProxyResource; import com.azure.core.util.logging.ClientLogger; import com.azure.resourcemanager.advisor.models.Category; @@ -21,126 +20,24 @@ import java.util.UUID; /** Advisor Recommendation. */ -@JsonFlatten @Fluent -public class ResourceRecommendationBaseInner extends ProxyResource { +public final class ResourceRecommendationBaseInner extends ProxyResource { @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceRecommendationBaseInner.class); /* - * The category of the recommendation. + * The properties of the recommendation. */ - @JsonProperty(value = "properties.category") - private Category category; + @JsonProperty(value = "properties") + private RecommendationProperties innerProperties; - /* - * The business impact of the recommendation. - */ - @JsonProperty(value = "properties.impact") - private Impact impact; - - /* - * The resource type identified by Advisor. - */ - @JsonProperty(value = "properties.impactedField") - private String impactedField; - - /* - * The resource identified by Advisor. - */ - @JsonProperty(value = "properties.impactedValue") - private String impactedValue; - - /* - * The most recent time that Advisor checked the validity of the - * recommendation. - */ - @JsonProperty(value = "properties.lastUpdated") - private OffsetDateTime lastUpdated; - - /* - * The recommendation metadata. - */ - @JsonProperty(value = "properties.metadata") - private Map metadata; - - /* - * The recommendation-type GUID. - */ - @JsonProperty(value = "properties.recommendationTypeId") - private String recommendationTypeId; - - /* - * The potential risk of not implementing the recommendation. - */ - @JsonProperty(value = "properties.risk") - private Risk risk; - - /* - * A summary of the recommendation. - */ - @JsonProperty(value = "properties.shortDescription") - private ShortDescription shortDescription; - - /* - * The list of snoozed and dismissed rules for the recommendation. - */ - @JsonProperty(value = "properties.suppressionIds") - private List suppressionIds; - - /* - * Extended properties - */ - @JsonProperty(value = "properties.extendedProperties") - private Map extendedProperties; - - /* - * Metadata of resource that was assessed - */ - @JsonProperty(value = "properties.resourceMetadata") - private ResourceMetadata resourceMetadata; - - /* - * The detailed description of recommendation. - */ - @JsonProperty(value = "properties.description") - private String description; - - /* - * The label of recommendation. - */ - @JsonProperty(value = "properties.label") - private String label; - - /* - * The link to learn more about recommendation and generation logic. - */ - @JsonProperty(value = "properties.learnMoreLink") - private String learnMoreLink; - - /* - * The potential benefit of implementing recommendation. - */ - @JsonProperty(value = "properties.potentialBenefits") - private String potentialBenefits; - - /* - * The list of recommended actions to implement recommendation. - */ - @JsonProperty(value = "properties.actions") - private List> actions; - - /* - * The automated way to apply recommendation. - */ - @JsonProperty(value = "properties.remediation") - private Map remediation; - - /* - * The recommendation metadata properties exposed to customer to provide - * additional information. + /** + * Get the innerProperties property: The properties of the recommendation. + * + * @return the innerProperties value. */ - @JsonProperty(value = "properties.exposedMetadataProperties") - private Map exposedMetadataProperties; + private RecommendationProperties innerProperties() { + return this.innerProperties; + } /** * Get the category property: The category of the recommendation. @@ -148,7 +45,7 @@ public class ResourceRecommendationBaseInner extends ProxyResource { * @return the category value. */ public Category category() { - return this.category; + return this.innerProperties() == null ? null : this.innerProperties().category(); } /** @@ -158,7 +55,10 @@ public Category category() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withCategory(Category category) { - this.category = category; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withCategory(category); return this; } @@ -168,7 +68,7 @@ public ResourceRecommendationBaseInner withCategory(Category category) { * @return the impact value. */ public Impact impact() { - return this.impact; + return this.innerProperties() == null ? null : this.innerProperties().impact(); } /** @@ -178,7 +78,10 @@ public Impact impact() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withImpact(Impact impact) { - this.impact = impact; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withImpact(impact); return this; } @@ -188,7 +91,7 @@ public ResourceRecommendationBaseInner withImpact(Impact impact) { * @return the impactedField value. */ public String impactedField() { - return this.impactedField; + return this.innerProperties() == null ? null : this.innerProperties().impactedField(); } /** @@ -198,7 +101,10 @@ public String impactedField() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withImpactedField(String impactedField) { - this.impactedField = impactedField; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withImpactedField(impactedField); return this; } @@ -208,7 +114,7 @@ public ResourceRecommendationBaseInner withImpactedField(String impactedField) { * @return the impactedValue value. */ public String impactedValue() { - return this.impactedValue; + return this.innerProperties() == null ? null : this.innerProperties().impactedValue(); } /** @@ -218,7 +124,10 @@ public String impactedValue() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withImpactedValue(String impactedValue) { - this.impactedValue = impactedValue; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withImpactedValue(impactedValue); return this; } @@ -228,7 +137,7 @@ public ResourceRecommendationBaseInner withImpactedValue(String impactedValue) { * @return the lastUpdated value. */ public OffsetDateTime lastUpdated() { - return this.lastUpdated; + return this.innerProperties() == null ? null : this.innerProperties().lastUpdated(); } /** @@ -238,7 +147,10 @@ public OffsetDateTime lastUpdated() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withLastUpdated(OffsetDateTime lastUpdated) { - this.lastUpdated = lastUpdated; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withLastUpdated(lastUpdated); return this; } @@ -248,7 +160,7 @@ public ResourceRecommendationBaseInner withLastUpdated(OffsetDateTime lastUpdate * @return the metadata value. */ public Map metadata() { - return this.metadata; + return this.innerProperties() == null ? null : this.innerProperties().metadata(); } /** @@ -258,7 +170,10 @@ public Map metadata() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withMetadata(Map metadata) { - this.metadata = metadata; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withMetadata(metadata); return this; } @@ -268,7 +183,7 @@ public ResourceRecommendationBaseInner withMetadata(Map metadata * @return the recommendationTypeId value. */ public String recommendationTypeId() { - return this.recommendationTypeId; + return this.innerProperties() == null ? null : this.innerProperties().recommendationTypeId(); } /** @@ -278,7 +193,10 @@ public String recommendationTypeId() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withRecommendationTypeId(String recommendationTypeId) { - this.recommendationTypeId = recommendationTypeId; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withRecommendationTypeId(recommendationTypeId); return this; } @@ -288,7 +206,7 @@ public ResourceRecommendationBaseInner withRecommendationTypeId(String recommend * @return the risk value. */ public Risk risk() { - return this.risk; + return this.innerProperties() == null ? null : this.innerProperties().risk(); } /** @@ -298,7 +216,10 @@ public Risk risk() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withRisk(Risk risk) { - this.risk = risk; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withRisk(risk); return this; } @@ -308,7 +229,7 @@ public ResourceRecommendationBaseInner withRisk(Risk risk) { * @return the shortDescription value. */ public ShortDescription shortDescription() { - return this.shortDescription; + return this.innerProperties() == null ? null : this.innerProperties().shortDescription(); } /** @@ -318,7 +239,10 @@ public ShortDescription shortDescription() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withShortDescription(ShortDescription shortDescription) { - this.shortDescription = shortDescription; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withShortDescription(shortDescription); return this; } @@ -328,7 +252,7 @@ public ResourceRecommendationBaseInner withShortDescription(ShortDescription sho * @return the suppressionIds value. */ public List suppressionIds() { - return this.suppressionIds; + return this.innerProperties() == null ? null : this.innerProperties().suppressionIds(); } /** @@ -338,7 +262,10 @@ public List suppressionIds() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withSuppressionIds(List suppressionIds) { - this.suppressionIds = suppressionIds; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withSuppressionIds(suppressionIds); return this; } @@ -348,7 +275,7 @@ public ResourceRecommendationBaseInner withSuppressionIds(List suppression * @return the extendedProperties value. */ public Map extendedProperties() { - return this.extendedProperties; + return this.innerProperties() == null ? null : this.innerProperties().extendedProperties(); } /** @@ -358,7 +285,10 @@ public Map extendedProperties() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withExtendedProperties(Map extendedProperties) { - this.extendedProperties = extendedProperties; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withExtendedProperties(extendedProperties); return this; } @@ -368,7 +298,7 @@ public ResourceRecommendationBaseInner withExtendedProperties(Map> actions() { - return this.actions; + return this.innerProperties() == null ? null : this.innerProperties().actions(); } /** @@ -478,7 +423,10 @@ public List> actions() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withActions(List> actions) { - this.actions = actions; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withActions(actions); return this; } @@ -488,7 +436,7 @@ public ResourceRecommendationBaseInner withActions(List> act * @return the remediation value. */ public Map remediation() { - return this.remediation; + return this.innerProperties() == null ? null : this.innerProperties().remediation(); } /** @@ -498,7 +446,10 @@ public Map remediation() { * @return the ResourceRecommendationBaseInner object itself. */ public ResourceRecommendationBaseInner withRemediation(Map remediation) { - this.remediation = remediation; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withRemediation(remediation); return this; } @@ -509,7 +460,7 @@ public ResourceRecommendationBaseInner withRemediation(Map remed * @return the exposedMetadataProperties value. */ public Map exposedMetadataProperties() { - return this.exposedMetadataProperties; + return this.innerProperties() == null ? null : this.innerProperties().exposedMetadataProperties(); } /** @@ -521,7 +472,10 @@ public Map exposedMetadataProperties() { */ public ResourceRecommendationBaseInner withExposedMetadataProperties( Map exposedMetadataProperties) { - this.exposedMetadataProperties = exposedMetadataProperties; + if (this.innerProperties() == null) { + this.innerProperties = new RecommendationProperties(); + } + this.innerProperties().withExposedMetadataProperties(exposedMetadataProperties); return this; } @@ -531,11 +485,8 @@ public ResourceRecommendationBaseInner withExposedMetadataProperties( * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { - if (shortDescription() != null) { - shortDescription().validate(); - } - if (resourceMetadata() != null) { - resourceMetadata().validate(); + if (innerProperties() != null) { + innerProperties().validate(); } } } diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionContractInner.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionContractInner.java index 5c3af5862bff..ef413ed3c73f 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 @@ -5,7 +5,6 @@ package com.azure.resourcemanager.advisor.fluent.models; import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.JsonFlatten; import com.azure.core.management.ProxyResource; import com.azure.core.util.logging.ClientLogger; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -13,28 +12,24 @@ import java.time.OffsetDateTime; /** The details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with the rule. */ -@JsonFlatten @Fluent -public class SuppressionContractInner extends ProxyResource { +public final class SuppressionContractInner extends ProxyResource { @JsonIgnore private final ClientLogger logger = new ClientLogger(SuppressionContractInner.class); /* - * The GUID of the suppression. + * The properties of the suppression. */ - @JsonProperty(value = "properties.suppressionId") - private String suppressionId; + @JsonProperty(value = "properties") + private SuppressionProperties innerProperties; - /* - * The duration for which the suppression is valid. - */ - @JsonProperty(value = "properties.ttl") - private String ttl; - - /* - * Gets or sets the expiration time stamp. + /** + * Get the innerProperties property: The properties of the suppression. + * + * @return the innerProperties value. */ - @JsonProperty(value = "properties.expirationTimeStamp", access = JsonProperty.Access.WRITE_ONLY) - private OffsetDateTime expirationTimestamp; + private SuppressionProperties innerProperties() { + return this.innerProperties; + } /** * Get the suppressionId property: The GUID of the suppression. @@ -42,7 +37,7 @@ public class SuppressionContractInner extends ProxyResource { * @return the suppressionId value. */ public String suppressionId() { - return this.suppressionId; + return this.innerProperties() == null ? null : this.innerProperties().suppressionId(); } /** @@ -52,7 +47,10 @@ public String suppressionId() { * @return the SuppressionContractInner object itself. */ public SuppressionContractInner withSuppressionId(String suppressionId) { - this.suppressionId = suppressionId; + if (this.innerProperties() == null) { + this.innerProperties = new SuppressionProperties(); + } + this.innerProperties().withSuppressionId(suppressionId); return this; } @@ -62,7 +60,7 @@ public SuppressionContractInner withSuppressionId(String suppressionId) { * @return the ttl value. */ public String ttl() { - return this.ttl; + return this.innerProperties() == null ? null : this.innerProperties().ttl(); } /** @@ -72,7 +70,10 @@ public String ttl() { * @return the SuppressionContractInner object itself. */ public SuppressionContractInner withTtl(String ttl) { - this.ttl = ttl; + if (this.innerProperties() == null) { + this.innerProperties = new SuppressionProperties(); + } + this.innerProperties().withTtl(ttl); return this; } @@ -82,7 +83,7 @@ public SuppressionContractInner withTtl(String ttl) { * @return the expirationTimestamp value. */ public OffsetDateTime expirationTimestamp() { - return this.expirationTimestamp; + return this.innerProperties() == null ? null : this.innerProperties().expirationTimestamp(); } /** @@ -91,5 +92,8 @@ public OffsetDateTime expirationTimestamp() { * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } } } 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 new file mode 100644 index 000000000000..49bb74b06793 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/fluent/models/SuppressionProperties.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.advisor.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** The properties of the suppression. */ +@Fluent +public final class SuppressionProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(SuppressionProperties.class); + + /* + * 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; + + /** + * Get the suppressionId property: The GUID of the suppression. + * + * @return the suppressionId value. + */ + public String suppressionId() { + return this.suppressionId; + } + + /** + * Set the suppressionId property: The GUID of the suppression. + * + * @param suppressionId the suppressionId value to set. + * @return the SuppressionProperties object itself. + */ + public SuppressionProperties withSuppressionId(String suppressionId) { + this.suppressionId = suppressionId; + return this; + } + + /** + * Get the ttl property: The duration for which the suppression is valid. + * + * @return the ttl value. + */ + public String ttl() { + return this.ttl; + } + + /** + * Set the ttl property: The duration for which the suppression is valid. + * + * @param ttl the ttl value to set. + * @return the SuppressionProperties object itself. + */ + public SuppressionProperties withTtl(String ttl) { + this.ttl = ttl; + return this; + } + + /** + * Get the expirationTimestamp property: Gets or sets the expiration time stamp. + * + * @return the expirationTimestamp value. + */ + public OffsetDateTime expirationTimestamp() { + return this.expirationTimestamp; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionsClientImpl.java b/sdk/advisor/azure-resourcemanager-advisor/src/main/java/com/azure/resourcemanager/advisor/implementation/SuppressionsClientImpl.java index d1b8fce38d23..546ca8edaf67 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 @@ -77,7 +77,7 @@ Mono> get( @Headers({"Content-Type: application/json"}) @Put("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}") - @ExpectedResponses({200, 404}) + @ExpectedResponses({200}) @UnexpectedResponseExceptionType(ManagementException.class) Mono> create( @HostParam("$host") String endpoint, 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 283c7fb4390c..fd95c67543f5 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 @@ -191,7 +191,7 @@ public void deleteById(String id) { new IllegalArgumentException( String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id))); } - this.deleteWithResponse(resourceUri, recommendationId, name, Context.NONE).getValue(); + this.deleteWithResponse(resourceUri, recommendationId, name, Context.NONE); } public Response deleteByIdWithResponse(String id, Context context) { 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 85d9d75b5e11..53176292497e 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 @@ -7,6 +7,7 @@ import com.azure.core.annotation.Fluent; import com.azure.core.util.logging.ClientLogger; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Map; @@ -31,6 +32,7 @@ public final class ResourceMetadata { * The action to view resource. */ @JsonProperty(value = "action") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) private Map action; /* 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 new file mode 100644 index 000000000000..b546b9b94783 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInResourceGroupSamples.java @@ -0,0 +1,51 @@ +// 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.resourcemanager.advisor.models.Category; +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 java.util.Arrays; + +/** 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 + */ + /** + * Sample code: PutConfigurations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void putConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + 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))) + .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 new file mode 100644 index 000000000000..c80891684f7e --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsCreateInSubscriptionSamples.java @@ -0,0 +1,54 @@ +// 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.Context; +import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner; +import com.azure.resourcemanager.advisor.models.Category; +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 java.util.Arrays; + +/** 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 + */ + /** + * 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))), + 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 new file mode 100644 index 000000000000..16a18eaa02f7 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListByResourceGroupSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * Sample code: GetConfigurations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.configurations().listByResourceGroup("resourceGroup", Context.NONE); + } +} 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 new file mode 100644 index 000000000000..a52ea1d18c1b --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/ConfigurationsListSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * Sample code: GetConfigurations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getConfigurations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.configurations().list(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 new file mode 100644 index 000000000000..ac64d17525a7 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataGetSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * Sample code: GetMetadata. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getMetadata(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendationMetadatas().getWithResponse("types", Context.NONE); + } +} 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 new file mode 100644 index 000000000000..91624f713402 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationMetadataListSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * Sample code: GetMetadata. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getMetadata(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendationMetadatas().list(Context.NONE); + } +} 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 new file mode 100644 index 000000000000..027d2adae3e2 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGenerateSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * Sample code: GenerateRecommendations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void generateRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendations().generateWithResponse(Context.NONE); + } +} 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 new file mode 100644 index 000000000000..79f3a587f93c --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetGenerateStatusSamples.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; + +import com.azure.core.util.Context; +import java.util.UUID; + +/** 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 + */ + /** + * Sample code: GetGenerateStatus. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getGenerateStatus(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendations().getGenerateStatusWithResponse(UUID.fromString("operationGUID"), 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 new file mode 100644 index 000000000000..38a67bb7f2af --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsGetSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * Sample code: GetRecommendationDetail. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getRecommendationDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendations().getWithResponse("resourceUri", "recommendationId", Context.NONE); + } +} 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 new file mode 100644 index 000000000000..d6067cd83a32 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/RecommendationsListSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * Sample code: ListRecommendations. + * + * @param manager Entry point to AdvisorManager. + */ + public static void listRecommendations(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.recommendations().list(null, 10, null, 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 new file mode 100644 index 000000000000..2d0933834073 --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsCreateSamples.java @@ -0,0 +1,25 @@ +// 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 Suppressions Create. */ +public final class SuppressionsCreateSamples { + /* + * x-ms-original-file: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-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() + .define("suppressionName1") + .withExistingRecommendation("resourceUri", "recommendationId") + .withTtl("07:00:00:00") + .create(); + } +} 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 new file mode 100644 index 000000000000..00ed87e55f0b --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsDeleteSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * 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", 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 new file mode 100644 index 000000000000..66178329beff --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsGetSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * Sample code: GetSuppressionDetail. + * + * @param manager Entry point to AdvisorManager. + */ + public static void getSuppressionDetail(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.suppressions().getWithResponse("resourceUri", "recommendationId", "suppressionName1", 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 new file mode 100644 index 000000000000..459b99a7784b --- /dev/null +++ b/sdk/advisor/azure-resourcemanager-advisor/src/samples/java/com/azure/resourcemanager/advisor/generated/SuppressionsListSamples.java @@ -0,0 +1,22 @@ +// 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.Context; + +/** 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 + */ + /** + * Sample code: ListSuppressions. + * + * @param manager Entry point to AdvisorManager. + */ + public static void listSuppressions(com.azure.resourcemanager.advisor.AdvisorManager manager) { + manager.suppressions().list(null, null, Context.NONE); + } +}