com.microsoft.azure.management.resources.implementation.PolicySetDefinitionsInner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-mgmt-resources Show documentation
Show all versions of azure-mgmt-resources Show documentation
This package contains Microsoft Azure Resource Management SDK.
/**
* 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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.resources.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.
*
* @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.
*
* @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.
*
* @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.
*
* @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.");
}
Validator.validate(parameters);
final String apiVersion = "2017-06-01-preview";
return service.createOrUpdate(policySetDefinitionName, this.client.subscriptionId(), parameters, 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.
*
* @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.
*
* @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.
*
* @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.
*
* @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.");
}
final String apiVersion = "2017-06-01-preview";
return service.delete(policySetDefinitionName, this.client.subscriptionId(), 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);
}
/**
* Gets the policy set definition.
*
* @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();
}
/**
* Gets the policy set definition.
*
* @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);
}
/**
* Gets the policy set definition.
*
* @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();
}
});
}
/**
* Gets the policy set definition.
*
* @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.");
}
final String apiVersion = "2017-06-01-preview";
return service.get(policySetDefinitionName, this.client.subscriptionId(), 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);
}
/**
* Gets the built in policy set definition.
*
* @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();
}
/**
* Gets the built in policy set definition.
*
* @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);
}
/**
* Gets the built in policy set definition.
*
* @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();
}
});
}
/**
* Gets the built in policy set definition.
*
* @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.");
}
final String apiVersion = "2017-06-01-preview";
return service.getBuiltIn(policySetDefinitionName, 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);
}
/**
* Gets all the policy set definitions for a 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();
}
};
}
/**
* Gets all the policy set definitions for a 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);
}
/**
* Gets all the policy set definitions for a 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();
}
});
}
/**
* Gets all the policy set definitions for a 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));
}
});
}
/**
* Gets all the policy set definitions for a 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.");
}
final String apiVersion = "2017-06-01-preview";
return service.list(this.client.subscriptionId(), 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);
}
/**
* Gets 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();
}
};
}
/**
* Gets 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);
}
/**
* Gets 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();
}
});
}
/**
* Gets 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));
}
});
}
/**
* Gets 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() {
final String apiVersion = "2017-06-01-preview";
return service.listBuiltIn(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 {
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 at management group level.
*
* @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 at management group level.
*
* @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 at management group level.
*
* @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 at management group level.
*
* @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.");
}
Validator.validate(parameters);
final String apiVersion = "2017-06-01-preview";
return service.createOrUpdateAtManagementGroup(policySetDefinitionName, managementGroupId, parameters, 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 at management group level.
*
* @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 at management group level.
*
* @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 at management group level.
*
* @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 at management group level.
*
* @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.");
}
final String apiVersion = "2017-06-01-preview";
return service.deleteAtManagementGroup(policySetDefinitionName, managementGroupId, 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);
}
/**
* Gets the policy set definition at management group level.
*
* @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();
}
/**
* Gets the policy set definition at management group level.
*
* @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);
}
/**
* Gets the policy set definition at management group level.
*
* @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();
}
});
}
/**
* Gets the policy set definition at management group level.
*
* @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.");
}
final String apiVersion = "2017-06-01-preview";
return service.getAtManagementGroup(policySetDefinitionName, managementGroupId, 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);
}
/**
* Gets all the policy set definitions for a subscription at 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();
}
};
}
/**
* Gets all the policy set definitions for a subscription at 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);
}
/**
* Gets all the policy set definitions for a subscription at 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();
}
});
}
/**
* Gets all the policy set definitions for a subscription at 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));
}
});
}
/**
* Gets all the policy set definitions for a subscription at 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.");
}
final String apiVersion = "2017-06-01-preview";
return service.listByManagementGroup(managementGroupId, 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);
}
/**
* Gets all the policy set definitions for a 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();
}
};
}
/**
* Gets all the policy set definitions for a 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);
}
/**
* Gets all the policy set definitions for a 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();
}
});
}
/**
* Gets all the policy set definitions for a 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));
}
});
}
/**
* Gets all the policy set definitions for a 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);
}
/**
* Gets 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();
}
};
}
/**
* Gets 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);
}
/**
* Gets 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