com.microsoft.azure.management.graphrbac.implementation.RoleDefinitionsInner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-mgmt-graph-rbac Show documentation
Show all versions of azure-mgmt-graph-rbac Show documentation
This package contains Microsoft Azure Graph RBAC Management SDK. This package has been deprecated. A replacement package com.azure.resourcemanager:azure-resourcemanager-authorization is available as of 31-March-2022. We strongly encourage you to upgrade to continue receiving updates. See Migration Guide https://aka.ms/java-track2-migration-guide for guidance on upgrading. Refer to our deprecation policy https://azure.github.io/azure-sdk/policies_support.html for more details.
/**
* 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.graphrbac.implementation;
import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete;
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 RoleDefinitions.
*/
public class RoleDefinitionsInner implements InnerSupportsDelete {
/** The Retrofit service to perform REST calls. */
private RoleDefinitionsService service;
/** The service client containing this operation class. */
private AuthorizationManagementClientImpl client;
/**
* Initializes an instance of RoleDefinitionsInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public RoleDefinitionsInner(Retrofit retrofit, AuthorizationManagementClientImpl client) {
this.service = retrofit.create(RoleDefinitionsService.class);
this.client = client;
}
/**
* The interface defining all the services for RoleDefinitions to be
* used by Retrofit to perform actually REST calls.
*/
interface RoleDefinitionsService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.graphrbac.RoleDefinitions delete" })
@HTTP(path = "{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", method = "DELETE", hasBody = true)
Observable> delete(@Path(value = "scope", encoded = true) String scope, @Path("roleDefinitionId") String roleDefinitionId, @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.graphrbac.RoleDefinitions get" })
@GET("{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}")
Observable> get(@Path(value = "scope", encoded = true) String scope, @Path("roleDefinitionId") String roleDefinitionId, @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.graphrbac.RoleDefinitions createOrUpdate" })
@PUT("{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}")
Observable> createOrUpdate(@Path(value = "scope", encoded = true) String scope, @Path("roleDefinitionId") String roleDefinitionId, @Body RoleDefinitionInner roleDefinition, @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.graphrbac.RoleDefinitions list" })
@GET("{scope}/providers/Microsoft.Authorization/roleDefinitions")
Observable> list(@Path(value = "scope", encoded = true) String scope, @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.graphrbac.RoleDefinitions getById" })
@GET("{roleId}")
Observable> getById(@Path(value = "roleId", encoded = true) String roleId, @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.graphrbac.RoleDefinitions listNext" })
@GET
Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
}
/**
* Deletes a role definition.
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role 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
* @return the RoleDefinitionInner object if successful.
*/
public RoleDefinitionInner delete(String scope, String roleDefinitionId) {
return deleteWithServiceResponseAsync(scope, roleDefinitionId).toBlocking().single().body();
}
/**
* Deletes a role definition.
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role 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 scope, String roleDefinitionId, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(scope, roleDefinitionId), serviceCallback);
}
/**
* Deletes a role definition.
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the RoleDefinitionInner object
*/
public Observable deleteAsync(String scope, String roleDefinitionId) {
return deleteWithServiceResponseAsync(scope, roleDefinitionId).map(new Func1, RoleDefinitionInner>() {
@Override
public RoleDefinitionInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Deletes a role definition.
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the RoleDefinitionInner object
*/
public Observable> deleteWithServiceResponseAsync(String scope, String roleDefinitionId) {
if (scope == null) {
throw new IllegalArgumentException("Parameter scope is required and cannot be null.");
}
if (roleDefinitionId == null) {
throw new IllegalArgumentException("Parameter roleDefinitionId is required and cannot be null.");
}
final String apiVersion = "2018-01-01-preview";
return service.delete(scope, roleDefinitionId, 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())
.registerError(CloudException.class)
.build(response);
}
/**
* Get role definition by name (GUID).
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition.
* @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 RoleDefinitionInner object if successful.
*/
public RoleDefinitionInner get(String scope, String roleDefinitionId) {
return getWithServiceResponseAsync(scope, roleDefinitionId).toBlocking().single().body();
}
/**
* Get role definition by name (GUID).
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition.
* @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 roleDefinitionId, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(getWithServiceResponseAsync(scope, roleDefinitionId), serviceCallback);
}
/**
* Get role definition by name (GUID).
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the RoleDefinitionInner object
*/
public Observable getAsync(String scope, String roleDefinitionId) {
return getWithServiceResponseAsync(scope, roleDefinitionId).map(new Func1, RoleDefinitionInner>() {
@Override
public RoleDefinitionInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Get role definition by name (GUID).
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the RoleDefinitionInner object
*/
public Observable> getWithServiceResponseAsync(String scope, String roleDefinitionId) {
if (scope == null) {
throw new IllegalArgumentException("Parameter scope is required and cannot be null.");
}
if (roleDefinitionId == null) {
throw new IllegalArgumentException("Parameter roleDefinitionId is required and cannot be null.");
}
final String apiVersion = "2018-01-01-preview";
return service.get(scope, roleDefinitionId, 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);
}
/**
* Creates or updates a role definition.
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition.
* @param roleDefinition The values for the role definition.
* @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 RoleDefinitionInner object if successful.
*/
public RoleDefinitionInner createOrUpdate(String scope, String roleDefinitionId, RoleDefinitionInner roleDefinition) {
return createOrUpdateWithServiceResponseAsync(scope, roleDefinitionId, roleDefinition).toBlocking().single().body();
}
/**
* Creates or updates a role definition.
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition.
* @param roleDefinition The values for the role definition.
* @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 scope, String roleDefinitionId, RoleDefinitionInner roleDefinition, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(scope, roleDefinitionId, roleDefinition), serviceCallback);
}
/**
* Creates or updates a role definition.
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition.
* @param roleDefinition The values for the role definition.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the RoleDefinitionInner object
*/
public Observable createOrUpdateAsync(String scope, String roleDefinitionId, RoleDefinitionInner roleDefinition) {
return createOrUpdateWithServiceResponseAsync(scope, roleDefinitionId, roleDefinition).map(new Func1, RoleDefinitionInner>() {
@Override
public RoleDefinitionInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Creates or updates a role definition.
*
* @param scope The scope of the role definition.
* @param roleDefinitionId The ID of the role definition.
* @param roleDefinition The values for the role definition.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the RoleDefinitionInner object
*/
public Observable> createOrUpdateWithServiceResponseAsync(String scope, String roleDefinitionId, RoleDefinitionInner roleDefinition) {
if (scope == null) {
throw new IllegalArgumentException("Parameter scope is required and cannot be null.");
}
if (roleDefinitionId == null) {
throw new IllegalArgumentException("Parameter roleDefinitionId is required and cannot be null.");
}
if (roleDefinition == null) {
throw new IllegalArgumentException("Parameter roleDefinition is required and cannot be null.");
}
Validator.validate(roleDefinition);
final String apiVersion = "2018-01-01-preview";
return service.createOrUpdate(scope, roleDefinitionId, roleDefinition, 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);
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @param scope The scope of the role definition.
* @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<RoleDefinitionInner> object if successful.
*/
public PagedList list(final String scope) {
ServiceResponse> response = listSinglePageAsync(scope).toBlocking().single();
return new PagedList(response.body()) {
@Override
public Page nextPage(String nextPageLink) {
return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
}
};
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @param scope The scope of the role definition.
* @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 scope, final ListOperationCallback serviceCallback) {
return AzureServiceFuture.fromPageResponse(
listSinglePageAsync(scope),
new Func1>>>() {
@Override
public Observable>> call(String nextPageLink) {
return listNextSinglePageAsync(nextPageLink);
}
},
serviceCallback);
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @param scope The scope of the role definition.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<RoleDefinitionInner> object
*/
public Observable> listAsync(final String scope) {
return listWithServiceResponseAsync(scope)
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @param scope The scope of the role definition.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<RoleDefinitionInner> object
*/
public Observable>> listWithServiceResponseAsync(final String scope) {
return listSinglePageAsync(scope)
.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));
}
});
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @param scope The scope of the role definition.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<RoleDefinitionInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable>> listSinglePageAsync(final String scope) {
if (scope == null) {
throw new IllegalArgumentException("Parameter scope is required and cannot be null.");
}
final String apiVersion = "2018-01-01-preview";
final String filter = null;
return service.list(scope, filter, 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);
}
}
});
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @param scope The scope of the role definition.
* @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well.
* @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<RoleDefinitionInner> object if successful.
*/
public PagedList list(final String scope, final String filter) {
ServiceResponse> response = listSinglePageAsync(scope, filter).toBlocking().single();
return new PagedList(response.body()) {
@Override
public Page nextPage(String nextPageLink) {
return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
}
};
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @param scope The scope of the role definition.
* @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well.
* @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 scope, final String filter, final ListOperationCallback serviceCallback) {
return AzureServiceFuture.fromPageResponse(
listSinglePageAsync(scope, filter),
new Func1>>>() {
@Override
public Observable>> call(String nextPageLink) {
return listNextSinglePageAsync(nextPageLink);
}
},
serviceCallback);
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @param scope The scope of the role definition.
* @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<RoleDefinitionInner> object
*/
public Observable> listAsync(final String scope, final String filter) {
return listWithServiceResponseAsync(scope, filter)
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @param scope The scope of the role definition.
* @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<RoleDefinitionInner> object
*/
public Observable>> listWithServiceResponseAsync(final String scope, final String filter) {
return listSinglePageAsync(scope, 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));
}
});
}
/**
* Get all role definitions that are applicable at scope and above.
*
ServiceResponse> * @param scope The scope of the role definition.
ServiceResponse> * @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<RoleDefinitionInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable>> listSinglePageAsync(final String scope, final String filter) {
if (scope == null) {
throw new IllegalArgumentException("Parameter scope is required and cannot be null.");
}
final String apiVersion = "2018-01-01-preview";
return service.list(scope, filter, 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);
}
/**
* Gets a role definition by ID.
*
* @param roleId The fully qualified role definition ID. Use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role 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 RoleDefinitionInner object if successful.
*/
public RoleDefinitionInner getById(String roleId) {
return getByIdWithServiceResponseAsync(roleId).toBlocking().single().body();
}
/**
* Gets a role definition by ID.
*
* @param roleId The fully qualified role definition ID. Use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role 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 getByIdAsync(String roleId, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(getByIdWithServiceResponseAsync(roleId), serviceCallback);
}
/**
* Gets a role definition by ID.
*
* @param roleId The fully qualified role definition ID. Use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the RoleDefinitionInner object
*/
public Observable getByIdAsync(String roleId) {
return getByIdWithServiceResponseAsync(roleId).map(new Func1, RoleDefinitionInner>() {
@Override
public RoleDefinitionInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Gets a role definition by ID.
*
* @param roleId The fully qualified role definition ID. Use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the RoleDefinitionInner object
*/
public Observable> getByIdWithServiceResponseAsync(String roleId) {
if (roleId == null) {
throw new IllegalArgumentException("Parameter roleId is required and cannot be null.");
}
final String apiVersion = "2018-01-01-preview";
return service.getById(roleId, 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 CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @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<RoleDefinitionInner> 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();
}
};
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @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);
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @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<RoleDefinitionInner> object
*/
public Observable> listNextAsync(final String nextPageLink) {
return listNextWithServiceResponseAsync(nextPageLink)
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Get all role definitions that are applicable at scope and above.
*
* @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<RoleDefinitionInner> 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));
}
});
}
/**
* Get all role definitions that are applicable at scope and above.
*
ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<RoleDefinitionInner> 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);
}
}