diff --git a/sdk/advisor/mgmt-v2017_03_31/pom.xml b/sdk/advisor/mgmt-v2017_03_31/pom.xml new file mode 100644 index 0000000000000..6a2ceaab90324 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + com.microsoft.azure.advisor.v2017_03_31 + + com.microsoft.azure + azure-arm-parent + 1.1.0 + ../../../pom.management.xml + + azure-mgmt-advisor + 1.0.0-beta + jar + Microsoft Azure SDK for Advisor Management + This package contains Microsoft Advisor Management SDK. + https://github.com/Azure/azure-sdk-for-java + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + UTF-8 + + + + + microsoft + Microsoft + + + + + com.microsoft.azure + azure-client-runtime + + + com.microsoft.azure + azure-arm-client-runtime + + + junit + junit + test + + + com.microsoft.azure + azure-client-authentication + test + + + com.microsoft.azure + azure-mgmt-resources + test + + + com.microsoft.azure + azure-arm-client-runtime + test-jar + test + + 1.6.5 + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + + true + true + + true + true + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search + + + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/ + ]]> +
+
+
+
+
+
diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Category.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Category.java new file mode 100644 index 0000000000000..0845459b1aaec --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Category.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for Category. + */ +public final class Category extends ExpandableStringEnum { + /** Static value HighAvailability for Category. */ + public static final Category HIGH_AVAILABILITY = fromString("HighAvailability"); + + /** Static value Security for Category. */ + public static final Category SECURITY = fromString("Security"); + + /** Static value Performance for Category. */ + public static final Category PERFORMANCE = fromString("Performance"); + + /** Static value Cost for Category. */ + public static final Category COST = fromString("Cost"); + + /** Static value OperationalExcellence for Category. */ + public static final Category OPERATIONAL_EXCELLENCE = fromString("OperationalExcellence"); + + /** + * Creates or finds a Category from its string representation. + * @param name a name to look for + * @return the corresponding Category + */ + @JsonCreator + public static Category fromString(String name) { + return fromString(name, Category.class); + } + + /** + * @return known Category values + */ + public static Collection values() { + return values(Category.class); + } +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Impact.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Impact.java new file mode 100644 index 0000000000000..59ff1e1192eee --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Impact.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for Impact. + */ +public final class Impact extends ExpandableStringEnum { + /** Static value High for Impact. */ + public static final Impact HIGH = fromString("High"); + + /** Static value Medium for Impact. */ + public static final Impact MEDIUM = fromString("Medium"); + + /** Static value Low for Impact. */ + public static final Impact LOW = fromString("Low"); + + /** + * Creates or finds a Impact from its string representation. + * @param name a name to look for + * @return the corresponding Impact + */ + @JsonCreator + public static Impact fromString(String name) { + return fromString(name, Impact.class); + } + + /** + * @return known Impact values + */ + public static Collection values() { + return values(Impact.class); + } +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/OperationDisplayInfo.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/OperationDisplayInfo.java new file mode 100644 index 0000000000000..4258d981915fc --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/OperationDisplayInfo.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The operation supported by Advisor. + */ +public class OperationDisplayInfo { + /** + * The description of the operation. + */ + @JsonProperty(value = "description") + private String description; + + /** + * The action that users can perform, based on their permission level. + */ + @JsonProperty(value = "operation") + private String operation; + + /** + * Service provider: Microsoft Advisor. + */ + @JsonProperty(value = "provider") + private String provider; + + /** + * Resource on which the operation is performed. + */ + @JsonProperty(value = "resource") + private String resource; + + /** + * Get the description of the operation. + * + * @return the description value + */ + public String description() { + return this.description; + } + + /** + * Set the description of the operation. + * + * @param description the description value to set + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the action that users can perform, based on their permission level. + * + * @return the operation value + */ + public String operation() { + return this.operation; + } + + /** + * Set the action that users can perform, based on their permission level. + * + * @param operation the operation value to set + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withOperation(String operation) { + this.operation = operation; + return this; + } + + /** + * Get service provider: Microsoft Advisor. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Set service provider: Microsoft Advisor. + * + * @param provider the provider value to set + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get resource on which the operation is performed. + * + * @return the resource value + */ + public String resource() { + return this.resource; + } + + /** + * Set resource on which the operation is performed. + * + * @param resource the resource value to set + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withResource(String resource) { + this.resource = resource; + return this; + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/OperationEntity.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/OperationEntity.java new file mode 100644 index 0000000000000..c61c3081f11ad --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/OperationEntity.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.advisor.v2017_03_31.implementation.AdvisorManager; +import com.microsoft.azure.management.advisor.v2017_03_31.implementation.OperationEntityInner; + +/** + * Type representing OperationEntity. + */ +public interface OperationEntity extends HasInner, HasManager { + /** + * @return the display value. + */ + OperationDisplayInfo display(); + + /** + * @return the name value. + */ + String name(); + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Operations.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Operations.java new file mode 100644 index 0000000000000..1f4d659956d74 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Operations.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import rx.Observable; +import com.microsoft.azure.management.advisor.v2017_03_31.implementation.OperationsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing Operations. + */ +public interface Operations extends HasInner { + /** + * Lists all the available Advisor REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(); + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Recommendations.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Recommendations.java new file mode 100644 index 0000000000000..8e1ed215420b5 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Recommendations.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import com.microsoft.azure.arm.collection.SupportsListing; +import rx.Observable; +import com.microsoft.azure.management.advisor.v2017_03_31.implementation.RecommendationsInner; +import com.microsoft.azure.arm.model.HasInner; +import rx.Completable; +import java.util.UUID; + +/** + * Type representing Recommendations. + */ +public interface Recommendations extends SupportsListing, HasInner { + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(String resourceUri, String recommendationId); + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation response header. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Completable getGenerateStatusAsync(UUID operationId); + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Completable generateAsync(); + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/RecommendationsGenerateHeaders.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/RecommendationsGenerateHeaders.java new file mode 100644 index 0000000000000..bed9bf9274698 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/RecommendationsGenerateHeaders.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Defines headers for Generate operation. + */ +public class RecommendationsGenerateHeaders { + /** + * The URL where the status of the asynchronous operation can be checked. + */ + @JsonProperty(value = "Location") + private String location; + + /** + * The amount of delay to use while the status of the operation is checked. + * The value is expressed in seconds. + */ + @JsonProperty(value = "Retry-After") + private String retryAfter; + + /** + * Get the URL where the status of the asynchronous operation can be checked. + * + * @return the location value + */ + public String location() { + return this.location; + } + + /** + * Set the URL where the status of the asynchronous operation can be checked. + * + * @param location the location value to set + * @return the RecommendationsGenerateHeaders object itself. + */ + public RecommendationsGenerateHeaders withLocation(String location) { + this.location = location; + return this; + } + + /** + * Get the amount of delay to use while the status of the operation is checked. The value is expressed in seconds. + * + * @return the retryAfter value + */ + public String retryAfter() { + return this.retryAfter; + } + + /** + * Set the amount of delay to use while the status of the operation is checked. The value is expressed in seconds. + * + * @param retryAfter the retryAfter value to set + * @return the RecommendationsGenerateHeaders object itself. + */ + public RecommendationsGenerateHeaders withRetryAfter(String retryAfter) { + this.retryAfter = retryAfter; + return this; + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/ResourceRecommendationBase.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/ResourceRecommendationBase.java new file mode 100644 index 0000000000000..e338644930552 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/ResourceRecommendationBase.java @@ -0,0 +1,91 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.management.advisor.v2017_03_31.implementation.ResourceRecommendationBaseInner; +import com.microsoft.azure.arm.model.Indexable; +import com.microsoft.azure.arm.model.Refreshable; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.advisor.v2017_03_31.implementation.AdvisorManager; +import org.joda.time.DateTime; +import java.util.Map; +import java.util.List; +import java.util.UUID; + +/** + * Type representing ResourceRecommendationBase. + */ +public interface ResourceRecommendationBase extends HasInner, Indexable, Refreshable, HasManager { + /** + * @return the category value. + */ + Category category(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the impact value. + */ + Impact impact(); + + /** + * @return the impactedField value. + */ + String impactedField(); + + /** + * @return the impactedValue value. + */ + String impactedValue(); + + /** + * @return the lastUpdated value. + */ + DateTime lastUpdated(); + + /** + * @return the metadata value. + */ + Map metadata(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the recommendationTypeId value. + */ + String recommendationTypeId(); + + /** + * @return the risk value. + */ + Risk risk(); + + /** + * @return the shortDescription value. + */ + ShortDescription shortDescription(); + + /** + * @return the suppressionIds value. + */ + List suppressionIds(); + + /** + * @return the type value. + */ + String type(); + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Risk.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Risk.java new file mode 100644 index 0000000000000..f681ce0a5903e --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Risk.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for Risk. + */ +public final class Risk extends ExpandableStringEnum { + /** Static value Error for Risk. */ + public static final Risk ERROR = fromString("Error"); + + /** Static value Warning for Risk. */ + public static final Risk WARNING = fromString("Warning"); + + /** Static value None for Risk. */ + public static final Risk NONE = fromString("None"); + + /** + * Creates or finds a Risk from its string representation. + * @param name a name to look for + * @return the corresponding Risk + */ + @JsonCreator + public static Risk fromString(String name) { + return fromString(name, Risk.class); + } + + /** + * @return known Risk values + */ + public static Collection values() { + return values(Risk.class); + } +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/ShortDescription.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/ShortDescription.java new file mode 100644 index 0000000000000..9cc94d33f9e05 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/ShortDescription.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A summary of the recommendation. + */ +public class ShortDescription { + /** + * The issue or opportunity identified by the recommendation. + */ + @JsonProperty(value = "problem") + private String problem; + + /** + * The remediation action suggested by the recommendation. + */ + @JsonProperty(value = "solution") + private String solution; + + /** + * Get the issue or opportunity identified by the recommendation. + * + * @return the problem value + */ + public String problem() { + return this.problem; + } + + /** + * Set the issue or opportunity identified by the recommendation. + * + * @param problem the problem value to set + * @return the ShortDescription object itself. + */ + public ShortDescription withProblem(String problem) { + this.problem = problem; + return this; + } + + /** + * Get the remediation action suggested by the recommendation. + * + * @return the solution value + */ + public String solution() { + return this.solution; + } + + /** + * Set the remediation action suggested by the recommendation. + * + * @param solution the solution value to set + * @return the ShortDescription object itself. + */ + public ShortDescription withSolution(String solution) { + this.solution = solution; + return this; + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/SuppressionContract.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/SuppressionContract.java new file mode 100644 index 0000000000000..74eb1a1dd86fe --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/SuppressionContract.java @@ -0,0 +1,157 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.management.advisor.v2017_03_31.implementation.SuppressionContractInner; +import com.microsoft.azure.arm.model.Indexable; +import com.microsoft.azure.arm.model.Refreshable; +import com.microsoft.azure.arm.model.Updatable; +import com.microsoft.azure.arm.model.Appliable; +import com.microsoft.azure.arm.model.Creatable; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.advisor.v2017_03_31.implementation.AdvisorManager; + +/** + * Type representing SuppressionContract. + */ +public interface SuppressionContract extends HasInner, Indexable, Refreshable, Updatable, HasManager { + /** + * @return the id value. + */ + String id(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the suppressionId value. + */ + String suppressionId(); + + /** + * @return the ttl value. + */ + String ttl(); + + /** + * @return the type value. + */ + String type(); + + /** + * The entirety of the SuppressionContract definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithRecommendation, DefinitionStages.WithResourceUri, DefinitionStages.WithCreate { + } + + /** + * Grouping of SuppressionContract definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a SuppressionContract definition. + */ + interface Blank extends WithRecommendation { + } + + /** + * The stage of the suppressioncontract definition allowing to specify Recommendation. + */ + interface WithRecommendation { + /** + * Specifies recommendationId. + * @param recommendationId The recommendation ID + * @return the next definition stage + */ + WithResourceUri withExistingRecommendation(String recommendationId); + } + + /** + * The stage of the suppressioncontract definition allowing to specify ResourceUri. + */ + interface WithResourceUri { + /** + * Specifies resourceUri. + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies + * @return the next definition stage + */ + WithCreate withResourceUri(String resourceUri); + } + + /** + * The stage of the suppressioncontract definition allowing to specify SuppressionId. + */ + interface WithSuppressionId { + /** + * Specifies suppressionId. + * @param suppressionId The GUID of the suppression + * @return the next definition stage + */ + WithCreate withSuppressionId(String suppressionId); + } + + /** + * The stage of the suppressioncontract definition allowing to specify Ttl. + */ + interface WithTtl { + /** + * Specifies ttl. + * @param ttl The duration for which the suppression is valid + * @return the next definition stage + */ + WithCreate withTtl(String ttl); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends Creatable, DefinitionStages.WithSuppressionId, DefinitionStages.WithTtl { + } + } + /** + * The template for a SuppressionContract update operation, containing all the settings that can be modified. + */ + interface Update extends Appliable, UpdateStages.WithSuppressionId, UpdateStages.WithTtl { + } + + /** + * Grouping of SuppressionContract update stages. + */ + interface UpdateStages { + /** + * The stage of the suppressioncontract update allowing to specify SuppressionId. + */ + interface WithSuppressionId { + /** + * Specifies suppressionId. + * @param suppressionId The GUID of the suppression + * @return the next update stage + */ + Update withSuppressionId(String suppressionId); + } + + /** + * The stage of the suppressioncontract update allowing to specify Ttl. + */ + interface WithTtl { + /** + * Specifies ttl. + * @param ttl The duration for which the suppression is valid + * @return the next update stage + */ + Update withTtl(String ttl); + } + + } +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Suppressions.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Suppressions.java new file mode 100644 index 0000000000000..9f9ea02c8019a --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/Suppressions.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31; + +import com.microsoft.azure.arm.collection.SupportsCreating; +import rx.Completable; +import rx.Observable; +import com.microsoft.azure.management.advisor.v2017_03_31.implementation.SuppressionsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing Suppressions. + */ +public interface Suppressions extends SupportsCreating, HasInner { + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listAsync(); + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(String resourceUri, String recommendationId, String name); + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Completable deleteAsync(String resourceUri, String recommendationId, String name); + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/AdvisorManagementClientImpl.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/AdvisorManagementClientImpl.java new file mode 100644 index 0000000000000..a183d920e4e55 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/AdvisorManagementClientImpl.java @@ -0,0 +1,224 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; + +/** + * Initializes a new instance of the AdvisorManagementClientImpl class. + */ +public class AdvisorManagementClientImpl extends AzureServiceClient { + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** The Azure subscription ID. */ + private String subscriptionId; + + /** + * Gets The Azure subscription ID. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Sets The Azure subscription ID. + * + * @param subscriptionId the subscriptionId value. + * @return the service client itself + */ + public AdvisorManagementClientImpl withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** The version of the API to be used with the client request. */ + private String apiVersion; + + /** + * Gets The version of the API to be used with the client request. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** The preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets The preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets The preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public AdvisorManagementClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** The retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets The retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets The retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public AdvisorManagementClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public AdvisorManagementClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The RecommendationsInner object to access its operations. + */ + private RecommendationsInner recommendations; + + /** + * Gets the RecommendationsInner object to access its operations. + * @return the RecommendationsInner object. + */ + public RecommendationsInner recommendations() { + return this.recommendations; + } + + /** + * The OperationsInner object to access its operations. + */ + private OperationsInner operations; + + /** + * Gets the OperationsInner object to access its operations. + * @return the OperationsInner object. + */ + public OperationsInner operations() { + return this.operations; + } + + /** + * The SuppressionsInner object to access its operations. + */ + private SuppressionsInner suppressions; + + /** + * Gets the SuppressionsInner object to access its operations. + * @return the SuppressionsInner object. + */ + public SuppressionsInner suppressions() { + return this.suppressions; + } + + /** + * Initializes an instance of AdvisorManagementClient client. + * + * @param credentials the management credentials for Azure + */ + public AdvisorManagementClientImpl(ServiceClientCredentials credentials) { + this("https://management.azure.com", credentials); + } + + /** + * Initializes an instance of AdvisorManagementClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public AdvisorManagementClientImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of AdvisorManagementClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public AdvisorManagementClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2017-03-31"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.recommendations = new RecommendationsInner(restClient().retrofit(), this); + this.operations = new OperationsInner(restClient().retrofit(), this); + this.suppressions = new SuppressionsInner(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("%s (%s, %s, auto-generated)", super.userAgent(), "AdvisorManagementClient", "2017-03-31"); + } +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/AdvisorManager.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/AdvisorManager.java new file mode 100644 index 0000000000000..1852b59fbb9c9 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/AdvisorManager.java @@ -0,0 +1,123 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.AzureEnvironment; +import com.microsoft.azure.AzureResponseBuilder; +import com.microsoft.azure.credentials.AzureTokenCredentials; +import com.microsoft.azure.management.apigeneration.Beta; +import com.microsoft.azure.management.apigeneration.Beta.SinceVersion; +import com.microsoft.azure.arm.resources.AzureConfigurable; +import com.microsoft.azure.serializer.AzureJacksonAdapter; +import com.microsoft.rest.RestClient; +import com.microsoft.azure.management.advisor.v2017_03_31.Recommendations; +import com.microsoft.azure.management.advisor.v2017_03_31.Operations; +import com.microsoft.azure.management.advisor.v2017_03_31.Suppressions; +import com.microsoft.azure.arm.resources.implementation.AzureConfigurableCoreImpl; +import com.microsoft.azure.arm.resources.implementation.ManagerCore; + +/** + * Entry point to Azure Advisor resource management. + */ +public final class AdvisorManager extends ManagerCore { + private Recommendations recommendations; + private Operations operations; + private Suppressions suppressions; + /** + * Get a Configurable instance that can be used to create AdvisorManager with optional configuration. + * + * @return the instance allowing configurations + */ + public static Configurable configure() { + return new AdvisorManager.ConfigurableImpl(); + } + /** + * Creates an instance of AdvisorManager that exposes Advisor resource management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the AdvisorManager + */ + public static AdvisorManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return new AdvisorManager(new RestClient.Builder() + .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) + .withCredentials(credentials) + .withSerializerAdapter(new AzureJacksonAdapter()) + .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) + .build(), subscriptionId); + } + /** + * Creates an instance of AdvisorManager that exposes Advisor resource management API entry points. + * + * @param restClient the RestClient to be used for API calls. + * @param subscriptionId the subscription UUID + * @return the AdvisorManager + */ + public static AdvisorManager authenticate(RestClient restClient, String subscriptionId) { + return new AdvisorManager(restClient, subscriptionId); + } + /** + * The interface allowing configurations to be set. + */ + public interface Configurable extends AzureConfigurable { + /** + * Creates an instance of AdvisorManager that exposes Advisor management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the interface exposing Advisor management API entry points that work across subscriptions + */ + AdvisorManager authenticate(AzureTokenCredentials credentials, String subscriptionId); + } + + /** + * @return Entry point to manage Recommendations. + */ + public Recommendations recommendations() { + if (this.recommendations == null) { + this.recommendations = new RecommendationsImpl(this); + } + return this.recommendations; + } + + /** + * @return Entry point to manage Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(this); + } + return this.operations; + } + + /** + * @return Entry point to manage Suppressions. + */ + public Suppressions suppressions() { + if (this.suppressions == null) { + this.suppressions = new SuppressionsImpl(this); + } + return this.suppressions; + } + + /** + * The implementation for Configurable interface. + */ + private static final class ConfigurableImpl extends AzureConfigurableCoreImpl implements Configurable { + public AdvisorManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return AdvisorManager.authenticate(buildRestClient(credentials), subscriptionId); + } + } + private AdvisorManager(RestClient restClient, String subscriptionId) { + super( + restClient, + subscriptionId, + new AdvisorManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); + } +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/IdParsingUtils.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/IdParsingUtils.java new file mode 100644 index 0000000000000..3e5f7e0d50215 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/IdParsingUtils.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; +import java.util.Arrays; +import java.util.Iterator; + +class IdParsingUtils { + public static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterable iterable = Arrays.asList(id.split("/")); + Iterator itr = iterable.iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && part.trim() != "") { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + public static String getValueFromIdByPosition(String id, int pos) { + if (id == null) { + return null; + } + Iterable iterable = Arrays.asList(id.split("/")); + Iterator itr = iterable.iterator(); + int index = 0; + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && part.trim() != "") { + if (index == pos) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + index++; + } + return null; + } +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationEntityImpl.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationEntityImpl.java new file mode 100644 index 0000000000000..fe73071aaad1e --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationEntityImpl.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.management.advisor.v2017_03_31.OperationEntity; +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.advisor.v2017_03_31.OperationDisplayInfo; + +class OperationEntityImpl extends WrapperImpl implements OperationEntity { + private final AdvisorManager manager; + OperationEntityImpl(OperationEntityInner inner, AdvisorManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public AdvisorManager manager() { + return this.manager; + } + + @Override + public OperationDisplayInfo display() { + return this.inner().display(); + } + + @Override + public String name() { + return this.inner().name(); + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationEntityInner.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationEntityInner.java new file mode 100644 index 0000000000000..b0f78fe23efe6 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationEntityInner.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.management.advisor.v2017_03_31.OperationDisplayInfo; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The operation supported by Advisor. + */ +public class OperationEntityInner { + /** + * Operation name: {provider}/{resource}/{operation}. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The operation supported by Advisor. + */ + @JsonProperty(value = "display") + private OperationDisplayInfo display; + + /** + * Get operation name: {provider}/{resource}/{operation}. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set operation name: {provider}/{resource}/{operation}. + * + * @param name the name value to set + * @return the OperationEntityInner object itself. + */ + public OperationEntityInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the operation supported by Advisor. + * + * @return the display value + */ + public OperationDisplayInfo display() { + return this.display; + } + + /** + * Set the operation supported by Advisor. + * + * @param display the display value to set + * @return the OperationEntityInner object itself. + */ + public OperationEntityInner withDisplay(OperationDisplayInfo display) { + this.display = display; + return this; + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationsImpl.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationsImpl.java new file mode 100644 index 0000000000000..877600676b1b0 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationsImpl.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * abc + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.advisor.v2017_03_31.Operations; +import rx.functions.Func1; +import rx.Observable; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.advisor.v2017_03_31.OperationEntity; + +class OperationsImpl extends WrapperImpl implements Operations { + private final AdvisorManager manager; + + OperationsImpl(AdvisorManager manager) { + super(manager.inner().operations()); + this.manager = manager; + } + + public AdvisorManager manager() { + return this.manager; + } + + @Override + public Observable listAsync() { + OperationsInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public OperationEntity call(OperationEntityInner inner) { + return new OperationEntityImpl(inner, manager()); + } + }); + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationsInner.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationsInner.java new file mode 100644 index 0000000000000..875790742bf27 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/OperationsInner.java @@ -0,0 +1,283 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.CloudException; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Operations. + */ +public class OperationsInner { + /** The Retrofit service to perform REST calls. */ + private OperationsService service; + /** The service client containing this operation class. */ + private AdvisorManagementClientImpl client; + + /** + * Initializes an instance of OperationsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public OperationsInner(Retrofit retrofit, AdvisorManagementClientImpl client) { + this.service = retrofit.create(OperationsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Operations to be + * used by Retrofit to perform actually REST calls. + */ + interface OperationsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Operations list" }) + @GET("providers/Microsoft.Advisor/operations") + Observable> list(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Operations listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists all the available Advisor REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<OperationEntityInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all the available Advisor REST API operations. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationEntityInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationEntityInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<OperationEntityInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<OperationEntityInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all the available Advisor REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationEntityInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all the available Advisor REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationEntityInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all the available Advisor REST API operations. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<OperationEntityInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/PageImpl.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/PageImpl.java new file mode 100644 index 0000000000000..779d992792641 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/PageImpl.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Page; +import java.util.List; + +/** + * An instance of this class defines a page of Azure resources and a link to + * get the next page of resources, if any. + * + * @param type of Azure resource + */ +public class PageImpl implements Page { + /** + * The link to the next page. + */ + @JsonProperty("nextLink") + private String nextPageLink; + + /** + * The list of items. + */ + @JsonProperty("value") + private List items; + + /** + * Gets the link to the next page. + * + * @return the link to the next page. + */ + @Override + public String nextPageLink() { + return this.nextPageLink; + } + + /** + * Gets the list of items. + * + * @return the list of items in {@link List}. + */ + @Override + public List items() { + return items; + } + + /** + * Sets the link to the next page. + * + * @param nextPageLink the link to the next page. + * @return this Page object itself. + */ + public PageImpl setNextPageLink(String nextPageLink) { + this.nextPageLink = nextPageLink; + return this; + } + + /** + * Sets the list of items. + * + * @param items the list of items in {@link List}. + * @return this Page object itself. + */ + public PageImpl setItems(List items) { + this.items = items; + return this; + } +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/PageImpl1.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/PageImpl1.java new file mode 100644 index 0000000000000..84d2c81e16438 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/PageImpl1.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Page; +import java.util.List; + +/** + * An instance of this class defines a page of Azure resources and a link to + * get the next page of resources, if any. + * + * @param type of Azure resource + */ +public class PageImpl1 implements Page { + /** + * The link to the next page. + */ + @JsonProperty("") + private String nextPageLink; + + /** + * The list of items. + */ + @JsonProperty("value") + private List items; + + /** + * Gets the link to the next page. + * + * @return the link to the next page. + */ + @Override + public String nextPageLink() { + return this.nextPageLink; + } + + /** + * Gets the list of items. + * + * @return the list of items in {@link List}. + */ + @Override + public List items() { + return items; + } + + /** + * Sets the link to the next page. + * + * @param nextPageLink the link to the next page. + * @return this Page object itself. + */ + public PageImpl1 setNextPageLink(String nextPageLink) { + this.nextPageLink = nextPageLink; + return this; + } + + /** + * Sets the list of items. + * + * @param items the list of items in {@link List}. + * @return this Page object itself. + */ + public PageImpl1 setItems(List items) { + this.items = items; + return this; + } +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/RecommendationsImpl.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/RecommendationsImpl.java new file mode 100644 index 0000000000000..d16c9a360ee6b --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/RecommendationsImpl.java @@ -0,0 +1,94 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * jkl + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.advisor.v2017_03_31.Recommendations; +import rx.Observable; +import rx.functions.Func1; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.advisor.v2017_03_31.ResourceRecommendationBase; +import com.microsoft.azure.arm.utils.PagedListConverter; +import rx.Completable; +import java.util.UUID; + +class RecommendationsImpl extends WrapperImpl implements Recommendations { + private PagedListConverter converter; + private final AdvisorManager manager; + + RecommendationsImpl(AdvisorManager manager) { + super(manager.inner().recommendations()); + this.manager = manager; + this.converter = new PagedListConverter() { + @Override + public Observable typeConvertAsync(ResourceRecommendationBaseInner inner) { + return Observable.just((ResourceRecommendationBase) wrapModel(inner)); + } + }; + } + + public AdvisorManager manager() { + return this.manager; + } + + private ResourceRecommendationBaseImpl wrapModel(ResourceRecommendationBaseInner inner) { + return new ResourceRecommendationBaseImpl(inner, manager()); + } + + @Override + public Observable getAsync(String resourceUri, String recommendationId) { + RecommendationsInner client = this.inner(); + return client.getAsync(resourceUri, recommendationId) + .map(new Func1() { + @Override + public ResourceRecommendationBase call(ResourceRecommendationBaseInner inner) { + return new ResourceRecommendationBaseImpl(inner, manager()); + } + }); + } + + @Override + public PagedList list() { + RecommendationsInner client = this.inner(); + return converter.convert(client.list()); + } + + @Override + public Observable listAsync() { + RecommendationsInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public ResourceRecommendationBase call(ResourceRecommendationBaseInner inner) { + return wrapModel(inner); + } + }); + } + + @Override + public Completable getGenerateStatusAsync(UUID operationId) { + RecommendationsInner client = this.inner(); + return client.getGenerateStatusAsync(operationId).toCompletable(); + } + + @Override + public Completable generateAsync() { + RecommendationsInner client = this.inner(); + return client.generateAsync().toCompletable(); + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/RecommendationsInner.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/RecommendationsInner.java new file mode 100644 index 0000000000000..eceadc055b2b2 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/RecommendationsInner.java @@ -0,0 +1,655 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.CloudException; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.advisor.v2017_03_31.RecommendationsGenerateHeaders; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseWithHeaders; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Recommendations. + */ +public class RecommendationsInner { + /** The Retrofit service to perform REST calls. */ + private RecommendationsService service; + /** The service client containing this operation class. */ + private AdvisorManagementClientImpl client; + + /** + * Initializes an instance of RecommendationsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public RecommendationsInner(Retrofit retrofit, AdvisorManagementClientImpl client) { + this.service = retrofit.create(RecommendationsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Recommendations to be + * used by Retrofit to perform actually REST calls. + */ + interface RecommendationsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Recommendations generate" }) + @POST("subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations") + Observable> generate(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Recommendations getGenerateStatus" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}") + Observable> getGenerateStatus(@Path("subscriptionId") String subscriptionId, @Path("operationId") UUID operationId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Recommendations list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations") + Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$skipToken") String skipToken, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Recommendations get" }) + @GET("{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}") + Observable> get(@Path("resourceUri") String resourceUri, @Path("recommendationId") String recommendationId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Recommendations listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void generate() { + generateWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture generateAsync(final ServiceCallback serviceCallback) { + return ServiceFuture.fromHeaderResponse(generateWithServiceResponseAsync(), serviceCallback); + } + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable generateAsync() { + return generateWithServiceResponseAsync().map(new Func1, Void>() { + @Override + public Void call(ServiceResponseWithHeaders response) { + return response.body(); + } + }); + } + + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable> generateWithServiceResponseAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.generate(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponseWithHeaders clientResponse = generateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponseWithHeaders generateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(202, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .buildWithHeaders(response, RecommendationsGenerateHeaders.class); + } + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation response header. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void getGenerateStatus(UUID operationId) { + getGenerateStatusWithServiceResponseAsync(operationId).toBlocking().single().body(); + } + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation response header. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getGenerateStatusAsync(UUID operationId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getGenerateStatusWithServiceResponseAsync(operationId), serviceCallback); + } + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation response header. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable getGenerateStatusAsync(UUID operationId) { + return getGenerateStatusWithServiceResponseAsync(operationId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the generation recommendation. The URI of this API is returned in the Location field of the response header. + * + * @param operationId The operation ID, which can be found from the Location field in the generate recommendation response header. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> getGenerateStatusWithServiceResponseAsync(UUID operationId) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (operationId == null) { + throw new IllegalArgumentException("Parameter operationId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.getGenerateStatus(this.client.subscriptionId(), operationId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getGenerateStatusDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getGenerateStatusDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(202, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ResourceRecommendationBaseInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ResourceRecommendationBaseInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ResourceRecommendationBaseInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ResourceRecommendationBaseInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String filter = null; + final Integer top = null; + final String skipToken = null; + return service.list(this.client.subscriptionId(), this.client.apiVersion(), filter, top, skipToken, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @param filter The filter to apply to the recommendations. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ResourceRecommendationBaseInner> object if successful. + */ + public PagedList list(final String filter, final Integer top, final String skipToken) { + ServiceResponse> response = listSinglePageAsync(filter, top, skipToken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @param filter The filter to apply to the recommendations. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String filter, final Integer top, final String skipToken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(filter, top, skipToken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @param filter The filter to apply to the recommendations. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ResourceRecommendationBaseInner> object + */ + public Observable> listAsync(final String filter, final Integer top, final String skipToken) { + return listWithServiceResponseAsync(filter, top, skipToken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @param filter The filter to apply to the recommendations. + * @param top The number of recommendations per page if a paged version of this API is being used. + * @param skipToken The page-continuation token to use with a paged version of this API. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ResourceRecommendationBaseInner> object + */ + public Observable>> listWithServiceResponseAsync(final String filter, final Integer top, final String skipToken) { + return listSinglePageAsync(filter, top, skipToken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + ServiceResponse> * @param filter The filter to apply to the recommendations. + ServiceResponse> * @param top The number of recommendations per page if a paged version of this API is being used. + ServiceResponse> * @param skipToken The page-continuation token to use with a paged version of this API. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ResourceRecommendationBaseInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String filter, final Integer top, final String skipToken) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.subscriptionId(), this.client.apiVersion(), filter, top, skipToken, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ResourceRecommendationBaseInner object if successful. + */ + public ResourceRecommendationBaseInner get(String resourceUri, String recommendationId) { + return getWithServiceResponseAsync(resourceUri, recommendationId).toBlocking().single().body(); + } + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String resourceUri, String recommendationId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceUri, recommendationId), serviceCallback); + } + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ResourceRecommendationBaseInner object + */ + public Observable getAsync(String resourceUri, String recommendationId) { + return getWithServiceResponseAsync(resourceUri, recommendationId).map(new Func1, ResourceRecommendationBaseInner>() { + @Override + public ResourceRecommendationBaseInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Obtains details of a cached recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ResourceRecommendationBaseInner object + */ + public Observable> getWithServiceResponseAsync(String resourceUri, String recommendationId) { + if (resourceUri == null) { + throw new IllegalArgumentException("Parameter resourceUri is required and cannot be null."); + } + if (recommendationId == null) { + throw new IllegalArgumentException("Parameter recommendationId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(resourceUri, recommendationId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ResourceRecommendationBaseInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ResourceRecommendationBaseInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ResourceRecommendationBaseInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ResourceRecommendationBaseInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/ResourceRecommendationBaseImpl.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/ResourceRecommendationBaseImpl.java new file mode 100644 index 0000000000000..62672053b4d2d --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/ResourceRecommendationBaseImpl.java @@ -0,0 +1,115 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.management.advisor.v2017_03_31.ResourceRecommendationBase; +import com.microsoft.azure.arm.model.implementation.IndexableRefreshableWrapperImpl; +import rx.Observable; +import com.microsoft.azure.management.advisor.v2017_03_31.Category; +import com.microsoft.azure.management.advisor.v2017_03_31.Impact; +import org.joda.time.DateTime; +import java.util.Map; +import com.microsoft.azure.management.advisor.v2017_03_31.Risk; +import com.microsoft.azure.management.advisor.v2017_03_31.ShortDescription; +import java.util.List; +import java.util.UUID; + +class ResourceRecommendationBaseImpl extends IndexableRefreshableWrapperImpl implements ResourceRecommendationBase { + private String resourceUri; + private String recommendationId; + private final AdvisorManager manager; + + ResourceRecommendationBaseImpl(ResourceRecommendationBaseInner inner, AdvisorManager manager) { + super(null, inner); + this.manager = manager; + // set resource ancestor and positional variables + this.recommendationId = IdParsingUtils.getValueFromIdByName(inner.id(), "recommendations"); + this.resourceUri = IdParsingUtils.getValueFromIdByPosition(inner.id(), 0); + } + + @Override + public AdvisorManager manager() { + return this.manager; + } + + @Override + protected Observable getInnerAsync() { + RecommendationsInner client = this.manager().inner().recommendations(); + return client.getAsync(this.resourceUri, this.recommendationId); + } + + + + @Override + public Category category() { + return this.inner().category(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public Impact impact() { + return this.inner().impact(); + } + + @Override + public String impactedField() { + return this.inner().impactedField(); + } + + @Override + public String impactedValue() { + return this.inner().impactedValue(); + } + + @Override + public DateTime lastUpdated() { + return this.inner().lastUpdated(); + } + + @Override + public Map metadata() { + return this.inner().metadata(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public String recommendationTypeId() { + return this.inner().recommendationTypeId(); + } + + @Override + public Risk risk() { + return this.inner().risk(); + } + + @Override + public ShortDescription shortDescription() { + return this.inner().shortDescription(); + } + + @Override + public List suppressionIds() { + return this.inner().suppressionIds(); + } + + @Override + public String type() { + return this.inner().type(); + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/ResourceRecommendationBaseInner.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/ResourceRecommendationBaseInner.java new file mode 100644 index 0000000000000..4d3cb291f15c8 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/ResourceRecommendationBaseInner.java @@ -0,0 +1,293 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.management.advisor.v2017_03_31.Category; +import com.microsoft.azure.management.advisor.v2017_03_31.Impact; +import org.joda.time.DateTime; +import java.util.Map; +import com.microsoft.azure.management.advisor.v2017_03_31.Risk; +import com.microsoft.azure.management.advisor.v2017_03_31.ShortDescription; +import java.util.List; +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * Advisor Recommendation. + */ +@JsonFlatten +public class ResourceRecommendationBaseInner extends ProxyResource { + /** + * The category of the recommendation. Possible values include: + * 'HighAvailability', 'Security', 'Performance', 'Cost', + * 'OperationalExcellence'. + */ + @JsonProperty(value = "properties.category") + private Category category; + + /** + * The business impact of the recommendation. Possible values include: + * 'High', 'Medium', 'Low'. + */ + @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 DateTime 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. Possible + * values include: 'Error', 'Warning', 'None'. + */ + @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; + + /** + * Get the category of the recommendation. Possible values include: 'HighAvailability', 'Security', 'Performance', 'Cost', 'OperationalExcellence'. + * + * @return the category value + */ + public Category category() { + return this.category; + } + + /** + * Set the category of the recommendation. Possible values include: 'HighAvailability', 'Security', 'Performance', 'Cost', 'OperationalExcellence'. + * + * @param category the category value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withCategory(Category category) { + this.category = category; + return this; + } + + /** + * Get the business impact of the recommendation. Possible values include: 'High', 'Medium', 'Low'. + * + * @return the impact value + */ + public Impact impact() { + return this.impact; + } + + /** + * Set the business impact of the recommendation. Possible values include: 'High', 'Medium', 'Low'. + * + * @param impact the impact value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withImpact(Impact impact) { + this.impact = impact; + return this; + } + + /** + * Get the resource type identified by Advisor. + * + * @return the impactedField value + */ + public String impactedField() { + return this.impactedField; + } + + /** + * Set the resource type identified by Advisor. + * + * @param impactedField the impactedField value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withImpactedField(String impactedField) { + this.impactedField = impactedField; + return this; + } + + /** + * Get the resource identified by Advisor. + * + * @return the impactedValue value + */ + public String impactedValue() { + return this.impactedValue; + } + + /** + * Set the resource identified by Advisor. + * + * @param impactedValue the impactedValue value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withImpactedValue(String impactedValue) { + this.impactedValue = impactedValue; + return this; + } + + /** + * Get the most recent time that Advisor checked the validity of the recommendation. + * + * @return the lastUpdated value + */ + public DateTime lastUpdated() { + return this.lastUpdated; + } + + /** + * Set the most recent time that Advisor checked the validity of the recommendation. + * + * @param lastUpdated the lastUpdated value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withLastUpdated(DateTime lastUpdated) { + this.lastUpdated = lastUpdated; + return this; + } + + /** + * Get the recommendation metadata. + * + * @return the metadata value + */ + public Map metadata() { + return this.metadata; + } + + /** + * Set the recommendation metadata. + * + * @param metadata the metadata value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Get the recommendation-type GUID. + * + * @return the recommendationTypeId value + */ + public String recommendationTypeId() { + return this.recommendationTypeId; + } + + /** + * Set the recommendation-type GUID. + * + * @param recommendationTypeId the recommendationTypeId value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withRecommendationTypeId(String recommendationTypeId) { + this.recommendationTypeId = recommendationTypeId; + return this; + } + + /** + * Get the potential risk of not implementing the recommendation. Possible values include: 'Error', 'Warning', 'None'. + * + * @return the risk value + */ + public Risk risk() { + return this.risk; + } + + /** + * Set the potential risk of not implementing the recommendation. Possible values include: 'Error', 'Warning', 'None'. + * + * @param risk the risk value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withRisk(Risk risk) { + this.risk = risk; + return this; + } + + /** + * Get a summary of the recommendation. + * + * @return the shortDescription value + */ + public ShortDescription shortDescription() { + return this.shortDescription; + } + + /** + * Set a summary of the recommendation. + * + * @param shortDescription the shortDescription value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withShortDescription(ShortDescription shortDescription) { + this.shortDescription = shortDescription; + return this; + } + + /** + * Get the list of snoozed and dismissed rules for the recommendation. + * + * @return the suppressionIds value + */ + public List suppressionIds() { + return this.suppressionIds; + } + + /** + * Set the list of snoozed and dismissed rules for the recommendation. + * + * @param suppressionIds the suppressionIds value to set + * @return the ResourceRecommendationBaseInner object itself. + */ + public ResourceRecommendationBaseInner withSuppressionIds(List suppressionIds) { + this.suppressionIds = suppressionIds; + return this; + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionContractImpl.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionContractImpl.java new file mode 100644 index 0000000000000..055f27975d943 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionContractImpl.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.management.advisor.v2017_03_31.SuppressionContract; +import com.microsoft.azure.arm.model.implementation.CreatableUpdatableImpl; +import rx.Observable; + +class SuppressionContractImpl extends CreatableUpdatableImpl implements SuppressionContract, SuppressionContract.Definition, SuppressionContract.Update { + private final AdvisorManager manager; + private String resourceUri; + private String recommendationId; + private String name; + + SuppressionContractImpl(String name, AdvisorManager manager) { + super(name, new SuppressionContractInner()); + this.manager = manager; + // Set resource name + this.name = name; + // + } + + SuppressionContractImpl(SuppressionContractInner inner, AdvisorManager manager) { + super(inner.name(), inner); + this.manager = manager; + // Set resource name + this.name = inner.name(); + // set resource ancestor and positional variables + this.recommendationId = IdParsingUtils.getValueFromIdByName(inner.id(), "recommendations"); + this.name = IdParsingUtils.getValueFromIdByName(inner.id(), "suppressions"); + this.resourceUri = IdParsingUtils.getValueFromIdByPosition(inner.id(), 0); + // + } + + @Override + public AdvisorManager manager() { + return this.manager; + } + + @Override + public Observable createResourceAsync() { + SuppressionsInner client = this.manager().inner().suppressions(); + return client.createAsync(this.resourceUri, this.recommendationId, this.name, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + public Observable updateResourceAsync() { + SuppressionsInner client = this.manager().inner().suppressions(); + return client.createAsync(this.resourceUri, this.recommendationId, this.name, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + protected Observable getInnerAsync() { + SuppressionsInner client = this.manager().inner().suppressions(); + return client.getAsync(this.resourceUri, this.recommendationId, this.name); + } + + @Override + public boolean isInCreateMode() { + return this.inner().id() == null; + } + + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public String suppressionId() { + return this.inner().suppressionId(); + } + + @Override + public String ttl() { + return this.inner().ttl(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public SuppressionContractImpl withExistingRecommendation(String recommendationId) { + this.recommendationId = recommendationId; + return this; + } + + @Override + public SuppressionContractImpl withResourceUri(String resourceUri) { + this.resourceUri = resourceUri; + return this; + } + + @Override + public SuppressionContractImpl withSuppressionId(String suppressionId) { + this.inner().withSuppressionId(suppressionId); + return this; + } + + @Override + public SuppressionContractImpl withTtl(String ttl) { + this.inner().withTtl(ttl); + return this; + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionContractInner.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionContractInner.java new file mode 100644 index 0000000000000..c07ff5aa0d02d --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionContractInner.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * The details of the snoozed or dismissed rule; for example, the duration, + * name, and GUID associated with the rule. + */ +@JsonFlatten +public class SuppressionContractInner extends ProxyResource { + /** + * The GUID of the suppression. + */ + @JsonProperty(value = "properties.suppressionId") + private String suppressionId; + + /** + * The duration for which the suppression is valid. + */ + @JsonProperty(value = "properties.ttl") + private String ttl; + + /** + * Get the GUID of the suppression. + * + * @return the suppressionId value + */ + public String suppressionId() { + return this.suppressionId; + } + + /** + * Set the GUID of the suppression. + * + * @param suppressionId the suppressionId value to set + * @return the SuppressionContractInner object itself. + */ + public SuppressionContractInner withSuppressionId(String suppressionId) { + this.suppressionId = suppressionId; + return this; + } + + /** + * Get the duration for which the suppression is valid. + * + * @return the ttl value + */ + public String ttl() { + return this.ttl; + } + + /** + * Set the duration for which the suppression is valid. + * + * @param ttl the ttl value to set + * @return the SuppressionContractInner object itself. + */ + public SuppressionContractInner withTtl(String ttl) { + this.ttl = ttl; + return this; + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionsImpl.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionsImpl.java new file mode 100644 index 0000000000000..e7c01e9c85aa5 --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionsImpl.java @@ -0,0 +1,85 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.advisor.v2017_03_31.Suppressions; +import rx.Completable; +import rx.Observable; +import rx.functions.Func1; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.advisor.v2017_03_31.SuppressionContract; + +class SuppressionsImpl extends WrapperImpl implements Suppressions { + private final AdvisorManager manager; + + SuppressionsImpl(AdvisorManager manager) { + super(manager.inner().suppressions()); + this.manager = manager; + } + + public AdvisorManager manager() { + return this.manager; + } + + @Override + public SuppressionContractImpl define(String name) { + return wrapModel(name); + } + + private SuppressionContractImpl wrapModel(SuppressionContractInner inner) { + return new SuppressionContractImpl(inner, manager()); + } + + private SuppressionContractImpl wrapModel(String name) { + return new SuppressionContractImpl(name, this.manager()); + } + + @Override + public Observable listAsync() { + SuppressionsInner client = this.inner(); + return client.listAsync() + .flatMap(new Func1, Observable>() { + @Override + public Observable call(Page innerPage) { + return Observable.from(innerPage.items()); + } + }) + .map(new Func1() { + @Override + public SuppressionContract call(SuppressionContractInner inner) { + return new SuppressionContractImpl(inner, manager()); + } + }); + } + + @Override + public Observable getAsync(String resourceUri, String recommendationId, String name) { + SuppressionsInner client = this.inner(); + return client.getAsync(resourceUri, recommendationId, name) + .flatMap(new Func1>() { + @Override + public Observable call(SuppressionContractInner inner) { + if (inner == null) { + return Observable.empty(); + } else { + return Observable.just((SuppressionContract)wrapModel(inner)); + } + } + }); + } + + @Override + public Completable deleteAsync(String resourceUri, String recommendationId, String name) { + SuppressionsInner client = this.inner(); + return client.deleteAsync(resourceUri, recommendationId, name).toCompletable(); + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionsInner.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionsInner.java new file mode 100644 index 0000000000000..25a91684b396b --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/SuppressionsInner.java @@ -0,0 +1,437 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.CloudException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Suppressions. + */ +public class SuppressionsInner { + /** The Retrofit service to perform REST calls. */ + private SuppressionsService service; + /** The service client containing this operation class. */ + private AdvisorManagementClientImpl client; + + /** + * Initializes an instance of SuppressionsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public SuppressionsInner(Retrofit retrofit, AdvisorManagementClientImpl client) { + this.service = retrofit.create(SuppressionsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Suppressions to be + * used by Retrofit to perform actually REST calls. + */ + interface SuppressionsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Suppressions get" }) + @GET("{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}") + Observable> get(@Path("resourceUri") String resourceUri, @Path("recommendationId") String recommendationId, @Path("name") String name, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Suppressions create" }) + @PUT("{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}") + Observable> create(@Path("resourceUri") String resourceUri, @Path("recommendationId") String recommendationId, @Path("name") String name, @Body SuppressionContractInner suppressionContract, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Suppressions delete" }) + @HTTP(path = "{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", method = "DELETE", hasBody = true) + Observable> delete(@Path("resourceUri") String resourceUri, @Path("recommendationId") String recommendationId, @Path("name") String name, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.advisor.v2017_03_31.Suppressions list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions") + Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the SuppressionContractInner object if successful. + */ + public SuppressionContractInner get(String resourceUri, String recommendationId, String name) { + return getWithServiceResponseAsync(resourceUri, recommendationId, name).toBlocking().single().body(); + } + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String resourceUri, String recommendationId, String name, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceUri, recommendationId, name), serviceCallback); + } + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SuppressionContractInner object + */ + public Observable getAsync(String resourceUri, String recommendationId, String name) { + return getWithServiceResponseAsync(resourceUri, recommendationId, name).map(new Func1, SuppressionContractInner>() { + @Override + public SuppressionContractInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Obtains the details of a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SuppressionContractInner object + */ + public Observable> getWithServiceResponseAsync(String resourceUri, String recommendationId, String name) { + if (resourceUri == null) { + throw new IllegalArgumentException("Parameter resourceUri is required and cannot be null."); + } + if (recommendationId == null) { + throw new IllegalArgumentException("Parameter recommendationId is required and cannot be null."); + } + if (name == null) { + throw new IllegalArgumentException("Parameter name is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(resourceUri, recommendationId, name, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the SuppressionContractInner object if successful. + */ + public SuppressionContractInner create(String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + return createWithServiceResponseAsync(resourceUri, recommendationId, name, suppressionContract).toBlocking().single().body(); + } + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(resourceUri, recommendationId, name, suppressionContract), serviceCallback); + } + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SuppressionContractInner object + */ + public Observable createAsync(String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + return createWithServiceResponseAsync(resourceUri, recommendationId, name, suppressionContract).map(new Func1, SuppressionContractInner>() { + @Override + public SuppressionContractInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SuppressionContractInner object + */ + public Observable> createWithServiceResponseAsync(String resourceUri, String recommendationId, String name, SuppressionContractInner suppressionContract) { + if (resourceUri == null) { + throw new IllegalArgumentException("Parameter resourceUri is required and cannot be null."); + } + if (recommendationId == null) { + throw new IllegalArgumentException("Parameter recommendationId is required and cannot be null."); + } + if (name == null) { + throw new IllegalArgumentException("Parameter name is required and cannot be null."); + } + if (suppressionContract == null) { + throw new IllegalArgumentException("Parameter suppressionContract is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(suppressionContract); + return service.create(resourceUri, recommendationId, name, suppressionContract, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String resourceUri, String recommendationId, String name) { + deleteWithServiceResponseAsync(resourceUri, recommendationId, name).toBlocking().single().body(); + } + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String resourceUri, String recommendationId, String name, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceUri, recommendationId, name), serviceCallback); + } + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String resourceUri, String recommendationId, String name) { + return deleteWithServiceResponseAsync(resourceUri, recommendationId, name).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String resourceUri, String recommendationId, String name) { + if (resourceUri == null) { + throw new IllegalArgumentException("Parameter resourceUri is required and cannot be null."); + } + if (recommendationId == null) { + throw new IllegalArgumentException("Parameter recommendationId is required and cannot be null."); + } + if (name == null) { + throw new IllegalArgumentException("Parameter name is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(resourceUri, recommendationId, name, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(204, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @return the PagedList object if successful. + */ + public PagedList list() { + PageImpl1 page = new PageImpl1<>(); + page.setItems(listWithServiceResponseAsync().toBlocking().single().body()); + page.setNextPageLink(null); + return new PagedList(page) { + @Override + public Page nextPage(String nextPageLink) { + return null; + } + }; + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @return the observable to the List<SuppressionContractInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync().map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + PageImpl1 page = new PageImpl1<>(); + page.setItems(response.body()); + return page; + } + }); + } + + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. + * + * @return the observable to the List<SuppressionContractInner> object + */ + public Observable>> listWithServiceResponseAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + List items = null; + if (result.body() != null) { + items = result.body().items(); + } + ServiceResponse> clientResponse = new ServiceResponse>(items, result.response()); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/package-info.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/package-info.java new file mode 100644 index 0000000000000..46efcd59fe04d --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for AdvisorManagementClient. + * REST APIs for Azure Advisor. + */ +package com.microsoft.azure.management.advisor.v2017_03_31.implementation; diff --git a/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/package-info.java b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/package-info.java new file mode 100644 index 0000000000000..e0344a45fb43d --- /dev/null +++ b/sdk/advisor/mgmt-v2017_03_31/src/main/java/com/microsoft/azure/management/advisor/v2017_03_31/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for AdvisorManagementClient. + * REST APIs for Azure Advisor. + */ +package com.microsoft.azure.management.advisor.v2017_03_31;