com.microsoft.azure.management.graphrbac.implementation.ObjectsInner 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 retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.AzureServiceFuture;
import com.microsoft.azure.CloudException;
import com.microsoft.azure.ListOperationCallback;
import com.microsoft.azure.management.graphrbac.GraphErrorException;
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.Path;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Url;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;
/**
* An instance of this class provides access to all the operations defined
* in Objects.
*/
public class ObjectsInner {
/** The Retrofit service to perform REST calls. */
private ObjectsService service;
/** The service client containing this operation class. */
private GraphRbacManagementClientImpl client;
/**
* Initializes an instance of ObjectsInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public ObjectsInner(Retrofit retrofit, GraphRbacManagementClientImpl client) {
this.service = retrofit.create(ObjectsService.class);
this.client = client;
}
/**
* The interface defining all the services for Objects to be
* used by Retrofit to perform actually REST calls.
*/
interface ObjectsService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.graphrbac.Objects getCurrentUser" })
@GET("{tenantID}/me")
Observable> getCurrentUser(@Path("tenantID") String tenantID, @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.Objects getObjectsByObjectIds" })
@POST("{tenantID}/getObjectsByObjectIds")
Observable> getObjectsByObjectIds(@Path("tenantID") String tenantID, @Body GetObjectsParametersInner 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.graphrbac.Objects getObjectsByObjectIdsNext" })
@GET
Observable> getObjectsByObjectIdsNext(@Url String nextUrl, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
}
/**
* Gets the details for the currently logged-in user.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws GraphErrorException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the AADObjectInner object if successful.
*/
public AADObjectInner getCurrentUser() {
return getCurrentUserWithServiceResponseAsync().toBlocking().single().body();
}
/**
* Gets the details for the currently logged-in user.
*
* @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 getCurrentUserAsync(final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(getCurrentUserWithServiceResponseAsync(), serviceCallback);
}
/**
* Gets the details for the currently logged-in user.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the AADObjectInner object
*/
public Observable getCurrentUserAsync() {
return getCurrentUserWithServiceResponseAsync().map(new Func1, AADObjectInner>() {
@Override
public AADObjectInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Gets the details for the currently logged-in user.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the AADObjectInner object
*/
public Observable> getCurrentUserWithServiceResponseAsync() {
if (this.client.tenantID() == null) {
throw new IllegalArgumentException("Parameter this.client.tenantID() 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.getCurrentUser(this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = getCurrentUserDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse getCurrentUserDelegate(Response response) throws GraphErrorException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.registerError(GraphErrorException.class)
.build(response);
}
/**
* Gets AD group membership for the specified AD object IDs.
*
* @param parameters Objects filtering parameters.
* @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<AADObjectInner> object if successful.
*/
public PagedList getObjectsByObjectIds(final GetObjectsParametersInner parameters) {
ServiceResponse> response = getObjectsByObjectIdsSinglePageAsync(parameters).toBlocking().single();
return new PagedList(response.body()) {
@Override
public Page nextPage(String nextLink) {
return getObjectsByObjectIdsNextSinglePageAsync(nextLink).toBlocking().single().body();
}
};
}
/**
* Gets AD group membership for the specified AD object IDs.
*
* @param parameters Objects filtering parameters.
* @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> getObjectsByObjectIdsAsync(final GetObjectsParametersInner parameters, final ListOperationCallback serviceCallback) {
return AzureServiceFuture.fromPageResponse(
getObjectsByObjectIdsSinglePageAsync(parameters),
new Func1>>>() {
@Override
public Observable>> call(String nextLink) {
return getObjectsByObjectIdsNextSinglePageAsync(nextLink);
}
},
serviceCallback);
}
/**
* Gets AD group membership for the specified AD object IDs.
*
* @param parameters Objects filtering parameters.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<AADObjectInner> object
*/
public Observable> getObjectsByObjectIdsAsync(final GetObjectsParametersInner parameters) {
return getObjectsByObjectIdsWithServiceResponseAsync(parameters)
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Gets AD group membership for the specified AD object IDs.
*
* @param parameters Objects filtering parameters.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<AADObjectInner> object
*/
public Observable>> getObjectsByObjectIdsWithServiceResponseAsync(final GetObjectsParametersInner parameters) {
return getObjectsByObjectIdsSinglePageAsync(parameters)
.concatMap(new Func1>, Observable>>>() {
@Override
public Observable>> call(ServiceResponse> page) {
String nextLink = page.body().nextPageLink();
if (nextLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(getObjectsByObjectIdsNextWithServiceResponseAsync(nextLink));
}
});
}
/**
* Gets AD group membership for the specified AD object IDs.
*
ServiceResponse> * @param parameters Objects filtering parameters.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<AADObjectInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable>> getObjectsByObjectIdsSinglePageAsync(final GetObjectsParametersInner parameters) {
if (this.client.tenantID() == null) {
throw new IllegalArgumentException("Parameter this.client.tenantID() 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.getObjectsByObjectIds(this.client.tenantID(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = getObjectsByObjectIdsDelegate(response);
return Observable.just(new ServiceResponse>(result.body(), result.response()));
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> getObjectsByObjectIdsDelegate(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 AD group membership for the specified AD object IDs.
*
* @param nextLink Next link for the 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<AADObjectInner> object if successful.
*/
public PagedList getObjectsByObjectIdsNext(final String nextLink) {
ServiceResponse> response = getObjectsByObjectIdsNextSinglePageAsync(nextLink).toBlocking().single();
return new PagedList(response.body()) {
@Override
public Page nextPage(String nextLink) {
return getObjectsByObjectIdsNextSinglePageAsync(nextLink).toBlocking().single().body();
}
};
}
/**
* Gets AD group membership for the specified AD object IDs.
*
* @param nextLink Next link for the 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> getObjectsByObjectIdsNextAsync(final String nextLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) {
return AzureServiceFuture.fromPageResponse(
getObjectsByObjectIdsNextSinglePageAsync(nextLink),
new Func1>>>() {
@Override
public Observable>> call(String nextLink) {
return getObjectsByObjectIdsNextSinglePageAsync(nextLink);
}
},
serviceCallback);
}
/**
* Gets AD group membership for the specified AD object IDs.
*
* @param nextLink Next link for the list operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<AADObjectInner> object
*/
public Observable> getObjectsByObjectIdsNextAsync(final String nextLink) {
return getObjectsByObjectIdsNextWithServiceResponseAsync(nextLink)
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Gets AD group membership for the specified AD object IDs.
*
* @param nextLink Next link for the list operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<AADObjectInner> object
*/
public Observable>> getObjectsByObjectIdsNextWithServiceResponseAsync(final String nextLink) {
return getObjectsByObjectIdsNextSinglePageAsync(nextLink)
.concatMap(new Func1>, Observable>>>() {
@Override
public Observable>> call(ServiceResponse> page) {
String nextLink = page.body().nextPageLink();
if (nextLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(getObjectsByObjectIdsNextWithServiceResponseAsync(nextLink));
}
});
}
/**
* Gets AD group membership for the specified AD object IDs.
*
ServiceResponse> * @param nextLink Next link for the list operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<AADObjectInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable>> getObjectsByObjectIdsNextSinglePageAsync(final String nextLink) {
if (nextLink == null) {
throw new IllegalArgumentException("Parameter nextLink is required and cannot be null.");
}
if (this.client.tenantID() == null) {
throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
String nextUrl = String.format("%s/%s", this.client.tenantID(), nextLink);
return service.getObjectsByObjectIdsNext(nextUrl, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = getObjectsByObjectIdsNextDelegate(response);
return Observable.just(new ServiceResponse>(result.body(), result.response()));
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> getObjectsByObjectIdsNextDelegate(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);
}
}