From 0b08846ee746cd7d281a4d3996fe966bbbb2d44e Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Tue, 25 Feb 2020 11:01:37 +0000 Subject: [PATCH] Generated from 4e32ccac34d00a1d371389c7bdc21ed4c3588593 add package-subscriptions-2019-11 --- sdk/policy/mgmt-v2019_01_01/pom.xml | 135 ++ .../policy/v2019_01_01/ErrorResponse.java | 96 + .../v2019_01_01/ErrorResponseException.java | 44 + .../policy/v2019_01_01/Identity.java | 73 + .../policy/v2019_01_01/PolicyAssignment.java | 378 ++++ .../policy/v2019_01_01/PolicyAssignments.java | 91 + .../policy/v2019_01_01/PolicyDefinition.java | 278 +++ .../PolicyDefinitionReference.java | 69 + .../policy/v2019_01_01/PolicyDefinitions.java | 106 + .../v2019_01_01/PolicySetDefinition.java | 238 +++ .../v2019_01_01/PolicySetDefinitions.java | 106 + .../policy/v2019_01_01/PolicySku.java | 69 + .../policy/v2019_01_01/PolicyType.java | 44 + .../v2019_01_01/ResourceIdentityType.java | 53 + .../implementation/IdParsingUtils.java | 57 + .../v2019_01_01/implementation/PageImpl.java | 75 + .../implementation/PolicyAssignmentImpl.java | 205 ++ .../implementation/PolicyAssignmentInner.java | 285 +++ .../implementation/PolicyAssignmentsImpl.java | 179 ++ .../PolicyAssignmentsInner.java | 1748 +++++++++++++++++ .../implementation/PolicyClientImpl.java | 224 +++ .../implementation/PolicyDefinitionImpl.java | 162 ++ .../implementation/PolicyDefinitionInner.java | 206 ++ .../implementation/PolicyDefinitionsImpl.java | 174 ++ .../PolicyDefinitionsInner.java | 1410 +++++++++++++ .../implementation/PolicyManager.java | 123 ++ .../PolicySetDefinitionImpl.java | 153 ++ .../PolicySetDefinitionInner.java | 182 ++ .../PolicySetDefinitionsImpl.java | 174 ++ .../PolicySetDefinitionsInner.java | 1412 +++++++++++++ .../implementation/package-info.java | 11 + .../policy/v2019_01_01/package-info.java | 11 + 32 files changed, 8571 insertions(+) create mode 100644 sdk/policy/mgmt-v2019_01_01/pom.xml create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ErrorResponse.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ErrorResponseException.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/Identity.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyAssignment.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyAssignments.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinition.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinitionReference.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinitions.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySetDefinition.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySetDefinitions.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySku.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyType.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ResourceIdentityType.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/IdParsingUtils.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PageImpl.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentImpl.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentInner.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentsImpl.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentsInner.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyClientImpl.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionImpl.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionInner.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionsImpl.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionsInner.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyManager.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionImpl.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionInner.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionsImpl.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionsInner.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/package-info.java create mode 100644 sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/package-info.java diff --git a/sdk/policy/mgmt-v2019_01_01/pom.xml b/sdk/policy/mgmt-v2019_01_01/pom.xml new file mode 100644 index 0000000000000..0b5e2a32bc259 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + com.microsoft.azure.policy.v2019_01_01 + + com.microsoft.azure + azure-arm-parent + 1.1.0 + ../../../pom.management.xml + + azure-mgmt-policy + 1.0.0-beta + jar + Microsoft Azure SDK for Authorization Management + This package contains Microsoft Authorization 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/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ErrorResponse.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ErrorResponse.java new file mode 100644 index 0000000000000..dbef5561f2a5f --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ErrorResponse.java @@ -0,0 +1,96 @@ +/** + * 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.policy.v2019_01_01; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Error response indicates Azure Resource Manager is not able to process the + * incoming request. The reason is provided in the error message. + */ +public class ErrorResponse { + /** + * Http status code. + */ + @JsonProperty(value = "httpStatus") + private String httpStatus; + + /** + * Error code. + */ + @JsonProperty(value = "errorCode") + private String errorCode; + + /** + * Error message indicating why the operation failed. + */ + @JsonProperty(value = "errorMessage") + private String errorMessage; + + /** + * Get http status code. + * + * @return the httpStatus value + */ + public String httpStatus() { + return this.httpStatus; + } + + /** + * Set http status code. + * + * @param httpStatus the httpStatus value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withHttpStatus(String httpStatus) { + this.httpStatus = httpStatus; + return this; + } + + /** + * Get error code. + * + * @return the errorCode value + */ + public String errorCode() { + return this.errorCode; + } + + /** + * Set error code. + * + * @param errorCode the errorCode value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withErrorCode(String errorCode) { + this.errorCode = errorCode; + return this; + } + + /** + * Get error message indicating why the operation failed. + * + * @return the errorMessage value + */ + public String errorMessage() { + return this.errorMessage; + } + + /** + * Set error message indicating why the operation failed. + * + * @param errorMessage the errorMessage value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ErrorResponseException.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ErrorResponseException.java new file mode 100644 index 0000000000000..84854e9d5ee5c --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ErrorResponseException.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.policy.v2019_01_01; + +import com.microsoft.rest.RestException; +import okhttp3.ResponseBody; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with ErrorResponse information. + */ +public class ErrorResponseException extends RestException { + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + */ + public ErrorResponseException(final String message, final Response response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + * @param body the deserialized response body + */ + public ErrorResponseException(final String message, final Response response, final ErrorResponse body) { + super(message, response, body); + } + + @Override + public ErrorResponse body() { + return (ErrorResponse) super.body(); + } +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/Identity.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/Identity.java new file mode 100644 index 0000000000000..c58fbb989b68e --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/Identity.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.policy.v2019_01_01; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Identity for the resource. + */ +public class Identity { + /** + * The principal ID of the resource identity. + */ + @JsonProperty(value = "principalId", access = JsonProperty.Access.WRITE_ONLY) + private String principalId; + + /** + * The tenant ID of the resource identity. + */ + @JsonProperty(value = "tenantId", access = JsonProperty.Access.WRITE_ONLY) + private String tenantId; + + /** + * The identity type. Possible values include: 'SystemAssigned', 'None'. + */ + @JsonProperty(value = "type") + private ResourceIdentityType type; + + /** + * Get the principal ID of the resource identity. + * + * @return the principalId value + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenant ID of the resource identity. + * + * @return the tenantId value + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the identity type. Possible values include: 'SystemAssigned', 'None'. + * + * @return the type value + */ + public ResourceIdentityType type() { + return this.type; + } + + /** + * Set the identity type. Possible values include: 'SystemAssigned', 'None'. + * + * @param type the type value to set + * @return the Identity object itself. + */ + public Identity withType(ResourceIdentityType type) { + this.type = type; + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyAssignment.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyAssignment.java new file mode 100644 index 0000000000000..feb08bb735794 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyAssignment.java @@ -0,0 +1,378 @@ +/** + * 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.policy.v2019_01_01; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicyAssignmentInner; +import com.microsoft.azure.arm.model.Indexable; +import com.microsoft.azure.arm.model.Creatable; +import com.microsoft.azure.arm.model.Updatable; +import com.microsoft.azure.arm.model.Appliable; +import com.microsoft.azure.arm.model.Refreshable; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicyManager; +import java.util.List; + +/** + * Type representing PolicyAssignment. + */ +public interface PolicyAssignment extends HasInner, Indexable, Updatable, Refreshable, HasManager { + /** + * @return the description value. + */ + String description(); + + /** + * @return the displayName value. + */ + String displayName(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the identity value. + */ + Identity identity(); + + /** + * @return the location value. + */ + String location(); + + /** + * @return the metadata value. + */ + Object metadata(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the notScopes value. + */ + List notScopes(); + + /** + * @return the parameters value. + */ + Object parameters(); + + /** + * @return the policyDefinitionId value. + */ + String policyDefinitionId(); + + /** + * @return the scopeProperty value. + */ + String scopeProperty(); + + /** + * @return the sku value. + */ + PolicySku sku(); + + /** + * @return the type value. + */ + String type(); + + /** + * The entirety of the PolicyAssignment definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithScope, DefinitionStages.WithCreate { + } + + /** + * Grouping of PolicyAssignment definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a PolicyAssignment definition. + */ + interface Blank extends WithScope { + } + + /** + * The stage of the policyassignment definition allowing to specify Scope. + */ + interface WithScope { + /** + * Specifies scope. + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @return the next definition stage + */ + WithCreate withScope(String scope); + } + + /** + * The stage of the policyassignment definition allowing to specify Description. + */ + interface WithDescription { + /** + * Specifies description. + * @param description This message will be part of response in case of policy violation + * @return the next definition stage + */ + WithCreate withDescription(String description); + } + + /** + * The stage of the policyassignment definition allowing to specify DisplayName. + */ + interface WithDisplayName { + /** + * Specifies displayName. + * @param displayName The display name of the policy assignment + * @return the next definition stage + */ + WithCreate withDisplayName(String displayName); + } + + /** + * The stage of the policyassignment definition allowing to specify Identity. + */ + interface WithIdentity { + /** + * Specifies identity. + * @param identity The managed identity associated with the policy assignment + * @return the next definition stage + */ + WithCreate withIdentity(Identity identity); + } + + /** + * The stage of the policyassignment definition allowing to specify Location. + */ + interface WithLocation { + /** + * Specifies location. + * @param location The location of the policy assignment. Only required when utilizing managed identity + * @return the next definition stage + */ + WithCreate withLocation(String location); + } + + /** + * The stage of the policyassignment definition allowing to specify Metadata. + */ + interface WithMetadata { + /** + * Specifies metadata. + * @param metadata The policy assignment metadata + * @return the next definition stage + */ + WithCreate withMetadata(Object metadata); + } + + /** + * The stage of the policyassignment definition allowing to specify NotScopes. + */ + interface WithNotScopes { + /** + * Specifies notScopes. + * @param notScopes The policy's excluded scopes + * @return the next definition stage + */ + WithCreate withNotScopes(List notScopes); + } + + /** + * The stage of the policyassignment definition allowing to specify Parameters. + */ + interface WithParameters { + /** + * Specifies parameters. + * @param parameters Required if a parameter is used in policy rule + * @return the next definition stage + */ + WithCreate withParameters(Object parameters); + } + + /** + * The stage of the policyassignment definition allowing to specify PolicyDefinitionId. + */ + interface WithPolicyDefinitionId { + /** + * Specifies policyDefinitionId. + * @param policyDefinitionId The ID of the policy definition or policy set definition being assigned + * @return the next definition stage + */ + WithCreate withPolicyDefinitionId(String policyDefinitionId); + } + + /** + * The stage of the policyassignment definition allowing to specify ScopeProperty. + */ + interface WithScopeProperty { + /** + * Specifies scopeProperty. + * @param scopeProperty The scope for the policy assignment + * @return the next definition stage + */ + WithCreate withScopeProperty(String scopeProperty); + } + + /** + * The stage of the policyassignment definition allowing to specify Sku. + */ + interface WithSku { + /** + * Specifies sku. + * @param sku The policy sku. This property is optional, obsolete, and will be ignored + * @return the next definition stage + */ + WithCreate withSku(PolicySku sku); + } + + /** + * 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.WithDescription, DefinitionStages.WithDisplayName, DefinitionStages.WithIdentity, DefinitionStages.WithLocation, DefinitionStages.WithMetadata, DefinitionStages.WithNotScopes, DefinitionStages.WithParameters, DefinitionStages.WithPolicyDefinitionId, DefinitionStages.WithScopeProperty, DefinitionStages.WithSku { + } + } + /** + * The template for a PolicyAssignment update operation, containing all the settings that can be modified. + */ + interface Update extends Appliable, UpdateStages.WithDescription, UpdateStages.WithDisplayName, UpdateStages.WithIdentity, UpdateStages.WithLocation, UpdateStages.WithMetadata, UpdateStages.WithNotScopes, UpdateStages.WithParameters, UpdateStages.WithPolicyDefinitionId, UpdateStages.WithScopeProperty, UpdateStages.WithSku { + } + + /** + * Grouping of PolicyAssignment update stages. + */ + interface UpdateStages { + /** + * The stage of the policyassignment update allowing to specify Description. + */ + interface WithDescription { + /** + * Specifies description. + * @param description This message will be part of response in case of policy violation + * @return the next update stage + */ + Update withDescription(String description); + } + + /** + * The stage of the policyassignment update allowing to specify DisplayName. + */ + interface WithDisplayName { + /** + * Specifies displayName. + * @param displayName The display name of the policy assignment + * @return the next update stage + */ + Update withDisplayName(String displayName); + } + + /** + * The stage of the policyassignment update allowing to specify Identity. + */ + interface WithIdentity { + /** + * Specifies identity. + * @param identity The managed identity associated with the policy assignment + * @return the next update stage + */ + Update withIdentity(Identity identity); + } + + /** + * The stage of the policyassignment update allowing to specify Location. + */ + interface WithLocation { + /** + * Specifies location. + * @param location The location of the policy assignment. Only required when utilizing managed identity + * @return the next update stage + */ + Update withLocation(String location); + } + + /** + * The stage of the policyassignment update allowing to specify Metadata. + */ + interface WithMetadata { + /** + * Specifies metadata. + * @param metadata The policy assignment metadata + * @return the next update stage + */ + Update withMetadata(Object metadata); + } + + /** + * The stage of the policyassignment update allowing to specify NotScopes. + */ + interface WithNotScopes { + /** + * Specifies notScopes. + * @param notScopes The policy's excluded scopes + * @return the next update stage + */ + Update withNotScopes(List notScopes); + } + + /** + * The stage of the policyassignment update allowing to specify Parameters. + */ + interface WithParameters { + /** + * Specifies parameters. + * @param parameters Required if a parameter is used in policy rule + * @return the next update stage + */ + Update withParameters(Object parameters); + } + + /** + * The stage of the policyassignment update allowing to specify PolicyDefinitionId. + */ + interface WithPolicyDefinitionId { + /** + * Specifies policyDefinitionId. + * @param policyDefinitionId The ID of the policy definition or policy set definition being assigned + * @return the next update stage + */ + Update withPolicyDefinitionId(String policyDefinitionId); + } + + /** + * The stage of the policyassignment update allowing to specify ScopeProperty. + */ + interface WithScopeProperty { + /** + * Specifies scopeProperty. + * @param scopeProperty The scope for the policy assignment + * @return the next update stage + */ + Update withScopeProperty(String scopeProperty); + } + + /** + * The stage of the policyassignment update allowing to specify Sku. + */ + interface WithSku { + /** + * Specifies sku. + * @param sku The policy sku. This property is optional, obsolete, and will be ignored + * @return the next update stage + */ + Update withSku(PolicySku sku); + } + + } +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyAssignments.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyAssignments.java new file mode 100644 index 0000000000000..be4e0c886a4f5 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyAssignments.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.policy.v2019_01_01; + +import com.microsoft.azure.arm.collection.SupportsCreating; +import com.microsoft.azure.arm.resources.collection.SupportsListingByResourceGroup; +import com.microsoft.azure.arm.collection.SupportsListing; +import rx.Completable; +import rx.Observable; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicyAssignmentInner; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicyAssignmentsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing PolicyAssignments. + */ +public interface PolicyAssignments extends SupportsCreating, SupportsListingByResourceGroup, SupportsListing, HasInner { + /** + * Deletes a policy assignment. + * This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable deleteAsync(String scope, String policyAssignmentName); + + /** + * Retrieves a policy assignment. + * This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(String scope, String policyAssignmentName); + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listForResourceAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName); + + /** + * Deletes a policy assignment. + * This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * + * @param policyAssignmentId The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable deleteByIdAsync(String policyAssignmentId); + + /** + * Creates or updates a policy assignment. + * This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @param parameters Parameters for policy assignment. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable createByIdAsync(String policyAssignmentId, PolicyAssignmentInner parameters); + + /** + * Retrieves the policy assignment with the given ID. + * The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getByIdAsync(String policyAssignmentId); + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinition.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinition.java new file mode 100644 index 0000000000000..71304de54eac3 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinition.java @@ -0,0 +1,278 @@ +/** + * 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.policy.v2019_01_01; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicyDefinitionInner; +import com.microsoft.azure.arm.model.Indexable; +import com.microsoft.azure.arm.model.Creatable; +import com.microsoft.azure.arm.model.Updatable; +import com.microsoft.azure.arm.model.Appliable; +import com.microsoft.azure.arm.model.Refreshable; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicyManager; + +/** + * Type representing PolicyDefinition. + */ +public interface PolicyDefinition extends HasInner, Indexable, Updatable, Refreshable, HasManager { + /** + * @return the description value. + */ + String description(); + + /** + * @return the displayName value. + */ + String displayName(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the metadata value. + */ + Object metadata(); + + /** + * @return the mode value. + */ + String mode(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the parameters value. + */ + Object parameters(); + + /** + * @return the policyRule value. + */ + Object policyRule(); + + /** + * @return the policyType value. + */ + PolicyType policyType(); + + /** + * @return the type value. + */ + String type(); + + /** + * The entirety of the PolicyDefinition definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithCreate { + } + + /** + * Grouping of PolicyDefinition definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a PolicyDefinition definition. + */ + interface Blank extends WithCreate { + } + + /** + * The stage of the policydefinition definition allowing to specify Description. + */ + interface WithDescription { + /** + * Specifies description. + * @param description The policy definition description + * @return the next definition stage + */ + WithCreate withDescription(String description); + } + + /** + * The stage of the policydefinition definition allowing to specify DisplayName. + */ + interface WithDisplayName { + /** + * Specifies displayName. + * @param displayName The display name of the policy definition + * @return the next definition stage + */ + WithCreate withDisplayName(String displayName); + } + + /** + * The stage of the policydefinition definition allowing to specify Metadata. + */ + interface WithMetadata { + /** + * Specifies metadata. + * @param metadata The policy definition metadata + * @return the next definition stage + */ + WithCreate withMetadata(Object metadata); + } + + /** + * The stage of the policydefinition definition allowing to specify Mode. + */ + interface WithMode { + /** + * Specifies mode. + * @param mode The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data + * @return the next definition stage + */ + WithCreate withMode(String mode); + } + + /** + * The stage of the policydefinition definition allowing to specify Parameters. + */ + interface WithParameters { + /** + * Specifies parameters. + * @param parameters Required if a parameter is used in policy rule + * @return the next definition stage + */ + WithCreate withParameters(Object parameters); + } + + /** + * The stage of the policydefinition definition allowing to specify PolicyRule. + */ + interface WithPolicyRule { + /** + * Specifies policyRule. + * @param policyRule The policy rule + * @return the next definition stage + */ + WithCreate withPolicyRule(Object policyRule); + } + + /** + * The stage of the policydefinition definition allowing to specify PolicyType. + */ + interface WithPolicyType { + /** + * Specifies policyType. + * @param policyType The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom' + * @return the next definition stage + */ + WithCreate withPolicyType(PolicyType policyType); + } + + /** + * 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.WithDescription, DefinitionStages.WithDisplayName, DefinitionStages.WithMetadata, DefinitionStages.WithMode, DefinitionStages.WithParameters, DefinitionStages.WithPolicyRule, DefinitionStages.WithPolicyType { + } + } + /** + * The template for a PolicyDefinition update operation, containing all the settings that can be modified. + */ + interface Update extends Appliable, UpdateStages.WithDescription, UpdateStages.WithDisplayName, UpdateStages.WithMetadata, UpdateStages.WithMode, UpdateStages.WithParameters, UpdateStages.WithPolicyRule, UpdateStages.WithPolicyType { + } + + /** + * Grouping of PolicyDefinition update stages. + */ + interface UpdateStages { + /** + * The stage of the policydefinition update allowing to specify Description. + */ + interface WithDescription { + /** + * Specifies description. + * @param description The policy definition description + * @return the next update stage + */ + Update withDescription(String description); + } + + /** + * The stage of the policydefinition update allowing to specify DisplayName. + */ + interface WithDisplayName { + /** + * Specifies displayName. + * @param displayName The display name of the policy definition + * @return the next update stage + */ + Update withDisplayName(String displayName); + } + + /** + * The stage of the policydefinition update allowing to specify Metadata. + */ + interface WithMetadata { + /** + * Specifies metadata. + * @param metadata The policy definition metadata + * @return the next update stage + */ + Update withMetadata(Object metadata); + } + + /** + * The stage of the policydefinition update allowing to specify Mode. + */ + interface WithMode { + /** + * Specifies mode. + * @param mode The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data + * @return the next update stage + */ + Update withMode(String mode); + } + + /** + * The stage of the policydefinition update allowing to specify Parameters. + */ + interface WithParameters { + /** + * Specifies parameters. + * @param parameters Required if a parameter is used in policy rule + * @return the next update stage + */ + Update withParameters(Object parameters); + } + + /** + * The stage of the policydefinition update allowing to specify PolicyRule. + */ + interface WithPolicyRule { + /** + * Specifies policyRule. + * @param policyRule The policy rule + * @return the next update stage + */ + Update withPolicyRule(Object policyRule); + } + + /** + * The stage of the policydefinition update allowing to specify PolicyType. + */ + interface WithPolicyType { + /** + * Specifies policyType. + * @param policyType The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom' + * @return the next update stage + */ + Update withPolicyType(PolicyType policyType); + } + + } +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinitionReference.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinitionReference.java new file mode 100644 index 0000000000000..e3d8274b6860d --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinitionReference.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.policy.v2019_01_01; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The policy definition reference. + */ +public class PolicyDefinitionReference { + /** + * The ID of the policy definition or policy set definition. + */ + @JsonProperty(value = "policyDefinitionId") + private String policyDefinitionId; + + /** + * Required if a parameter is used in policy rule. + */ + @JsonProperty(value = "parameters") + private Object parameters; + + /** + * Get the ID of the policy definition or policy set definition. + * + * @return the policyDefinitionId value + */ + public String policyDefinitionId() { + return this.policyDefinitionId; + } + + /** + * Set the ID of the policy definition or policy set definition. + * + * @param policyDefinitionId the policyDefinitionId value to set + * @return the PolicyDefinitionReference object itself. + */ + public PolicyDefinitionReference withPolicyDefinitionId(String policyDefinitionId) { + this.policyDefinitionId = policyDefinitionId; + return this; + } + + /** + * Get required if a parameter is used in policy rule. + * + * @return the parameters value + */ + public Object parameters() { + return this.parameters; + } + + /** + * Set required if a parameter is used in policy rule. + * + * @param parameters the parameters value to set + * @return the PolicyDefinitionReference object itself. + */ + public PolicyDefinitionReference withParameters(Object parameters) { + this.parameters = parameters; + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinitions.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinitions.java new file mode 100644 index 0000000000000..c81a8ba692d1b --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyDefinitions.java @@ -0,0 +1,106 @@ +/** + * 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.policy.v2019_01_01; + +import com.microsoft.azure.arm.collection.SupportsCreating; +import com.microsoft.azure.arm.collection.SupportsListing; +import rx.Completable; +import rx.Observable; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicyDefinitionInner; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicyDefinitionsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing PolicyDefinitions. + */ +public interface PolicyDefinitions extends SupportsCreating, SupportsListing, HasInner { + /** + * Deletes a policy definition in a subscription. + * This operation deletes the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Completable deleteAsync(String policyDefinitionName); + + /** + * Retrieves a policy definition in a subscription. + * This operation retrieves the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(String policyDefinitionName); + + /** + * Retrieves a built-in policy definition. + * This operation retrieves the built-in policy definition with the given name. + * + * @param policyDefinitionName The name of the built-in policy definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getBuiltInAsync(String policyDefinitionName); + + /** + * Creates or updates a policy definition in a management group. + * This operation creates or updates a policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable createOrUpdateAtManagementGroupAsync(String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters); + + /** + * Deletes a policy definition in a management group. + * This operation deletes the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Completable deleteAtManagementGroupAsync(String policyDefinitionName, String managementGroupId); + + /** + * Retrieve a policy definition in a management group. + * This operation retrieves the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAtManagementGroupAsync(String policyDefinitionName, String managementGroupId); + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByManagementGroupAsync(final String managementGroupId); + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listBuiltInAsync(); + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySetDefinition.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySetDefinition.java new file mode 100644 index 0000000000000..6c91e234cca8d --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySetDefinition.java @@ -0,0 +1,238 @@ +/** + * 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.policy.v2019_01_01; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicySetDefinitionInner; +import com.microsoft.azure.arm.model.Indexable; +import com.microsoft.azure.arm.model.Creatable; +import com.microsoft.azure.arm.model.Updatable; +import com.microsoft.azure.arm.model.Appliable; +import com.microsoft.azure.arm.model.Refreshable; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicyManager; +import java.util.List; + +/** + * Type representing PolicySetDefinition. + */ +public interface PolicySetDefinition extends HasInner, Indexable, Updatable, Refreshable, HasManager { + /** + * @return the description value. + */ + String description(); + + /** + * @return the displayName value. + */ + String displayName(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the metadata value. + */ + Object metadata(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the parameters value. + */ + Object parameters(); + + /** + * @return the policyDefinitions value. + */ + List policyDefinitions(); + + /** + * @return the policyType value. + */ + PolicyType policyType(); + + /** + * @return the type value. + */ + String type(); + + /** + * The entirety of the PolicySetDefinition definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithPolicyDefinitions, DefinitionStages.WithCreate { + } + + /** + * Grouping of PolicySetDefinition definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a PolicySetDefinition definition. + */ + interface Blank extends WithPolicyDefinitions { + } + + /** + * The stage of the policysetdefinition definition allowing to specify PolicyDefinitions. + */ + interface WithPolicyDefinitions { + /** + * Specifies policyDefinitions. + * @param policyDefinitions An array of policy definition references + * @return the next definition stage + */ + WithCreate withPolicyDefinitions(List policyDefinitions); + } + + /** + * The stage of the policysetdefinition definition allowing to specify Description. + */ + interface WithDescription { + /** + * Specifies description. + * @param description The policy set definition description + * @return the next definition stage + */ + WithCreate withDescription(String description); + } + + /** + * The stage of the policysetdefinition definition allowing to specify DisplayName. + */ + interface WithDisplayName { + /** + * Specifies displayName. + * @param displayName The display name of the policy set definition + * @return the next definition stage + */ + WithCreate withDisplayName(String displayName); + } + + /** + * The stage of the policysetdefinition definition allowing to specify Metadata. + */ + interface WithMetadata { + /** + * Specifies metadata. + * @param metadata The policy set definition metadata + * @return the next definition stage + */ + WithCreate withMetadata(Object metadata); + } + + /** + * The stage of the policysetdefinition definition allowing to specify Parameters. + */ + interface WithParameters { + /** + * Specifies parameters. + * @param parameters The policy set definition parameters that can be used in policy definition references + * @return the next definition stage + */ + WithCreate withParameters(Object parameters); + } + + /** + * The stage of the policysetdefinition definition allowing to specify PolicyType. + */ + interface WithPolicyType { + /** + * Specifies policyType. + * @param policyType The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom' + * @return the next definition stage + */ + WithCreate withPolicyType(PolicyType policyType); + } + + /** + * 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.WithDescription, DefinitionStages.WithDisplayName, DefinitionStages.WithMetadata, DefinitionStages.WithParameters, DefinitionStages.WithPolicyType { + } + } + /** + * The template for a PolicySetDefinition update operation, containing all the settings that can be modified. + */ + interface Update extends Appliable, UpdateStages.WithDescription, UpdateStages.WithDisplayName, UpdateStages.WithMetadata, UpdateStages.WithParameters, UpdateStages.WithPolicyType { + } + + /** + * Grouping of PolicySetDefinition update stages. + */ + interface UpdateStages { + /** + * The stage of the policysetdefinition update allowing to specify Description. + */ + interface WithDescription { + /** + * Specifies description. + * @param description The policy set definition description + * @return the next update stage + */ + Update withDescription(String description); + } + + /** + * The stage of the policysetdefinition update allowing to specify DisplayName. + */ + interface WithDisplayName { + /** + * Specifies displayName. + * @param displayName The display name of the policy set definition + * @return the next update stage + */ + Update withDisplayName(String displayName); + } + + /** + * The stage of the policysetdefinition update allowing to specify Metadata. + */ + interface WithMetadata { + /** + * Specifies metadata. + * @param metadata The policy set definition metadata + * @return the next update stage + */ + Update withMetadata(Object metadata); + } + + /** + * The stage of the policysetdefinition update allowing to specify Parameters. + */ + interface WithParameters { + /** + * Specifies parameters. + * @param parameters The policy set definition parameters that can be used in policy definition references + * @return the next update stage + */ + Update withParameters(Object parameters); + } + + /** + * The stage of the policysetdefinition update allowing to specify PolicyType. + */ + interface WithPolicyType { + /** + * Specifies policyType. + * @param policyType The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom' + * @return the next update stage + */ + Update withPolicyType(PolicyType policyType); + } + + } +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySetDefinitions.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySetDefinitions.java new file mode 100644 index 0000000000000..e50a4e380e269 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySetDefinitions.java @@ -0,0 +1,106 @@ +/** + * 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.policy.v2019_01_01; + +import com.microsoft.azure.arm.collection.SupportsCreating; +import com.microsoft.azure.arm.collection.SupportsListing; +import rx.Completable; +import rx.Observable; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicySetDefinitionInner; +import com.microsoft.azure.management.policy.v2019_01_01.implementation.PolicySetDefinitionsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing PolicySetDefinitions. + */ +public interface PolicySetDefinitions extends SupportsCreating, SupportsListing, HasInner { + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Completable deleteAsync(String policySetDefinitionName); + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(String policySetDefinitionName); + + /** + * Retrieves a built in policy set definition. + * This operation retrieves the built-in policy set definition with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getBuiltInAsync(String policySetDefinitionName); + + /** + * Creates or updates a policy set definition. + * This operation creates or updates a policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy set definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable createOrUpdateAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId, PolicySetDefinitionInner parameters); + + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Completable deleteAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId); + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId); + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByManagementGroupAsync(final String managementGroupId); + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listBuiltInAsync(); + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySku.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySku.java new file mode 100644 index 0000000000000..d0712cbe8606e --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicySku.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.policy.v2019_01_01; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The policy sku. This property is optional, obsolete, and will be ignored. + */ +public class PolicySku { + /** + * The name of the policy sku. Possible values are A0 and A1. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * The policy sku tier. Possible values are Free and Standard. + */ + @JsonProperty(value = "tier") + private String tier; + + /** + * Get the name of the policy sku. Possible values are A0 and A1. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name of the policy sku. Possible values are A0 and A1. + * + * @param name the name value to set + * @return the PolicySku object itself. + */ + public PolicySku withName(String name) { + this.name = name; + return this; + } + + /** + * Get the policy sku tier. Possible values are Free and Standard. + * + * @return the tier value + */ + public String tier() { + return this.tier; + } + + /** + * Set the policy sku tier. Possible values are Free and Standard. + * + * @param tier the tier value to set + * @return the PolicySku object itself. + */ + public PolicySku withTier(String tier) { + this.tier = tier; + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyType.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyType.java new file mode 100644 index 0000000000000..8dded63d019de --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/PolicyType.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.policy.v2019_01_01; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for PolicyType. + */ +public final class PolicyType extends ExpandableStringEnum { + /** Static value NotSpecified for PolicyType. */ + public static final PolicyType NOT_SPECIFIED = fromString("NotSpecified"); + + /** Static value BuiltIn for PolicyType. */ + public static final PolicyType BUILT_IN = fromString("BuiltIn"); + + /** Static value Custom for PolicyType. */ + public static final PolicyType CUSTOM = fromString("Custom"); + + /** + * Creates or finds a PolicyType from its string representation. + * @param name a name to look for + * @return the corresponding PolicyType + */ + @JsonCreator + public static PolicyType fromString(String name) { + return fromString(name, PolicyType.class); + } + + /** + * @return known PolicyType values + */ + public static Collection values() { + return values(PolicyType.class); + } +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ResourceIdentityType.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ResourceIdentityType.java new file mode 100644 index 0000000000000..37a8699009bab --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/ResourceIdentityType.java @@ -0,0 +1,53 @@ +/** + * 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.policy.v2019_01_01; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for ResourceIdentityType. + */ +public enum ResourceIdentityType { + /** Enum value SystemAssigned. */ + SYSTEM_ASSIGNED("SystemAssigned"), + + /** Enum value None. */ + NONE("None"); + + /** The actual serialized value for a ResourceIdentityType instance. */ + private String value; + + ResourceIdentityType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ResourceIdentityType instance. + * + * @param value the serialized value to parse. + * @return the parsed ResourceIdentityType object, or null if unable to parse. + */ + @JsonCreator + public static ResourceIdentityType fromString(String value) { + ResourceIdentityType[] items = ResourceIdentityType.values(); + for (ResourceIdentityType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/IdParsingUtils.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/IdParsingUtils.java new file mode 100644 index 0000000000000..72fd6a90d50b9 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/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.policy.v2019_01_01.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/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PageImpl.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PageImpl.java new file mode 100644 index 0000000000000..e879fe27cd886 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/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.policy.v2019_01_01.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/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentImpl.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentImpl.java new file mode 100644 index 0000000000000..16f13c1fd2cc6 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentImpl.java @@ -0,0 +1,205 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import com.microsoft.azure.management.policy.v2019_01_01.PolicyAssignment; +import com.microsoft.azure.arm.model.implementation.CreatableUpdatableImpl; +import rx.Observable; +import java.util.List; +import com.microsoft.azure.management.policy.v2019_01_01.PolicySku; +import com.microsoft.azure.management.policy.v2019_01_01.Identity; + +class PolicyAssignmentImpl extends CreatableUpdatableImpl implements PolicyAssignment, PolicyAssignment.Definition, PolicyAssignment.Update { + private String scope; + private String policyAssignmentName; + private final PolicyManager manager; + + PolicyAssignmentImpl(String name, PolicyManager manager) { + super(name, new PolicyAssignmentInner()); + this.manager = manager; + // Set resource name + this.policyAssignmentName = name; + // + } + + PolicyAssignmentImpl(PolicyAssignmentInner inner, PolicyManager manager) { + super(inner.name(), inner); + this.manager = manager; + // Set resource name + this.policyAssignmentName = inner.name(); + // set resource ancestor and positional variables + this.policyAssignmentName = IdParsingUtils.getValueFromIdByName(inner.id(), "policyAssignments"); + this.scope = IdParsingUtils.getValueFromIdByPosition(inner.id(), 0); + // set other parameters for create and update + } + + @Override + public PolicyManager manager() { + return this.manager; + } + + @Override + public Observable createResourceAsync() { + PolicyAssignmentsInner client = this.manager().inner().policyAssignments(); + return client.createAsync(this.scope, this.policyAssignmentName, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + public Observable updateResourceAsync() { + PolicyAssignmentsInner client = this.manager().inner().policyAssignments(); + return client.createAsync(this.scope, this.policyAssignmentName, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + protected Observable getInnerAsync() { + PolicyAssignmentsInner client = this.manager().inner().policyAssignments(); + return client.getAsync(this.scope, this.policyAssignmentName); + } + + @Override + public boolean isInCreateMode() { + return this.inner().id() == null; + } + + + @Override + public String description() { + return this.inner().description(); + } + + @Override + public String displayName() { + return this.inner().displayName(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public Identity identity() { + return this.inner().identity(); + } + + @Override + public String location() { + return this.inner().location(); + } + + @Override + public Object metadata() { + return this.inner().metadata(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public List notScopes() { + return this.inner().notScopes(); + } + + @Override + public Object parameters() { + return this.inner().parameters(); + } + + @Override + public String policyDefinitionId() { + return this.inner().policyDefinitionId(); + } + + @Override + public String scopeProperty() { + return this.inner().scopeProperty(); + } + + @Override + public PolicySku sku() { + return this.inner().sku(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public PolicyAssignmentImpl withScope(String scope) { + this.scope = scope; + return this; + } + + @Override + public PolicyAssignmentImpl withDescription(String description) { + this.inner().withDescription(description); + return this; + } + + @Override + public PolicyAssignmentImpl withDisplayName(String displayName) { + this.inner().withDisplayName(displayName); + return this; + } + + @Override + public PolicyAssignmentImpl withIdentity(Identity identity) { + this.inner().withIdentity(identity); + return this; + } + + @Override + public PolicyAssignmentImpl withLocation(String location) { + this.inner().withLocation(location); + return this; + } + + @Override + public PolicyAssignmentImpl withMetadata(Object metadata) { + this.inner().withMetadata(metadata); + return this; + } + + @Override + public PolicyAssignmentImpl withNotScopes(List notScopes) { + this.inner().withNotScopes(notScopes); + return this; + } + + @Override + public PolicyAssignmentImpl withParameters(Object parameters) { + this.inner().withParameters(parameters); + return this; + } + + @Override + public PolicyAssignmentImpl withPolicyDefinitionId(String policyDefinitionId) { + this.inner().withPolicyDefinitionId(policyDefinitionId); + return this; + } + + @Override + public PolicyAssignmentImpl withScopeProperty(String scopeProperty) { + this.inner().withScopeProperty(scopeProperty); + return this; + } + + @Override + public PolicyAssignmentImpl withSku(PolicySku sku) { + this.inner().withSku(sku); + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentInner.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentInner.java new file mode 100644 index 0000000000000..3efad60de8763 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentInner.java @@ -0,0 +1,285 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import java.util.List; +import com.microsoft.azure.management.policy.v2019_01_01.PolicySku; +import com.microsoft.azure.management.policy.v2019_01_01.Identity; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * The policy assignment. + */ +@JsonFlatten +public class PolicyAssignmentInner extends ProxyResource { + /** + * The display name of the policy assignment. + */ + @JsonProperty(value = "properties.displayName") + private String displayName; + + /** + * The ID of the policy definition or policy set definition being assigned. + */ + @JsonProperty(value = "properties.policyDefinitionId") + private String policyDefinitionId; + + /** + * The scope for the policy assignment. + */ + @JsonProperty(value = "properties.scope") + private String scopeProperty; + + /** + * The policy's excluded scopes. + */ + @JsonProperty(value = "properties.notScopes") + private List notScopes; + + /** + * Required if a parameter is used in policy rule. + */ + @JsonProperty(value = "properties.parameters") + private Object parameters; + + /** + * This message will be part of response in case of policy violation. + */ + @JsonProperty(value = "properties.description") + private String description; + + /** + * The policy assignment metadata. + */ + @JsonProperty(value = "properties.metadata") + private Object metadata; + + /** + * The policy sku. This property is optional, obsolete, and will be + * ignored. + */ + @JsonProperty(value = "sku") + private PolicySku sku; + + /** + * The location of the policy assignment. Only required when utilizing + * managed identity. + */ + @JsonProperty(value = "location") + private String location; + + /** + * The managed identity associated with the policy assignment. + */ + @JsonProperty(value = "identity") + private Identity identity; + + /** + * Get the display name of the policy assignment. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the display name of the policy assignment. + * + * @param displayName the displayName value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the ID of the policy definition or policy set definition being assigned. + * + * @return the policyDefinitionId value + */ + public String policyDefinitionId() { + return this.policyDefinitionId; + } + + /** + * Set the ID of the policy definition or policy set definition being assigned. + * + * @param policyDefinitionId the policyDefinitionId value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withPolicyDefinitionId(String policyDefinitionId) { + this.policyDefinitionId = policyDefinitionId; + return this; + } + + /** + * Get the scope for the policy assignment. + * + * @return the scopeProperty value + */ + public String scopeProperty() { + return this.scopeProperty; + } + + /** + * Set the scope for the policy assignment. + * + * @param scopeProperty the scopeProperty value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withScopeProperty(String scopeProperty) { + this.scopeProperty = scopeProperty; + return this; + } + + /** + * Get the policy's excluded scopes. + * + * @return the notScopes value + */ + public List notScopes() { + return this.notScopes; + } + + /** + * Set the policy's excluded scopes. + * + * @param notScopes the notScopes value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withNotScopes(List notScopes) { + this.notScopes = notScopes; + return this; + } + + /** + * Get required if a parameter is used in policy rule. + * + * @return the parameters value + */ + public Object parameters() { + return this.parameters; + } + + /** + * Set required if a parameter is used in policy rule. + * + * @param parameters the parameters value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withParameters(Object parameters) { + this.parameters = parameters; + return this; + } + + /** + * Get this message will be part of response in case of policy violation. + * + * @return the description value + */ + public String description() { + return this.description; + } + + /** + * Set this message will be part of response in case of policy violation. + * + * @param description the description value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the policy assignment metadata. + * + * @return the metadata value + */ + public Object metadata() { + return this.metadata; + } + + /** + * Set the policy assignment metadata. + * + * @param metadata the metadata value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withMetadata(Object metadata) { + this.metadata = metadata; + return this; + } + + /** + * Get the policy sku. This property is optional, obsolete, and will be ignored. + * + * @return the sku value + */ + public PolicySku sku() { + return this.sku; + } + + /** + * Set the policy sku. This property is optional, obsolete, and will be ignored. + * + * @param sku the sku value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withSku(PolicySku sku) { + this.sku = sku; + return this; + } + + /** + * Get the location of the policy assignment. Only required when utilizing managed identity. + * + * @return the location value + */ + public String location() { + return this.location; + } + + /** + * Set the location of the policy assignment. Only required when utilizing managed identity. + * + * @param location the location value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withLocation(String location) { + this.location = location; + return this; + } + + /** + * Get the managed identity associated with the policy assignment. + * + * @return the identity value + */ + public Identity identity() { + return this.identity; + } + + /** + * Set the managed identity associated with the policy assignment. + * + * @param identity the identity value to set + * @return the PolicyAssignmentInner object itself. + */ + public PolicyAssignmentInner withIdentity(Identity identity) { + this.identity = identity; + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentsImpl.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentsImpl.java new file mode 100644 index 0000000000000..2686ec7800e74 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentsImpl.java @@ -0,0 +1,179 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.policy.v2019_01_01.PolicyAssignments; +import rx.Observable; +import rx.functions.Func1; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.Page; +import com.microsoft.azure.management.policy.v2019_01_01.PolicyAssignment; +import com.microsoft.azure.arm.utils.PagedListConverter; + +class PolicyAssignmentsImpl extends WrapperImpl implements PolicyAssignments { + private PagedListConverter converter; + private final PolicyManager manager; + + PolicyAssignmentsImpl(PolicyManager manager) { + super(manager.inner().policyAssignments()); + this.manager = manager; + this.converter = new PagedListConverter() { + @Override + public Observable typeConvertAsync(PolicyAssignmentInner inner) { + return Observable.just((PolicyAssignment) wrapModel(inner)); + } + }; + } + + public PolicyManager manager() { + return this.manager; + } + + @Override + public PolicyAssignmentImpl define(String name) { + return wrapModel(name); + } + + private PolicyAssignmentImpl wrapModel(PolicyAssignmentInner inner) { + return new PolicyAssignmentImpl(inner, manager()); + } + + private PolicyAssignmentImpl wrapModel(String name) { + return new PolicyAssignmentImpl(name, this.manager()); + } + + @Override + public Observable deleteAsync(String scope, String policyAssignmentName) { + PolicyAssignmentsInner client = this.inner(); + return client.deleteAsync(scope, policyAssignmentName) + .map(new Func1() { + @Override + public PolicyAssignment call(PolicyAssignmentInner inner) { + return new PolicyAssignmentImpl(inner, manager()); + } + }); + } + + @Override + public Observable getAsync(String scope, String policyAssignmentName) { + PolicyAssignmentsInner client = this.inner(); + return client.getAsync(scope, policyAssignmentName) + .map(new Func1() { + @Override + public PolicyAssignment call(PolicyAssignmentInner inner) { + return new PolicyAssignmentImpl(inner, manager()); + } + }); + } + + @Override + public Observable listForResourceAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName) { + PolicyAssignmentsInner client = this.inner(); + return client.listForResourceAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public PolicyAssignment call(PolicyAssignmentInner inner) { + return new PolicyAssignmentImpl(inner, manager()); + } + }); + } + + @Override + public Observable deleteByIdAsync(String policyAssignmentId) { + PolicyAssignmentsInner client = this.inner(); + return client.deleteByIdAsync(policyAssignmentId) + .map(new Func1() { + @Override + public PolicyAssignment call(PolicyAssignmentInner inner) { + return new PolicyAssignmentImpl(inner, manager()); + } + }); + } + + @Override + public Observable createByIdAsync(String policyAssignmentId, PolicyAssignmentInner parameters) { + PolicyAssignmentsInner client = this.inner(); + return client.createByIdAsync(policyAssignmentId, parameters) + .map(new Func1() { + @Override + public PolicyAssignment call(PolicyAssignmentInner inner) { + return new PolicyAssignmentImpl(inner, manager()); + } + }); + } + + @Override + public Observable getByIdAsync(String policyAssignmentId) { + PolicyAssignmentsInner client = this.inner(); + return client.getByIdAsync(policyAssignmentId) + .map(new Func1() { + @Override + public PolicyAssignment call(PolicyAssignmentInner inner) { + return new PolicyAssignmentImpl(inner, manager()); + } + }); + } + + @Override + public PagedList list() { + PolicyAssignmentsInner client = this.inner(); + return converter.convert(client.list()); + } + + @Override + public Observable listAsync() { + PolicyAssignmentsInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public PolicyAssignment call(PolicyAssignmentInner inner) { + return wrapModel(inner); + } + }); + } + + @Override + public PagedList listByResourceGroup(String resourceGroupName) { + PolicyAssignmentsInner client = this.inner(); + return converter.convert(client.listByResourceGroup(resourceGroupName)); + } + + @Override + public Observable listByResourceGroupAsync(String resourceGroupName) { + PolicyAssignmentsInner client = this.inner(); + return client.listByResourceGroupAsync(resourceGroupName) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public PolicyAssignment call(PolicyAssignmentInner inner) { + return wrapModel(inner); + } + }); + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentsInner.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentsInner.java new file mode 100644 index 0000000000000..c21376ad3fe56 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyAssignmentsInner.java @@ -0,0 +1,1748 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import com.microsoft.azure.arm.collection.InnerSupportsDelete; +import com.microsoft.azure.arm.collection.InnerSupportsListing; +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.policy.v2019_01_01.ErrorResponseException; +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.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 PolicyAssignments. + */ +public class PolicyAssignmentsInner implements InnerSupportsDelete, InnerSupportsListing { + /** The Retrofit service to perform REST calls. */ + private PolicyAssignmentsService service; + /** The service client containing this operation class. */ + private PolicyClientImpl client; + + /** + * Initializes an instance of PolicyAssignmentsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public PolicyAssignmentsInner(Retrofit retrofit, PolicyClientImpl client) { + this.service = retrofit.create(PolicyAssignmentsService.class); + this.client = client; + } + + /** + * The interface defining all the services for PolicyAssignments to be + * used by Retrofit to perform actually REST calls. + */ + interface PolicyAssignmentsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.policy.v2019_01_01.PolicyAssignments delete" }) + @HTTP(path = "{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}", method = "DELETE", hasBody = true) + Observable> delete(@Path(value = "scope", encoded = true) String scope, @Path("policyAssignmentName") String policyAssignmentName, @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.policy.v2019_01_01.PolicyAssignments create" }) + @PUT("{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + Observable> create(@Path(value = "scope", encoded = true) String scope, @Path("policyAssignmentName") String policyAssignmentName, @Body PolicyAssignmentInner parameters, @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.policy.v2019_01_01.PolicyAssignments get" }) + @GET("{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + Observable> get(@Path(value = "scope", encoded = true) String scope, @Path("policyAssignmentName") String policyAssignmentName, @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.policy.v2019_01_01.PolicyAssignments listByResourceGroup" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") + Observable> listByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query(value = "$filter", encoded = true) String filter, @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.policy.v2019_01_01.PolicyAssignments listForResource" }) + @GET("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") + Observable> listForResource(@Path("resourceGroupName") String resourceGroupName, @Path("resourceProviderNamespace") String resourceProviderNamespace, @Path(value = "parentResourcePath", encoded = true) String parentResourcePath, @Path(value = "resourceType", encoded = true) String resourceType, @Path("resourceName") String resourceName, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @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.policy.v2019_01_01.PolicyAssignments list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + Observable> list(@Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @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.policy.v2019_01_01.PolicyAssignments deleteById" }) + @HTTP(path = "{policyAssignmentId}", method = "DELETE", hasBody = true) + Observable> deleteById(@Path(value = "policyAssignmentId", encoded = true) String policyAssignmentId, @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.policy.v2019_01_01.PolicyAssignments createById" }) + @PUT("{policyAssignmentId}") + Observable> createById(@Path(value = "policyAssignmentId", encoded = true) String policyAssignmentId, @Body PolicyAssignmentInner parameters, @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.policy.v2019_01_01.PolicyAssignments getById" }) + @GET("{policyAssignmentId}") + Observable> getById(@Path(value = "policyAssignmentId", encoded = true) String policyAssignmentId, @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.policy.v2019_01_01.PolicyAssignments listByResourceGroupNext" }) + @GET + Observable> listByResourceGroupNext(@Url String nextUrl, @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.policy.v2019_01_01.PolicyAssignments listForResourceNext" }) + @GET + Observable> listForResourceNext(@Url String nextUrl, @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.policy.v2019_01_01.PolicyAssignments listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Deletes a policy assignment. + * This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicyAssignmentInner object if successful. + */ + public PolicyAssignmentInner delete(String scope, String policyAssignmentName) { + return deleteWithServiceResponseAsync(scope, policyAssignmentName).toBlocking().single().body(); + } + + /** + * Deletes a policy assignment. + * This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to delete. + * @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 scope, String policyAssignmentName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(scope, policyAssignmentName), serviceCallback); + } + + /** + * Deletes a policy assignment. + * This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable deleteAsync(String scope, String policyAssignmentName) { + return deleteWithServiceResponseAsync(scope, policyAssignmentName).map(new Func1, PolicyAssignmentInner>() { + @Override + public PolicyAssignmentInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes a policy assignment. + * This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable> deleteWithServiceResponseAsync(String scope, String policyAssignmentName) { + if (scope == null) { + throw new IllegalArgumentException("Parameter scope is required and cannot be null."); + } + if (policyAssignmentName == null) { + throw new IllegalArgumentException("Parameter policyAssignmentName 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(scope, policyAssignmentName, 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 ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Creates or updates a policy assignment. + * This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment. + * @param parameters Parameters for the policy assignment. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicyAssignmentInner object if successful. + */ + public PolicyAssignmentInner create(String scope, String policyAssignmentName, PolicyAssignmentInner parameters) { + return createWithServiceResponseAsync(scope, policyAssignmentName, parameters).toBlocking().single().body(); + } + + /** + * Creates or updates a policy assignment. + * This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment. + * @param parameters Parameters for the policy assignment. + * @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 scope, String policyAssignmentName, PolicyAssignmentInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(scope, policyAssignmentName, parameters), serviceCallback); + } + + /** + * Creates or updates a policy assignment. + * This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment. + * @param parameters Parameters for the policy assignment. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable createAsync(String scope, String policyAssignmentName, PolicyAssignmentInner parameters) { + return createWithServiceResponseAsync(scope, policyAssignmentName, parameters).map(new Func1, PolicyAssignmentInner>() { + @Override + public PolicyAssignmentInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates a policy assignment. + * This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment. + * @param parameters Parameters for the policy assignment. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable> createWithServiceResponseAsync(String scope, String policyAssignmentName, PolicyAssignmentInner parameters) { + if (scope == null) { + throw new IllegalArgumentException("Parameter scope is required and cannot be null."); + } + if (policyAssignmentName == null) { + throw new IllegalArgumentException("Parameter policyAssignmentName is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters 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(parameters); + return service.create(scope, policyAssignmentName, parameters, 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 ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(201, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves a policy assignment. + * This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicyAssignmentInner object if successful. + */ + public PolicyAssignmentInner get(String scope, String policyAssignmentName) { + return getWithServiceResponseAsync(scope, policyAssignmentName).toBlocking().single().body(); + } + + /** + * Retrieves a policy assignment. + * This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to get. + * @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 scope, String policyAssignmentName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(scope, policyAssignmentName), serviceCallback); + } + + /** + * Retrieves a policy assignment. + * This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable getAsync(String scope, String policyAssignmentName) { + return getWithServiceResponseAsync(scope, policyAssignmentName).map(new Func1, PolicyAssignmentInner>() { + @Override + public PolicyAssignmentInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieves a policy assignment. + * This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @param scope The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + * @param policyAssignmentName The name of the policy assignment to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable> getWithServiceResponseAsync(String scope, String policyAssignmentName) { + if (scope == null) { + throw new IllegalArgumentException("Parameter scope is required and cannot be null."); + } + if (policyAssignmentName == null) { + throw new IllegalArgumentException("Parameter policyAssignmentName 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(scope, policyAssignmentName, 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 ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param resourceGroupName The name of the resource group that contains policy assignments. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicyAssignmentInner> object if successful. + */ + public PagedList listByResourceGroup(final String resourceGroupName) { + ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param resourceGroupName The name of the resource group that contains policy assignments. + * @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> listByResourceGroupAsync(final String resourceGroupName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByResourceGroupSinglePageAsync(resourceGroupName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param resourceGroupName The name of the resource group that contains policy assignments. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable> listByResourceGroupAsync(final String resourceGroupName) { + return listByResourceGroupWithServiceResponseAsync(resourceGroupName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param resourceGroupName The name of the resource group that contains policy assignments. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName) { + return listByResourceGroupSinglePageAsync(resourceGroupName) + .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(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param resourceGroupName The name of the resource group that contains policy assignments. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyAssignmentInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByResourceGroupSinglePageAsync(final String resourceGroupName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + 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; + return service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByResourceGroupDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param resourceGroupName The name of the resource group that contains policy assignments. + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicyAssignmentInner> object if successful. + */ + public PagedList listByResourceGroup(final String resourceGroupName, final String filter) { + ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName, filter).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param resourceGroupName The name of the resource group that contains policy assignments. + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @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> listByResourceGroupAsync(final String resourceGroupName, final String filter, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByResourceGroupSinglePageAsync(resourceGroupName, filter), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param resourceGroupName The name of the resource group that contains policy assignments. + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable> listByResourceGroupAsync(final String resourceGroupName, final String filter) { + return listByResourceGroupWithServiceResponseAsync(resourceGroupName, filter) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param resourceGroupName The name of the resource group that contains policy assignments. + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName, final String filter) { + return listByResourceGroupSinglePageAsync(resourceGroupName, filter) + .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(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + ServiceResponse> * @param resourceGroupName The name of the resource group that contains policy assignments. + ServiceResponse> * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyAssignmentInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByResourceGroupSinglePageAsync(final String resourceGroupName, final String filter) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + 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.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByResourceGroupDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByResourceGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicyAssignmentInner> object if successful. + */ + public PagedList listForResource(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName) { + ServiceResponse> response = listForResourceSinglePageAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listForResourceNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @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> listForResourceAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listForResourceSinglePageAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listForResourceNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable> listForResourceAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName) { + return listForResourceWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable>> listForResourceWithServiceResponseAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName) { + return listForResourceSinglePageAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) + .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(listForResourceNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyAssignmentInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listForResourceSinglePageAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (resourceProviderNamespace == null) { + throw new IllegalArgumentException("Parameter resourceProviderNamespace is required and cannot be null."); + } + if (parentResourcePath == null) { + throw new IllegalArgumentException("Parameter parentResourcePath is required and cannot be null."); + } + if (resourceType == null) { + throw new IllegalArgumentException("Parameter resourceType is required and cannot be null."); + } + if (resourceName == null) { + throw new IllegalArgumentException("Parameter resourceName is required and cannot be null."); + } + 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; + return service.listForResource(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, this.client.subscriptionId(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listForResourceDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicyAssignmentInner> object if successful. + */ + public PagedList listForResource(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName, final String filter) { + ServiceResponse> response = listForResourceSinglePageAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listForResourceNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @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> listForResourceAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName, final String filter, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listForResourceSinglePageAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listForResourceNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable> listForResourceAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName, final String filter) { + return listForResourceWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param resourceGroupName The name of the resource group containing the resource. + * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + * @param parentResourcePath The parent resource path. Use empty string if there is none. + * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + * @param resourceName The name of the resource. + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable>> listForResourceWithServiceResponseAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName, final String filter) { + return listForResourceSinglePageAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) + .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(listForResourceNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + ServiceResponse> * @param resourceGroupName The name of the resource group containing the resource. + ServiceResponse> * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) + ServiceResponse> * @param parentResourcePath The parent resource path. Use empty string if there is none. + ServiceResponse> * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). + ServiceResponse> * @param resourceName The name of the resource. + ServiceResponse> * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyAssignmentInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listForResourceSinglePageAsync(final String resourceGroupName, final String resourceProviderNamespace, final String parentResourcePath, final String resourceType, final String resourceName, final String filter) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (resourceProviderNamespace == null) { + throw new IllegalArgumentException("Parameter resourceProviderNamespace is required and cannot be null."); + } + if (parentResourcePath == null) { + throw new IllegalArgumentException("Parameter parentResourcePath is required and cannot be null."); + } + if (resourceType == null) { + throw new IllegalArgumentException("Parameter resourceType is required and cannot be null."); + } + if (resourceName == null) { + throw new IllegalArgumentException("Parameter resourceName is required and cannot be null."); + } + 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.listForResource(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, this.client.subscriptionId(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listForResourceDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listForResourceDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicyAssignmentInner> 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(); + } + }; + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @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); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> 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)); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyAssignmentInner> 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; + return service.list(this.client.subscriptionId(), filter, 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); + } + } + }); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicyAssignmentInner> object if successful. + */ + public PagedList list(final String filter) { + ServiceResponse> response = listSinglePageAsync(filter).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @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 ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(filter), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable> listAsync(final String filter) { + return listWithServiceResponseAsync(filter) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyAssignmentInner> object + */ + public Observable>> listWithServiceResponseAsync(final String filter) { + return listSinglePageAsync(filter) + .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)); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + ServiceResponse> * @param filter The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyAssignmentInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String filter) { + 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(), filter, 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 ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Deletes a policy assignment. + * This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * + * @param policyAssignmentId The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicyAssignmentInner object if successful. + */ + public PolicyAssignmentInner deleteById(String policyAssignmentId) { + return deleteByIdWithServiceResponseAsync(policyAssignmentId).toBlocking().single().body(); + } + + /** + * Deletes a policy assignment. + * This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * + * @param policyAssignmentId The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @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 deleteByIdAsync(String policyAssignmentId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteByIdWithServiceResponseAsync(policyAssignmentId), serviceCallback); + } + + /** + * Deletes a policy assignment. + * This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * + * @param policyAssignmentId The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable deleteByIdAsync(String policyAssignmentId) { + return deleteByIdWithServiceResponseAsync(policyAssignmentId).map(new Func1, PolicyAssignmentInner>() { + @Override + public PolicyAssignmentInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes a policy assignment. + * This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * + * @param policyAssignmentId The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable> deleteByIdWithServiceResponseAsync(String policyAssignmentId) { + if (policyAssignmentId == null) { + throw new IllegalArgumentException("Parameter policyAssignmentId 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.deleteById(policyAssignmentId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteByIdDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteByIdDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Creates or updates a policy assignment. + * This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @param parameters Parameters for policy assignment. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicyAssignmentInner object if successful. + */ + public PolicyAssignmentInner createById(String policyAssignmentId, PolicyAssignmentInner parameters) { + return createByIdWithServiceResponseAsync(policyAssignmentId, parameters).toBlocking().single().body(); + } + + /** + * Creates or updates a policy assignment. + * This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @param parameters Parameters for policy assignment. + * @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 createByIdAsync(String policyAssignmentId, PolicyAssignmentInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createByIdWithServiceResponseAsync(policyAssignmentId, parameters), serviceCallback); + } + + /** + * Creates or updates a policy assignment. + * This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @param parameters Parameters for policy assignment. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable createByIdAsync(String policyAssignmentId, PolicyAssignmentInner parameters) { + return createByIdWithServiceResponseAsync(policyAssignmentId, parameters).map(new Func1, PolicyAssignmentInner>() { + @Override + public PolicyAssignmentInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates a policy assignment. + * This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @param parameters Parameters for policy assignment. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable> createByIdWithServiceResponseAsync(String policyAssignmentId, PolicyAssignmentInner parameters) { + if (policyAssignmentId == null) { + throw new IllegalArgumentException("Parameter policyAssignmentId is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters 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(parameters); + return service.createById(policyAssignmentId, parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createByIdDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createByIdDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(201, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves the policy assignment with the given ID. + * The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicyAssignmentInner object if successful. + */ + public PolicyAssignmentInner getById(String policyAssignmentId) { + return getByIdWithServiceResponseAsync(policyAssignmentId).toBlocking().single().body(); + } + + /** + * Retrieves the policy assignment with the given ID. + * The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @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 getByIdAsync(String policyAssignmentId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getByIdWithServiceResponseAsync(policyAssignmentId), serviceCallback); + } + + /** + * Retrieves the policy assignment with the given ID. + * The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable getByIdAsync(String policyAssignmentId) { + return getByIdWithServiceResponseAsync(policyAssignmentId).map(new Func1, PolicyAssignmentInner>() { + @Override + public PolicyAssignmentInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieves the policy assignment with the given ID. + * The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @param policyAssignmentId The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyAssignmentInner object + */ + public Observable> getByIdWithServiceResponseAsync(String policyAssignmentId) { + if (policyAssignmentId == null) { + throw new IllegalArgumentException("Parameter policyAssignmentId 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.getById(policyAssignmentId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getByIdDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getByIdDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicyAssignmentInner> object if successful. + */ + public PagedList listByResourceGroupNext(final String nextPageLink) { + ServiceResponse> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @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> listByResourceGroupNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByResourceGroupNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @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<PolicyAssignmentInner> object + */ + public Observable> listByResourceGroupNextAsync(final String nextPageLink) { + return listByResourceGroupNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @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<PolicyAssignmentInner> object + */ + public Observable>> listByResourceGroupNextWithServiceResponseAsync(final String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(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(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource group. + * This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyAssignmentInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByResourceGroupNextSinglePageAsync(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.listByResourceGroupNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByResourceGroupNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByResourceGroupNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicyAssignmentInner> object if successful. + */ + public PagedList listForResourceNext(final String nextPageLink) { + ServiceResponse> response = listForResourceNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listForResourceNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @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> listForResourceNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listForResourceNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listForResourceNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @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<PolicyAssignmentInner> object + */ + public Observable> listForResourceNextAsync(final String nextPageLink) { + return listForResourceNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @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<PolicyAssignmentInner> object + */ + public Observable>> listForResourceNextWithServiceResponseAsync(final String nextPageLink) { + return listForResourceNextSinglePageAsync(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(listForResourceNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a resource. + * This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyAssignmentInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listForResourceNextSinglePageAsync(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.listForResourceNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listForResourceNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listForResourceNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicyAssignmentInner> 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(); + } + }; + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @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); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @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<PolicyAssignmentInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @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<PolicyAssignmentInner> 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)); + } + }); + } + + /** + * Retrieves all policy assignments that apply to a subscription. + * This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyAssignmentInner> 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 ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyClientImpl.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyClientImpl.java new file mode 100644 index 0000000000000..b4f8f6056f5c2 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyClientImpl.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.policy.v2019_01_01.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 PolicyClientImpl class. + */ +public class PolicyClientImpl 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 ID of the target subscription. */ + private String subscriptionId; + + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Sets The ID of the target subscription. + * + * @param subscriptionId the subscriptionId value. + * @return the service client itself + */ + public PolicyClientImpl withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** The API version to use for the operation. */ + private String apiVersion; + + /** + * Gets The API version to use for the operation. + * + * @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 PolicyClientImpl 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 PolicyClientImpl 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 PolicyClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The PolicyAssignmentsInner object to access its operations. + */ + private PolicyAssignmentsInner policyAssignments; + + /** + * Gets the PolicyAssignmentsInner object to access its operations. + * @return the PolicyAssignmentsInner object. + */ + public PolicyAssignmentsInner policyAssignments() { + return this.policyAssignments; + } + + /** + * The PolicyDefinitionsInner object to access its operations. + */ + private PolicyDefinitionsInner policyDefinitions; + + /** + * Gets the PolicyDefinitionsInner object to access its operations. + * @return the PolicyDefinitionsInner object. + */ + public PolicyDefinitionsInner policyDefinitions() { + return this.policyDefinitions; + } + + /** + * The PolicySetDefinitionsInner object to access its operations. + */ + private PolicySetDefinitionsInner policySetDefinitions; + + /** + * Gets the PolicySetDefinitionsInner object to access its operations. + * @return the PolicySetDefinitionsInner object. + */ + public PolicySetDefinitionsInner policySetDefinitions() { + return this.policySetDefinitions; + } + + /** + * Initializes an instance of PolicyClient client. + * + * @param credentials the management credentials for Azure + */ + public PolicyClientImpl(ServiceClientCredentials credentials) { + this("https://management.azure.com", credentials); + } + + /** + * Initializes an instance of PolicyClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public PolicyClientImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of PolicyClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public PolicyClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2019-01-01"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.policyAssignments = new PolicyAssignmentsInner(restClient().retrofit(), this); + this.policyDefinitions = new PolicyDefinitionsInner(restClient().retrofit(), this); + this.policySetDefinitions = new PolicySetDefinitionsInner(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(), "PolicyClient", "2019-01-01"); + } +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionImpl.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionImpl.java new file mode 100644 index 0000000000000..c47fe56e15ab7 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionImpl.java @@ -0,0 +1,162 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import com.microsoft.azure.management.policy.v2019_01_01.PolicyDefinition; +import com.microsoft.azure.arm.model.implementation.CreatableUpdatableImpl; +import rx.Observable; +import com.microsoft.azure.management.policy.v2019_01_01.PolicyType; + +class PolicyDefinitionImpl extends CreatableUpdatableImpl implements PolicyDefinition, PolicyDefinition.Definition, PolicyDefinition.Update { + private String policyDefinitionName; + private final PolicyManager manager; + + PolicyDefinitionImpl(String name, PolicyManager manager) { + super(name, new PolicyDefinitionInner()); + this.manager = manager; + // Set resource name + this.policyDefinitionName = name; + // + } + + PolicyDefinitionImpl(PolicyDefinitionInner inner, PolicyManager manager) { + super(inner.name(), inner); + this.manager = manager; + // Set resource name + this.policyDefinitionName = inner.name(); + // set resource ancestor and positional variables + this.policyDefinitionName = IdParsingUtils.getValueFromIdByName(inner.id(), "policyDefinitions"); + // set other parameters for create and update + } + + @Override + public PolicyManager manager() { + return this.manager; + } + + @Override + public Observable createResourceAsync() { + PolicyDefinitionsInner client = this.manager().inner().policyDefinitions(); + return client.createOrUpdateAsync(this.policyDefinitionName, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + public Observable updateResourceAsync() { + PolicyDefinitionsInner client = this.manager().inner().policyDefinitions(); + return client.createOrUpdateAsync(this.policyDefinitionName, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + protected Observable getInnerAsync() { + PolicyDefinitionsInner client = this.manager().inner().policyDefinitions(); + return client.getAsync(this.policyDefinitionName); + } + + @Override + public boolean isInCreateMode() { + return this.inner().id() == null; + } + + + @Override + public String description() { + return this.inner().description(); + } + + @Override + public String displayName() { + return this.inner().displayName(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public Object metadata() { + return this.inner().metadata(); + } + + @Override + public String mode() { + return this.inner().mode(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public Object parameters() { + return this.inner().parameters(); + } + + @Override + public Object policyRule() { + return this.inner().policyRule(); + } + + @Override + public PolicyType policyType() { + return this.inner().policyType(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public PolicyDefinitionImpl withDescription(String description) { + this.inner().withDescription(description); + return this; + } + + @Override + public PolicyDefinitionImpl withDisplayName(String displayName) { + this.inner().withDisplayName(displayName); + return this; + } + + @Override + public PolicyDefinitionImpl withMetadata(Object metadata) { + this.inner().withMetadata(metadata); + return this; + } + + @Override + public PolicyDefinitionImpl withMode(String mode) { + this.inner().withMode(mode); + return this; + } + + @Override + public PolicyDefinitionImpl withParameters(Object parameters) { + this.inner().withParameters(parameters); + return this; + } + + @Override + public PolicyDefinitionImpl withPolicyRule(Object policyRule) { + this.inner().withPolicyRule(policyRule); + return this; + } + + @Override + public PolicyDefinitionImpl withPolicyType(PolicyType policyType) { + this.inner().withPolicyType(policyType); + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionInner.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionInner.java new file mode 100644 index 0000000000000..008a2fc38cfc7 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionInner.java @@ -0,0 +1,206 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import com.microsoft.azure.management.policy.v2019_01_01.PolicyType; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * The policy definition. + */ +@JsonFlatten +public class PolicyDefinitionInner extends ProxyResource { + /** + * The type of policy definition. Possible values are NotSpecified, + * BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', + * 'Custom'. + */ + @JsonProperty(value = "properties.policyType") + private PolicyType policyType; + + /** + * The policy definition mode. Some examples are All, Indexed, + * Microsoft.KeyVault.Data. + */ + @JsonProperty(value = "properties.mode") + private String mode; + + /** + * The display name of the policy definition. + */ + @JsonProperty(value = "properties.displayName") + private String displayName; + + /** + * The policy definition description. + */ + @JsonProperty(value = "properties.description") + private String description; + + /** + * The policy rule. + */ + @JsonProperty(value = "properties.policyRule") + private Object policyRule; + + /** + * The policy definition metadata. + */ + @JsonProperty(value = "properties.metadata") + private Object metadata; + + /** + * Required if a parameter is used in policy rule. + */ + @JsonProperty(value = "properties.parameters") + private Object parameters; + + /** + * Get the type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom'. + * + * @return the policyType value + */ + public PolicyType policyType() { + return this.policyType; + } + + /** + * Set the type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom'. + * + * @param policyType the policyType value to set + * @return the PolicyDefinitionInner object itself. + */ + public PolicyDefinitionInner withPolicyType(PolicyType policyType) { + this.policyType = policyType; + return this; + } + + /** + * Get the policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. + * + * @return the mode value + */ + public String mode() { + return this.mode; + } + + /** + * Set the policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. + * + * @param mode the mode value to set + * @return the PolicyDefinitionInner object itself. + */ + public PolicyDefinitionInner withMode(String mode) { + this.mode = mode; + return this; + } + + /** + * Get the display name of the policy definition. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the display name of the policy definition. + * + * @param displayName the displayName value to set + * @return the PolicyDefinitionInner object itself. + */ + public PolicyDefinitionInner withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the policy definition description. + * + * @return the description value + */ + public String description() { + return this.description; + } + + /** + * Set the policy definition description. + * + * @param description the description value to set + * @return the PolicyDefinitionInner object itself. + */ + public PolicyDefinitionInner withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the policy rule. + * + * @return the policyRule value + */ + public Object policyRule() { + return this.policyRule; + } + + /** + * Set the policy rule. + * + * @param policyRule the policyRule value to set + * @return the PolicyDefinitionInner object itself. + */ + public PolicyDefinitionInner withPolicyRule(Object policyRule) { + this.policyRule = policyRule; + return this; + } + + /** + * Get the policy definition metadata. + * + * @return the metadata value + */ + public Object metadata() { + return this.metadata; + } + + /** + * Set the policy definition metadata. + * + * @param metadata the metadata value to set + * @return the PolicyDefinitionInner object itself. + */ + public PolicyDefinitionInner withMetadata(Object metadata) { + this.metadata = metadata; + return this; + } + + /** + * Get required if a parameter is used in policy rule. + * + * @return the parameters value + */ + public Object parameters() { + return this.parameters; + } + + /** + * Set required if a parameter is used in policy rule. + * + * @param parameters the parameters value to set + * @return the PolicyDefinitionInner object itself. + */ + public PolicyDefinitionInner withParameters(Object parameters) { + this.parameters = parameters; + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionsImpl.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionsImpl.java new file mode 100644 index 0000000000000..9e4765ef251d9 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionsImpl.java @@ -0,0 +1,174 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.policy.v2019_01_01.PolicyDefinitions; +import rx.Observable; +import rx.functions.Func1; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.Page; +import rx.Completable; +import com.microsoft.azure.management.policy.v2019_01_01.PolicyDefinition; +import com.microsoft.azure.arm.utils.PagedListConverter; + +class PolicyDefinitionsImpl extends WrapperImpl implements PolicyDefinitions { + private PagedListConverter converter; + private final PolicyManager manager; + + PolicyDefinitionsImpl(PolicyManager manager) { + super(manager.inner().policyDefinitions()); + this.manager = manager; + this.converter = new PagedListConverter() { + @Override + public Observable typeConvertAsync(PolicyDefinitionInner inner) { + return Observable.just((PolicyDefinition) wrapModel(inner)); + } + }; + } + + public PolicyManager manager() { + return this.manager; + } + + @Override + public PolicyDefinitionImpl define(String name) { + return wrapModel(name); + } + + private PolicyDefinitionImpl wrapModel(PolicyDefinitionInner inner) { + return new PolicyDefinitionImpl(inner, manager()); + } + + private PolicyDefinitionImpl wrapModel(String name) { + return new PolicyDefinitionImpl(name, this.manager()); + } + + @Override + public Completable deleteAsync(String policyDefinitionName) { + PolicyDefinitionsInner client = this.inner(); + return client.deleteAsync(policyDefinitionName).toCompletable(); + } + + @Override + public Observable getAsync(String policyDefinitionName) { + PolicyDefinitionsInner client = this.inner(); + return client.getAsync(policyDefinitionName) + .map(new Func1() { + @Override + public PolicyDefinition call(PolicyDefinitionInner inner) { + return new PolicyDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Observable getBuiltInAsync(String policyDefinitionName) { + PolicyDefinitionsInner client = this.inner(); + return client.getBuiltInAsync(policyDefinitionName) + .map(new Func1() { + @Override + public PolicyDefinition call(PolicyDefinitionInner inner) { + return new PolicyDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Observable createOrUpdateAtManagementGroupAsync(String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters) { + PolicyDefinitionsInner client = this.inner(); + return client.createOrUpdateAtManagementGroupAsync(policyDefinitionName, managementGroupId, parameters) + .map(new Func1() { + @Override + public PolicyDefinition call(PolicyDefinitionInner inner) { + return new PolicyDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Completable deleteAtManagementGroupAsync(String policyDefinitionName, String managementGroupId) { + PolicyDefinitionsInner client = this.inner(); + return client.deleteAtManagementGroupAsync(policyDefinitionName, managementGroupId).toCompletable(); + } + + @Override + public Observable getAtManagementGroupAsync(String policyDefinitionName, String managementGroupId) { + PolicyDefinitionsInner client = this.inner(); + return client.getAtManagementGroupAsync(policyDefinitionName, managementGroupId) + .map(new Func1() { + @Override + public PolicyDefinition call(PolicyDefinitionInner inner) { + return new PolicyDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByManagementGroupAsync(final String managementGroupId) { + PolicyDefinitionsInner client = this.inner(); + return client.listByManagementGroupAsync(managementGroupId) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public PolicyDefinition call(PolicyDefinitionInner inner) { + return new PolicyDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Observable listBuiltInAsync() { + PolicyDefinitionsInner client = this.inner(); + return client.listBuiltInAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public PolicyDefinition call(PolicyDefinitionInner inner) { + return new PolicyDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public PagedList list() { + PolicyDefinitionsInner client = this.inner(); + return converter.convert(client.list()); + } + + @Override + public Observable listAsync() { + PolicyDefinitionsInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public PolicyDefinition call(PolicyDefinitionInner inner) { + return wrapModel(inner); + } + }); + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionsInner.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionsInner.java new file mode 100644 index 0000000000000..4b55a5f0e5610 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyDefinitionsInner.java @@ -0,0 +1,1410 @@ +/** + * 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.policy.v2019_01_01.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.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.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 PolicyDefinitions. + */ +public class PolicyDefinitionsInner { + /** The Retrofit service to perform REST calls. */ + private PolicyDefinitionsService service; + /** The service client containing this operation class. */ + private PolicyClientImpl client; + + /** + * Initializes an instance of PolicyDefinitionsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public PolicyDefinitionsInner(Retrofit retrofit, PolicyClientImpl client) { + this.service = retrofit.create(PolicyDefinitionsService.class); + this.client = client; + } + + /** + * The interface defining all the services for PolicyDefinitions to be + * used by Retrofit to perform actually REST calls. + */ + interface PolicyDefinitionsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.policy.v2019_01_01.PolicyDefinitions createOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") + Observable> createOrUpdate(@Path("policyDefinitionName") String policyDefinitionName, @Path("subscriptionId") String subscriptionId, @Body PolicyDefinitionInner parameters, @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.policy.v2019_01_01.PolicyDefinitions delete" }) + @HTTP(path = "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("policyDefinitionName") String policyDefinitionName, @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.policy.v2019_01_01.PolicyDefinitions get" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") + Observable> get(@Path("policyDefinitionName") String policyDefinitionName, @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.policy.v2019_01_01.PolicyDefinitions getBuiltIn" }) + @GET("providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") + Observable> getBuiltIn(@Path("policyDefinitionName") String policyDefinitionName, @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.policy.v2019_01_01.PolicyDefinitions createOrUpdateAtManagementGroup" }) + @PUT("providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") + Observable> createOrUpdateAtManagementGroup(@Path("policyDefinitionName") String policyDefinitionName, @Path("managementGroupId") String managementGroupId, @Body PolicyDefinitionInner parameters, @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.policy.v2019_01_01.PolicyDefinitions deleteAtManagementGroup" }) + @HTTP(path = "providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", method = "DELETE", hasBody = true) + Observable> deleteAtManagementGroup(@Path("policyDefinitionName") String policyDefinitionName, @Path("managementGroupId") String managementGroupId, @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.policy.v2019_01_01.PolicyDefinitions getAtManagementGroup" }) + @GET("providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") + Observable> getAtManagementGroup(@Path("policyDefinitionName") String policyDefinitionName, @Path("managementGroupId") String managementGroupId, @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.policy.v2019_01_01.PolicyDefinitions list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + Observable> list(@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.policy.v2019_01_01.PolicyDefinitions listBuiltIn" }) + @GET("providers/Microsoft.Authorization/policyDefinitions") + Observable> listBuiltIn(@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.policy.v2019_01_01.PolicyDefinitions listByManagementGroup" }) + @GET("providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") + Observable> listByManagementGroup(@Path("managementGroupId") String managementGroupId, @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.policy.v2019_01_01.PolicyDefinitions listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @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.policy.v2019_01_01.PolicyDefinitions listBuiltInNext" }) + @GET + Observable> listBuiltInNext(@Url String nextUrl, @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.policy.v2019_01_01.PolicyDefinitions listByManagementGroupNext" }) + @GET + Observable> listByManagementGroupNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Creates or updates a policy definition in a subscription. + * This operation creates or updates a policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to create. + * @param parameters The policy definition properties. + * @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 PolicyDefinitionInner object if successful. + */ + public PolicyDefinitionInner createOrUpdate(String policyDefinitionName, PolicyDefinitionInner parameters) { + return createOrUpdateWithServiceResponseAsync(policyDefinitionName, parameters).toBlocking().single().body(); + } + + /** + * Creates or updates a policy definition in a subscription. + * This operation creates or updates a policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to create. + * @param parameters The policy definition properties. + * @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 createOrUpdateAsync(String policyDefinitionName, PolicyDefinitionInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(policyDefinitionName, parameters), serviceCallback); + } + + /** + * Creates or updates a policy definition in a subscription. + * This operation creates or updates a policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to create. + * @param parameters The policy definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable createOrUpdateAsync(String policyDefinitionName, PolicyDefinitionInner parameters) { + return createOrUpdateWithServiceResponseAsync(policyDefinitionName, parameters).map(new Func1, PolicyDefinitionInner>() { + @Override + public PolicyDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates a policy definition in a subscription. + * This operation creates or updates a policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to create. + * @param parameters The policy definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String policyDefinitionName, PolicyDefinitionInner parameters) { + if (policyDefinitionName == null) { + throw new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters 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(parameters); + return service.createOrUpdate(policyDefinitionName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes a policy definition in a subscription. + * This operation deletes the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @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 policyDefinitionName) { + deleteWithServiceResponseAsync(policyDefinitionName).toBlocking().single().body(); + } + + /** + * Deletes a policy definition in a subscription. + * This operation deletes the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @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 policyDefinitionName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(policyDefinitionName), serviceCallback); + } + + /** + * Deletes a policy definition in a subscription. + * This operation deletes the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String policyDefinitionName) { + return deleteWithServiceResponseAsync(policyDefinitionName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes a policy definition in a subscription. + * This operation deletes the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String policyDefinitionName) { + if (policyDefinitionName == null) { + throw new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."); + } + 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.delete(policyDefinitionName, this.client.subscriptionId(), 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(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Retrieves a policy definition in a subscription. + * This operation retrieves the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @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 PolicyDefinitionInner object if successful. + */ + public PolicyDefinitionInner get(String policyDefinitionName) { + return getWithServiceResponseAsync(policyDefinitionName).toBlocking().single().body(); + } + + /** + * Retrieves a policy definition in a subscription. + * This operation retrieves the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @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 policyDefinitionName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(policyDefinitionName), serviceCallback); + } + + /** + * Retrieves a policy definition in a subscription. + * This operation retrieves the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable getAsync(String policyDefinitionName) { + return getWithServiceResponseAsync(policyDefinitionName).map(new Func1, PolicyDefinitionInner>() { + @Override + public PolicyDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieves a policy definition in a subscription. + * This operation retrieves the policy definition in the given subscription with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable> getWithServiceResponseAsync(String policyDefinitionName) { + if (policyDefinitionName == null) { + throw new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."); + } + 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.get(policyDefinitionName, this.client.subscriptionId(), 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); + } + + /** + * Retrieves a built-in policy definition. + * This operation retrieves the built-in policy definition with the given name. + * + * @param policyDefinitionName The name of the built-in policy definition to get. + * @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 PolicyDefinitionInner object if successful. + */ + public PolicyDefinitionInner getBuiltIn(String policyDefinitionName) { + return getBuiltInWithServiceResponseAsync(policyDefinitionName).toBlocking().single().body(); + } + + /** + * Retrieves a built-in policy definition. + * This operation retrieves the built-in policy definition with the given name. + * + * @param policyDefinitionName The name of the built-in policy definition to get. + * @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 getBuiltInAsync(String policyDefinitionName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getBuiltInWithServiceResponseAsync(policyDefinitionName), serviceCallback); + } + + /** + * Retrieves a built-in policy definition. + * This operation retrieves the built-in policy definition with the given name. + * + * @param policyDefinitionName The name of the built-in policy definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable getBuiltInAsync(String policyDefinitionName) { + return getBuiltInWithServiceResponseAsync(policyDefinitionName).map(new Func1, PolicyDefinitionInner>() { + @Override + public PolicyDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieves a built-in policy definition. + * This operation retrieves the built-in policy definition with the given name. + * + * @param policyDefinitionName The name of the built-in policy definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable> getBuiltInWithServiceResponseAsync(String policyDefinitionName) { + if (policyDefinitionName == null) { + throw new IllegalArgumentException("Parameter policyDefinitionName 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.getBuiltIn(policyDefinitionName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getBuiltInDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getBuiltInDelegate(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); + } + + /** + * Creates or updates a policy definition in a management group. + * This operation creates or updates a policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy definition properties. + * @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 PolicyDefinitionInner object if successful. + */ + public PolicyDefinitionInner createOrUpdateAtManagementGroup(String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters) { + return createOrUpdateAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId, parameters).toBlocking().single().body(); + } + + /** + * Creates or updates a policy definition in a management group. + * This operation creates or updates a policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy definition properties. + * @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 createOrUpdateAtManagementGroupAsync(String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId, parameters), serviceCallback); + } + + /** + * Creates or updates a policy definition in a management group. + * This operation creates or updates a policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable createOrUpdateAtManagementGroupAsync(String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters) { + return createOrUpdateAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId, parameters).map(new Func1, PolicyDefinitionInner>() { + @Override + public PolicyDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates a policy definition in a management group. + * This operation creates or updates a policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable> createOrUpdateAtManagementGroupWithServiceResponseAsync(String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters) { + if (policyDefinitionName == null) { + throw new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."); + } + if (managementGroupId == null) { + throw new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters 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(parameters); + return service.createOrUpdateAtManagementGroup(policyDefinitionName, managementGroupId, parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateAtManagementGroupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateAtManagementGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes a policy definition in a management group. + * This operation deletes the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @param managementGroupId The ID of the management group. + * @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 deleteAtManagementGroup(String policyDefinitionName, String managementGroupId) { + deleteAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId).toBlocking().single().body(); + } + + /** + * Deletes a policy definition in a management group. + * This operation deletes the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @param managementGroupId The ID of the management group. + * @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 deleteAtManagementGroupAsync(String policyDefinitionName, String managementGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId), serviceCallback); + } + + /** + * Deletes a policy definition in a management group. + * This operation deletes the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAtManagementGroupAsync(String policyDefinitionName, String managementGroupId) { + return deleteAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes a policy definition in a management group. + * This operation deletes the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to delete. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteAtManagementGroupWithServiceResponseAsync(String policyDefinitionName, String managementGroupId) { + if (policyDefinitionName == null) { + throw new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."); + } + if (managementGroupId == null) { + throw new IllegalArgumentException("Parameter managementGroupId 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.deleteAtManagementGroup(policyDefinitionName, managementGroupId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteAtManagementGroupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteAtManagementGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Retrieve a policy definition in a management group. + * This operation retrieves the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @param managementGroupId The ID of the management group. + * @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 PolicyDefinitionInner object if successful. + */ + public PolicyDefinitionInner getAtManagementGroup(String policyDefinitionName, String managementGroupId) { + return getAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId).toBlocking().single().body(); + } + + /** + * Retrieve a policy definition in a management group. + * This operation retrieves the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @param managementGroupId The ID of the management group. + * @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 getAtManagementGroupAsync(String policyDefinitionName, String managementGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId), serviceCallback); + } + + /** + * Retrieve a policy definition in a management group. + * This operation retrieves the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable getAtManagementGroupAsync(String policyDefinitionName, String managementGroupId) { + return getAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId).map(new Func1, PolicyDefinitionInner>() { + @Override + public PolicyDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve a policy definition in a management group. + * This operation retrieves the policy definition in the given management group with the given name. + * + * @param policyDefinitionName The name of the policy definition to get. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicyDefinitionInner object + */ + public Observable> getAtManagementGroupWithServiceResponseAsync(String policyDefinitionName, String managementGroupId) { + if (policyDefinitionName == null) { + throw new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."); + } + if (managementGroupId == null) { + throw new IllegalArgumentException("Parameter managementGroupId 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.getAtManagementGroup(policyDefinitionName, managementGroupId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getAtManagementGroupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getAtManagementGroupDelegate(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); + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + * @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<PolicyDefinitionInner> 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(); + } + }; + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + * @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); + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyDefinitionInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyDefinitionInner> 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)); + } + }); + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyDefinitionInner> 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."); + } + 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); + 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); + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @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<PolicyDefinitionInner> object if successful. + */ + public PagedList listBuiltIn() { + ServiceResponse> response = listBuiltInSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listBuiltInNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @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> listBuiltInAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listBuiltInSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listBuiltInNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyDefinitionInner> object + */ + public Observable> listBuiltInAsync() { + return listBuiltInWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyDefinitionInner> object + */ + public Observable>> listBuiltInWithServiceResponseAsync() { + return listBuiltInSinglePageAsync() + .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(listBuiltInNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyDefinitionInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listBuiltInSinglePageAsync() { + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listBuiltIn(this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listBuiltInDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listBuiltInDelegate(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); + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + * @param managementGroupId The ID of the management group. + * @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<PolicyDefinitionInner> object if successful. + */ + public PagedList listByManagementGroup(final String managementGroupId) { + ServiceResponse> response = listByManagementGroupSinglePageAsync(managementGroupId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + * @param managementGroupId The ID of the management group. + * @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> listByManagementGroupAsync(final String managementGroupId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByManagementGroupSinglePageAsync(managementGroupId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyDefinitionInner> object + */ + public Observable> listByManagementGroupAsync(final String managementGroupId) { + return listByManagementGroupWithServiceResponseAsync(managementGroupId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicyDefinitionInner> object + */ + public Observable>> listByManagementGroupWithServiceResponseAsync(final String managementGroupId) { + return listByManagementGroupSinglePageAsync(managementGroupId) + .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(listByManagementGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + ServiceResponse> * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyDefinitionInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByManagementGroupSinglePageAsync(final String managementGroupId) { + if (managementGroupId == null) { + throw new IllegalArgumentException("Parameter managementGroupId 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.listByManagementGroup(managementGroupId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByManagementGroupDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByManagementGroupDelegate(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); + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + * @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<PolicyDefinitionInner> 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(); + } + }; + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + * @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); + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + * @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<PolicyDefinitionInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + * @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<PolicyDefinitionInner> 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)); + } + }); + } + + /** + * Retrieves policy definitions in a subscription. + * This operation retrieves a list of all the policy definitions in a given subscription. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyDefinitionInner> 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); + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @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<PolicyDefinitionInner> object if successful. + */ + public PagedList listBuiltInNext(final String nextPageLink) { + ServiceResponse> response = listBuiltInNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listBuiltInNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @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> listBuiltInNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listBuiltInNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listBuiltInNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @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<PolicyDefinitionInner> object + */ + public Observable> listBuiltInNextAsync(final String nextPageLink) { + return listBuiltInNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + * @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<PolicyDefinitionInner> object + */ + public Observable>> listBuiltInNextWithServiceResponseAsync(final String nextPageLink) { + return listBuiltInNextSinglePageAsync(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(listBuiltInNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieve built-in policy definitions. + * This operation retrieves a list of all the built-in policy definitions. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyDefinitionInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listBuiltInNextSinglePageAsync(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.listBuiltInNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listBuiltInNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listBuiltInNextDelegate(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); + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + * @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<PolicyDefinitionInner> object if successful. + */ + public PagedList listByManagementGroupNext(final String nextPageLink) { + ServiceResponse> response = listByManagementGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + * @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> listByManagementGroupNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByManagementGroupNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + * @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<PolicyDefinitionInner> object + */ + public Observable> listByManagementGroupNextAsync(final String nextPageLink) { + return listByManagementGroupNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + * @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<PolicyDefinitionInner> object + */ + public Observable>> listByManagementGroupNextWithServiceResponseAsync(final String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(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(listByManagementGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieve policy definitions in a management group. + * This operation retrieves a list of all the policy definitions in a given management group. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicyDefinitionInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByManagementGroupNextSinglePageAsync(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.listByManagementGroupNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByManagementGroupNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByManagementGroupNextDelegate(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/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyManager.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyManager.java new file mode 100644 index 0000000000000..18ee9a95b2c4e --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicyManager.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.policy.v2019_01_01.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.policy.v2019_01_01.PolicyAssignments; +import com.microsoft.azure.management.policy.v2019_01_01.PolicyDefinitions; +import com.microsoft.azure.management.policy.v2019_01_01.PolicySetDefinitions; +import com.microsoft.azure.arm.resources.implementation.AzureConfigurableCoreImpl; +import com.microsoft.azure.arm.resources.implementation.ManagerCore; + +/** + * Entry point to Azure Authorization resource management. + */ +public final class PolicyManager extends ManagerCore { + private PolicyAssignments policyAssignments; + private PolicyDefinitions policyDefinitions; + private PolicySetDefinitions policySetDefinitions; + /** + * Get a Configurable instance that can be used to create PolicyManager with optional configuration. + * + * @return the instance allowing configurations + */ + public static Configurable configure() { + return new PolicyManager.ConfigurableImpl(); + } + /** + * Creates an instance of PolicyManager that exposes Authorization resource management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the PolicyManager + */ + public static PolicyManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return new PolicyManager(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 PolicyManager that exposes Authorization resource management API entry points. + * + * @param restClient the RestClient to be used for API calls. + * @param subscriptionId the subscription UUID + * @return the PolicyManager + */ + public static PolicyManager authenticate(RestClient restClient, String subscriptionId) { + return new PolicyManager(restClient, subscriptionId); + } + /** + * The interface allowing configurations to be set. + */ + public interface Configurable extends AzureConfigurable { + /** + * Creates an instance of PolicyManager that exposes Authorization management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the interface exposing Authorization management API entry points that work across subscriptions + */ + PolicyManager authenticate(AzureTokenCredentials credentials, String subscriptionId); + } + + /** + * @return Entry point to manage PolicyAssignments. + */ + public PolicyAssignments policyAssignments() { + if (this.policyAssignments == null) { + this.policyAssignments = new PolicyAssignmentsImpl(this); + } + return this.policyAssignments; + } + + /** + * @return Entry point to manage PolicyDefinitions. + */ + public PolicyDefinitions policyDefinitions() { + if (this.policyDefinitions == null) { + this.policyDefinitions = new PolicyDefinitionsImpl(this); + } + return this.policyDefinitions; + } + + /** + * @return Entry point to manage PolicySetDefinitions. + */ + public PolicySetDefinitions policySetDefinitions() { + if (this.policySetDefinitions == null) { + this.policySetDefinitions = new PolicySetDefinitionsImpl(this); + } + return this.policySetDefinitions; + } + + /** + * The implementation for Configurable interface. + */ + private static final class ConfigurableImpl extends AzureConfigurableCoreImpl implements Configurable { + public PolicyManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return PolicyManager.authenticate(buildRestClient(credentials), subscriptionId); + } + } + private PolicyManager(RestClient restClient, String subscriptionId) { + super( + restClient, + subscriptionId, + new PolicyClientImpl(restClient).withSubscriptionId(subscriptionId)); + } +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionImpl.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionImpl.java new file mode 100644 index 0000000000000..c8d1403da1afb --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionImpl.java @@ -0,0 +1,153 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import com.microsoft.azure.management.policy.v2019_01_01.PolicySetDefinition; +import com.microsoft.azure.arm.model.implementation.CreatableUpdatableImpl; +import rx.Observable; +import com.microsoft.azure.management.policy.v2019_01_01.PolicyType; +import java.util.List; +import com.microsoft.azure.management.policy.v2019_01_01.PolicyDefinitionReference; + +class PolicySetDefinitionImpl extends CreatableUpdatableImpl implements PolicySetDefinition, PolicySetDefinition.Definition, PolicySetDefinition.Update { + private String policySetDefinitionName; + private final PolicyManager manager; + + PolicySetDefinitionImpl(String name, PolicyManager manager) { + super(name, new PolicySetDefinitionInner()); + this.manager = manager; + // Set resource name + this.policySetDefinitionName = name; + // + } + + PolicySetDefinitionImpl(PolicySetDefinitionInner inner, PolicyManager manager) { + super(inner.name(), inner); + this.manager = manager; + // Set resource name + this.policySetDefinitionName = inner.name(); + // set resource ancestor and positional variables + this.policySetDefinitionName = IdParsingUtils.getValueFromIdByName(inner.id(), "policySetDefinitions"); + // set other parameters for create and update + } + + @Override + public PolicyManager manager() { + return this.manager; + } + + @Override + public Observable createResourceAsync() { + PolicySetDefinitionsInner client = this.manager().inner().policySetDefinitions(); + return client.createOrUpdateAsync(this.policySetDefinitionName, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + public Observable updateResourceAsync() { + PolicySetDefinitionsInner client = this.manager().inner().policySetDefinitions(); + return client.createOrUpdateAsync(this.policySetDefinitionName, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + protected Observable getInnerAsync() { + PolicySetDefinitionsInner client = this.manager().inner().policySetDefinitions(); + return client.getAsync(this.policySetDefinitionName); + } + + @Override + public boolean isInCreateMode() { + return this.inner().id() == null; + } + + + @Override + public String description() { + return this.inner().description(); + } + + @Override + public String displayName() { + return this.inner().displayName(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public Object metadata() { + return this.inner().metadata(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public Object parameters() { + return this.inner().parameters(); + } + + @Override + public List policyDefinitions() { + return this.inner().policyDefinitions(); + } + + @Override + public PolicyType policyType() { + return this.inner().policyType(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public PolicySetDefinitionImpl withPolicyDefinitions(List policyDefinitions) { + this.inner().withPolicyDefinitions(policyDefinitions); + return this; + } + + @Override + public PolicySetDefinitionImpl withDescription(String description) { + this.inner().withDescription(description); + return this; + } + + @Override + public PolicySetDefinitionImpl withDisplayName(String displayName) { + this.inner().withDisplayName(displayName); + return this; + } + + @Override + public PolicySetDefinitionImpl withMetadata(Object metadata) { + this.inner().withMetadata(metadata); + return this; + } + + @Override + public PolicySetDefinitionImpl withParameters(Object parameters) { + this.inner().withParameters(parameters); + return this; + } + + @Override + public PolicySetDefinitionImpl withPolicyType(PolicyType policyType) { + this.inner().withPolicyType(policyType); + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionInner.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionInner.java new file mode 100644 index 0000000000000..14b220e5311e2 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionInner.java @@ -0,0 +1,182 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import com.microsoft.azure.management.policy.v2019_01_01.PolicyType; +import java.util.List; +import com.microsoft.azure.management.policy.v2019_01_01.PolicyDefinitionReference; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * The policy set definition. + */ +@JsonFlatten +public class PolicySetDefinitionInner extends ProxyResource { + /** + * The type of policy definition. Possible values are NotSpecified, + * BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', + * 'Custom'. + */ + @JsonProperty(value = "properties.policyType") + private PolicyType policyType; + + /** + * The display name of the policy set definition. + */ + @JsonProperty(value = "properties.displayName") + private String displayName; + + /** + * The policy set definition description. + */ + @JsonProperty(value = "properties.description") + private String description; + + /** + * The policy set definition metadata. + */ + @JsonProperty(value = "properties.metadata") + private Object metadata; + + /** + * The policy set definition parameters that can be used in policy + * definition references. + */ + @JsonProperty(value = "properties.parameters") + private Object parameters; + + /** + * An array of policy definition references. + */ + @JsonProperty(value = "properties.policyDefinitions", required = true) + private List policyDefinitions; + + /** + * Get the type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom'. + * + * @return the policyType value + */ + public PolicyType policyType() { + return this.policyType; + } + + /** + * Set the type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom'. + * + * @param policyType the policyType value to set + * @return the PolicySetDefinitionInner object itself. + */ + public PolicySetDefinitionInner withPolicyType(PolicyType policyType) { + this.policyType = policyType; + return this; + } + + /** + * Get the display name of the policy set definition. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the display name of the policy set definition. + * + * @param displayName the displayName value to set + * @return the PolicySetDefinitionInner object itself. + */ + public PolicySetDefinitionInner withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the policy set definition description. + * + * @return the description value + */ + public String description() { + return this.description; + } + + /** + * Set the policy set definition description. + * + * @param description the description value to set + * @return the PolicySetDefinitionInner object itself. + */ + public PolicySetDefinitionInner withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the policy set definition metadata. + * + * @return the metadata value + */ + public Object metadata() { + return this.metadata; + } + + /** + * Set the policy set definition metadata. + * + * @param metadata the metadata value to set + * @return the PolicySetDefinitionInner object itself. + */ + public PolicySetDefinitionInner withMetadata(Object metadata) { + this.metadata = metadata; + return this; + } + + /** + * Get the policy set definition parameters that can be used in policy definition references. + * + * @return the parameters value + */ + public Object parameters() { + return this.parameters; + } + + /** + * Set the policy set definition parameters that can be used in policy definition references. + * + * @param parameters the parameters value to set + * @return the PolicySetDefinitionInner object itself. + */ + public PolicySetDefinitionInner withParameters(Object parameters) { + this.parameters = parameters; + return this; + } + + /** + * Get an array of policy definition references. + * + * @return the policyDefinitions value + */ + public List policyDefinitions() { + return this.policyDefinitions; + } + + /** + * Set an array of policy definition references. + * + * @param policyDefinitions the policyDefinitions value to set + * @return the PolicySetDefinitionInner object itself. + */ + public PolicySetDefinitionInner withPolicyDefinitions(List policyDefinitions) { + this.policyDefinitions = policyDefinitions; + return this; + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionsImpl.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionsImpl.java new file mode 100644 index 0000000000000..3e0f7ddff6832 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionsImpl.java @@ -0,0 +1,174 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.policy.v2019_01_01.PolicySetDefinitions; +import rx.Observable; +import rx.functions.Func1; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.Page; +import rx.Completable; +import com.microsoft.azure.management.policy.v2019_01_01.PolicySetDefinition; +import com.microsoft.azure.arm.utils.PagedListConverter; + +class PolicySetDefinitionsImpl extends WrapperImpl implements PolicySetDefinitions { + private PagedListConverter converter; + private final PolicyManager manager; + + PolicySetDefinitionsImpl(PolicyManager manager) { + super(manager.inner().policySetDefinitions()); + this.manager = manager; + this.converter = new PagedListConverter() { + @Override + public Observable typeConvertAsync(PolicySetDefinitionInner inner) { + return Observable.just((PolicySetDefinition) wrapModel(inner)); + } + }; + } + + public PolicyManager manager() { + return this.manager; + } + + @Override + public PolicySetDefinitionImpl define(String name) { + return wrapModel(name); + } + + private PolicySetDefinitionImpl wrapModel(PolicySetDefinitionInner inner) { + return new PolicySetDefinitionImpl(inner, manager()); + } + + private PolicySetDefinitionImpl wrapModel(String name) { + return new PolicySetDefinitionImpl(name, this.manager()); + } + + @Override + public Completable deleteAsync(String policySetDefinitionName) { + PolicySetDefinitionsInner client = this.inner(); + return client.deleteAsync(policySetDefinitionName).toCompletable(); + } + + @Override + public Observable getAsync(String policySetDefinitionName) { + PolicySetDefinitionsInner client = this.inner(); + return client.getAsync(policySetDefinitionName) + .map(new Func1() { + @Override + public PolicySetDefinition call(PolicySetDefinitionInner inner) { + return new PolicySetDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Observable getBuiltInAsync(String policySetDefinitionName) { + PolicySetDefinitionsInner client = this.inner(); + return client.getBuiltInAsync(policySetDefinitionName) + .map(new Func1() { + @Override + public PolicySetDefinition call(PolicySetDefinitionInner inner) { + return new PolicySetDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Observable createOrUpdateAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId, PolicySetDefinitionInner parameters) { + PolicySetDefinitionsInner client = this.inner(); + return client.createOrUpdateAtManagementGroupAsync(policySetDefinitionName, managementGroupId, parameters) + .map(new Func1() { + @Override + public PolicySetDefinition call(PolicySetDefinitionInner inner) { + return new PolicySetDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Completable deleteAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId) { + PolicySetDefinitionsInner client = this.inner(); + return client.deleteAtManagementGroupAsync(policySetDefinitionName, managementGroupId).toCompletable(); + } + + @Override + public Observable getAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId) { + PolicySetDefinitionsInner client = this.inner(); + return client.getAtManagementGroupAsync(policySetDefinitionName, managementGroupId) + .map(new Func1() { + @Override + public PolicySetDefinition call(PolicySetDefinitionInner inner) { + return new PolicySetDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByManagementGroupAsync(final String managementGroupId) { + PolicySetDefinitionsInner client = this.inner(); + return client.listByManagementGroupAsync(managementGroupId) + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public PolicySetDefinition call(PolicySetDefinitionInner inner) { + return new PolicySetDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public Observable listBuiltInAsync() { + PolicySetDefinitionsInner client = this.inner(); + return client.listBuiltInAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public PolicySetDefinition call(PolicySetDefinitionInner inner) { + return new PolicySetDefinitionImpl(inner, manager()); + } + }); + } + + @Override + public PagedList list() { + PolicySetDefinitionsInner client = this.inner(); + return converter.convert(client.list()); + } + + @Override + public Observable listAsync() { + PolicySetDefinitionsInner client = this.inner(); + return client.listAsync() + .flatMapIterable(new Func1, Iterable>() { + @Override + public Iterable call(Page page) { + return page.items(); + } + }) + .map(new Func1() { + @Override + public PolicySetDefinition call(PolicySetDefinitionInner inner) { + return wrapModel(inner); + } + }); + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionsInner.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionsInner.java new file mode 100644 index 0000000000000..ac0b95b8dc07c --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/PolicySetDefinitionsInner.java @@ -0,0 +1,1412 @@ +/** + * 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.policy.v2019_01_01.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.policy.v2019_01_01.ErrorResponseException; +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.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 PolicySetDefinitions. + */ +public class PolicySetDefinitionsInner { + /** The Retrofit service to perform REST calls. */ + private PolicySetDefinitionsService service; + /** The service client containing this operation class. */ + private PolicyClientImpl client; + + /** + * Initializes an instance of PolicySetDefinitionsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public PolicySetDefinitionsInner(Retrofit retrofit, PolicyClientImpl client) { + this.service = retrofit.create(PolicySetDefinitionsService.class); + this.client = client; + } + + /** + * The interface defining all the services for PolicySetDefinitions to be + * used by Retrofit to perform actually REST calls. + */ + interface PolicySetDefinitionsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.policy.v2019_01_01.PolicySetDefinitions createOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + Observable> createOrUpdate(@Path("policySetDefinitionName") String policySetDefinitionName, @Path("subscriptionId") String subscriptionId, @Body PolicySetDefinitionInner parameters, @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.policy.v2019_01_01.PolicySetDefinitions delete" }) + @HTTP(path = "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("policySetDefinitionName") String policySetDefinitionName, @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.policy.v2019_01_01.PolicySetDefinitions get" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + Observable> get(@Path("policySetDefinitionName") String policySetDefinitionName, @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.policy.v2019_01_01.PolicySetDefinitions getBuiltIn" }) + @GET("providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + Observable> getBuiltIn(@Path("policySetDefinitionName") String policySetDefinitionName, @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.policy.v2019_01_01.PolicySetDefinitions list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions") + Observable> list(@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.policy.v2019_01_01.PolicySetDefinitions listBuiltIn" }) + @GET("providers/Microsoft.Authorization/policySetDefinitions") + Observable> listBuiltIn(@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.policy.v2019_01_01.PolicySetDefinitions createOrUpdateAtManagementGroup" }) + @PUT("providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + Observable> createOrUpdateAtManagementGroup(@Path("policySetDefinitionName") String policySetDefinitionName, @Path("managementGroupId") String managementGroupId, @Body PolicySetDefinitionInner parameters, @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.policy.v2019_01_01.PolicySetDefinitions deleteAtManagementGroup" }) + @HTTP(path = "providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", method = "DELETE", hasBody = true) + Observable> deleteAtManagementGroup(@Path("policySetDefinitionName") String policySetDefinitionName, @Path("managementGroupId") String managementGroupId, @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.policy.v2019_01_01.PolicySetDefinitions getAtManagementGroup" }) + @GET("providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + Observable> getAtManagementGroup(@Path("policySetDefinitionName") String policySetDefinitionName, @Path("managementGroupId") String managementGroupId, @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.policy.v2019_01_01.PolicySetDefinitions listByManagementGroup" }) + @GET("providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions") + Observable> listByManagementGroup(@Path("managementGroupId") String managementGroupId, @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.policy.v2019_01_01.PolicySetDefinitions listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @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.policy.v2019_01_01.PolicySetDefinitions listBuiltInNext" }) + @GET + Observable> listBuiltInNext(@Url String nextUrl, @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.policy.v2019_01_01.PolicySetDefinitions listByManagementGroupNext" }) + @GET + Observable> listByManagementGroupNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Creates or updates a policy set definition. + * This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to create. + * @param parameters The policy set definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicySetDefinitionInner object if successful. + */ + public PolicySetDefinitionInner createOrUpdate(String policySetDefinitionName, PolicySetDefinitionInner parameters) { + return createOrUpdateWithServiceResponseAsync(policySetDefinitionName, parameters).toBlocking().single().body(); + } + + /** + * Creates or updates a policy set definition. + * This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to create. + * @param parameters The policy set definition properties. + * @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 createOrUpdateAsync(String policySetDefinitionName, PolicySetDefinitionInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(policySetDefinitionName, parameters), serviceCallback); + } + + /** + * Creates or updates a policy set definition. + * This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to create. + * @param parameters The policy set definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable createOrUpdateAsync(String policySetDefinitionName, PolicySetDefinitionInner parameters) { + return createOrUpdateWithServiceResponseAsync(policySetDefinitionName, parameters).map(new Func1, PolicySetDefinitionInner>() { + @Override + public PolicySetDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates a policy set definition. + * This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to create. + * @param parameters The policy set definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String policySetDefinitionName, PolicySetDefinitionInner parameters) { + if (policySetDefinitionName == null) { + throw new IllegalArgumentException("Parameter policySetDefinitionName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters 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(parameters); + return service.createOrUpdate(policySetDefinitionName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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 policySetDefinitionName) { + deleteWithServiceResponseAsync(policySetDefinitionName).toBlocking().single().body(); + } + + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @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 policySetDefinitionName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(policySetDefinitionName), serviceCallback); + } + + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String policySetDefinitionName) { + return deleteWithServiceResponseAsync(policySetDefinitionName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String policySetDefinitionName) { + if (policySetDefinitionName == null) { + throw new IllegalArgumentException("Parameter policySetDefinitionName is required and cannot be null."); + } + 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.delete(policySetDefinitionName, this.client.subscriptionId(), 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 ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicySetDefinitionInner object if successful. + */ + public PolicySetDefinitionInner get(String policySetDefinitionName) { + return getWithServiceResponseAsync(policySetDefinitionName).toBlocking().single().body(); + } + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @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 policySetDefinitionName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(policySetDefinitionName), serviceCallback); + } + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable getAsync(String policySetDefinitionName) { + return getWithServiceResponseAsync(policySetDefinitionName).map(new Func1, PolicySetDefinitionInner>() { + @Override + public PolicySetDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given subscription with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable> getWithServiceResponseAsync(String policySetDefinitionName) { + if (policySetDefinitionName == null) { + throw new IllegalArgumentException("Parameter policySetDefinitionName is required and cannot be null."); + } + 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.get(policySetDefinitionName, this.client.subscriptionId(), 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 ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves a built in policy set definition. + * This operation retrieves the built-in policy set definition with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicySetDefinitionInner object if successful. + */ + public PolicySetDefinitionInner getBuiltIn(String policySetDefinitionName) { + return getBuiltInWithServiceResponseAsync(policySetDefinitionName).toBlocking().single().body(); + } + + /** + * Retrieves a built in policy set definition. + * This operation retrieves the built-in policy set definition with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @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 getBuiltInAsync(String policySetDefinitionName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getBuiltInWithServiceResponseAsync(policySetDefinitionName), serviceCallback); + } + + /** + * Retrieves a built in policy set definition. + * This operation retrieves the built-in policy set definition with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable getBuiltInAsync(String policySetDefinitionName) { + return getBuiltInWithServiceResponseAsync(policySetDefinitionName).map(new Func1, PolicySetDefinitionInner>() { + @Override + public PolicySetDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieves a built in policy set definition. + * This operation retrieves the built-in policy set definition with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable> getBuiltInWithServiceResponseAsync(String policySetDefinitionName) { + if (policySetDefinitionName == null) { + throw new IllegalArgumentException("Parameter policySetDefinitionName 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.getBuiltIn(policySetDefinitionName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getBuiltInDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getBuiltInDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicySetDefinitionInner> 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(); + } + }; + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + * @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); + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicySetDefinitionInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicySetDefinitionInner> 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)); + } + }); + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicySetDefinitionInner> 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."); + } + 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); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicySetDefinitionInner> object if successful. + */ + public PagedList listBuiltIn() { + ServiceResponse> response = listBuiltInSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listBuiltInNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @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> listBuiltInAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listBuiltInSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listBuiltInNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicySetDefinitionInner> object + */ + public Observable> listBuiltInAsync() { + return listBuiltInWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicySetDefinitionInner> object + */ + public Observable>> listBuiltInWithServiceResponseAsync() { + return listBuiltInSinglePageAsync() + .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(listBuiltInNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicySetDefinitionInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listBuiltInSinglePageAsync() { + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listBuiltIn(this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listBuiltInDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listBuiltInDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Creates or updates a policy set definition. + * This operation creates or updates a policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy set definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicySetDefinitionInner object if successful. + */ + public PolicySetDefinitionInner createOrUpdateAtManagementGroup(String policySetDefinitionName, String managementGroupId, PolicySetDefinitionInner parameters) { + return createOrUpdateAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId, parameters).toBlocking().single().body(); + } + + /** + * Creates or updates a policy set definition. + * This operation creates or updates a policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy set definition properties. + * @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 createOrUpdateAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId, PolicySetDefinitionInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId, parameters), serviceCallback); + } + + /** + * Creates or updates a policy set definition. + * This operation creates or updates a policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy set definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable createOrUpdateAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId, PolicySetDefinitionInner parameters) { + return createOrUpdateAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId, parameters).map(new Func1, PolicySetDefinitionInner>() { + @Override + public PolicySetDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates a policy set definition. + * This operation creates or updates a policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to create. + * @param managementGroupId The ID of the management group. + * @param parameters The policy set definition properties. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable> createOrUpdateAtManagementGroupWithServiceResponseAsync(String policySetDefinitionName, String managementGroupId, PolicySetDefinitionInner parameters) { + if (policySetDefinitionName == null) { + throw new IllegalArgumentException("Parameter policySetDefinitionName is required and cannot be null."); + } + if (managementGroupId == null) { + throw new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters 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(parameters); + return service.createOrUpdateAtManagementGroup(policySetDefinitionName, managementGroupId, parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateAtManagementGroupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateAtManagementGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void deleteAtManagementGroup(String policySetDefinitionName, String managementGroupId) { + deleteAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId).toBlocking().single().body(); + } + + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @param managementGroupId The ID of the management group. + * @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 deleteAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId), serviceCallback); + } + + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId) { + return deleteAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes a policy set definition. + * This operation deletes the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to delete. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteAtManagementGroupWithServiceResponseAsync(String policySetDefinitionName, String managementGroupId) { + if (policySetDefinitionName == null) { + throw new IllegalArgumentException("Parameter policySetDefinitionName is required and cannot be null."); + } + if (managementGroupId == null) { + throw new IllegalArgumentException("Parameter managementGroupId 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.deleteAtManagementGroup(policySetDefinitionName, managementGroupId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteAtManagementGroupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteAtManagementGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PolicySetDefinitionInner object if successful. + */ + public PolicySetDefinitionInner getAtManagementGroup(String policySetDefinitionName, String managementGroupId) { + return getAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId).toBlocking().single().body(); + } + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @param managementGroupId The ID of the management group. + * @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 getAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId), serviceCallback); + } + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable getAtManagementGroupAsync(String policySetDefinitionName, String managementGroupId) { + return getAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId).map(new Func1, PolicySetDefinitionInner>() { + @Override + public PolicySetDefinitionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieves a policy set definition. + * This operation retrieves the policy set definition in the given management group with the given name. + * + * @param policySetDefinitionName The name of the policy set definition to get. + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PolicySetDefinitionInner object + */ + public Observable> getAtManagementGroupWithServiceResponseAsync(String policySetDefinitionName, String managementGroupId) { + if (policySetDefinitionName == null) { + throw new IllegalArgumentException("Parameter policySetDefinitionName is required and cannot be null."); + } + if (managementGroupId == null) { + throw new IllegalArgumentException("Parameter managementGroupId 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.getAtManagementGroup(policySetDefinitionName, managementGroupId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getAtManagementGroupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getAtManagementGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicySetDefinitionInner> object if successful. + */ + public PagedList listByManagementGroup(final String managementGroupId) { + ServiceResponse> response = listByManagementGroupSinglePageAsync(managementGroupId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + * @param managementGroupId The ID of the management group. + * @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> listByManagementGroupAsync(final String managementGroupId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByManagementGroupSinglePageAsync(managementGroupId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicySetDefinitionInner> object + */ + public Observable> listByManagementGroupAsync(final String managementGroupId) { + return listByManagementGroupWithServiceResponseAsync(managementGroupId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<PolicySetDefinitionInner> object + */ + public Observable>> listByManagementGroupWithServiceResponseAsync(final String managementGroupId) { + return listByManagementGroupSinglePageAsync(managementGroupId) + .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(listByManagementGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + ServiceResponse> * @param managementGroupId The ID of the management group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicySetDefinitionInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByManagementGroupSinglePageAsync(final String managementGroupId) { + if (managementGroupId == null) { + throw new IllegalArgumentException("Parameter managementGroupId 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.listByManagementGroup(managementGroupId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByManagementGroupDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByManagementGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicySetDefinitionInner> 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(); + } + }; + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + * @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); + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + * @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<PolicySetDefinitionInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + * @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<PolicySetDefinitionInner> 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)); + } + }); + } + + /** + * Retrieves the policy set definitions for a subscription. + * This operation retrieves a list of all the policy set definitions in the given subscription. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicySetDefinitionInner> 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 ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicySetDefinitionInner> object if successful. + */ + public PagedList listBuiltInNext(final String nextPageLink) { + ServiceResponse> response = listBuiltInNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listBuiltInNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @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> listBuiltInNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listBuiltInNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listBuiltInNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @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<PolicySetDefinitionInner> object + */ + public Observable> listBuiltInNextAsync(final String nextPageLink) { + return listBuiltInNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + * @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<PolicySetDefinitionInner> object + */ + public Observable>> listBuiltInNextWithServiceResponseAsync(final String nextPageLink) { + return listBuiltInNextSinglePageAsync(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(listBuiltInNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves built-in policy set definitions. + * This operation retrieves a list of all the built-in policy set definitions. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicySetDefinitionInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listBuiltInNextSinglePageAsync(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.listBuiltInNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listBuiltInNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listBuiltInNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<PolicySetDefinitionInner> object if successful. + */ + public PagedList listByManagementGroupNext(final String nextPageLink) { + ServiceResponse> response = listByManagementGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + * @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> listByManagementGroupNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByManagementGroupNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + * @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<PolicySetDefinitionInner> object + */ + public Observable> listByManagementGroupNextAsync(final String nextPageLink) { + return listByManagementGroupNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + * @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<PolicySetDefinitionInner> object + */ + public Observable>> listByManagementGroupNextWithServiceResponseAsync(final String nextPageLink) { + return listByManagementGroupNextSinglePageAsync(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(listByManagementGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Retrieves all policy set definitions in management group. + * This operation retrieves a list of all the a policy set definition in the given management group. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<PolicySetDefinitionInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByManagementGroupNextSinglePageAsync(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.listByManagementGroupNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByManagementGroupNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByManagementGroupNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/package-info.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/implementation/package-info.java new file mode 100644 index 0000000000000..9f3b5d63d07b0 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/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 PolicyClient. + * To manage and control access to your resources, you can define customized policies and assign them at a scope. + */ +package com.microsoft.azure.management.policy.v2019_01_01.implementation; diff --git a/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/package-info.java b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/package-info.java new file mode 100644 index 0000000000000..3c20a2127bc28 --- /dev/null +++ b/sdk/policy/mgmt-v2019_01_01/src/main/java/com/microsoft/azure/management/policy/v2019_01_01/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 PolicyClient. + * To manage and control access to your resources, you can define customized policies and assign them at a scope. + */ +package com.microsoft.azure.management.policy.v2019_01_01;