com.microsoft.azure.management.graphrbac.implementation.UsersInner 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.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.HTTP;
import retrofit2.http.PATCH;
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 Users.
*/
public class UsersInner {
/** The Retrofit service to perform REST calls. */
private UsersService service;
/** The service client containing this operation class. */
private GraphRbacManagementClientImpl client;
/**
* Initializes an instance of UsersInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public UsersInner(Retrofit retrofit, GraphRbacManagementClientImpl client) {
this.service = retrofit.create(UsersService.class);
this.client = client;
}
/**
* The interface defining all the services for Users to be
* used by Retrofit to perform actually REST calls.
*/
interface UsersService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.graphrbac.Users create" })
@POST("{tenantID}/users")
Observable> create(@Path("tenantID") String tenantID, @Body UserCreateParametersInner 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.Users list" })
@GET("{tenantID}/users")
Observable> list(@Path("tenantID") String tenantID, @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.Users get" })
@GET("{tenantID}/users/{upnOrObjectId}")
Observable> get(@Path("upnOrObjectId") String upnOrObjectId, @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.Users update" })
@PATCH("{tenantID}/users/{upnOrObjectId}")
Observable> update(@Path("upnOrObjectId") String upnOrObjectId, @Path("tenantID") String tenantID, @Body UserUpdateParametersInner 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.Users delete" })
@HTTP(path = "{tenantID}/users/{upnOrObjectId}", method = "DELETE", hasBody = true)
Observable> delete(@Path("upnOrObjectId") String upnOrObjectId, @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.Users getMemberGroups" })
@POST("{tenantID}/users/{objectId}/getMemberGroups")
Observable> getMemberGroups(@Path("objectId") String objectId, @Path("tenantID") String tenantID, @Body UserGetMemberGroupsParametersInner 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.Users listNext" })
@GET
Observable> listNext(@Url String nextUrl, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
}
/**
* Create a new user.
*
* @param parameters Parameters to create a 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 UserInner object if successful.
*/
public UserInner create(UserCreateParametersInner parameters) {
return createWithServiceResponseAsync(parameters).toBlocking().single().body();
}
/**
* Create a new user.
*
* @param parameters Parameters to create a 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 createAsync(UserCreateParametersInner parameters, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(createWithServiceResponseAsync(parameters), serviceCallback);
}
/**
* Create a new user.
*
* @param parameters Parameters to create a user.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the UserInner object
*/
public Observable createAsync(UserCreateParametersInner parameters) {
return createWithServiceResponseAsync(parameters).map(new Func1, UserInner>() {
@Override
public UserInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Create a new user.
*
* @param parameters Parameters to create a user.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the UserInner object
*/
public Observable> createWithServiceResponseAsync(UserCreateParametersInner 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.create(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 clientResponse = createDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse createDelegate(Response response) throws GraphErrorException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(201, new TypeToken() { }.getType())
.registerError(GraphErrorException.class)
.build(response);
}
/**
* Gets list of users for the current tenant.
*
* @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 PagedList<UserInner> object if successful.
*/
public PagedList list() {
ServiceResponse> response = listSinglePageAsync().toBlocking().single();
return new PagedList(response.body()) {
@Override
public Page nextPage(String nextLink) {
return listNextSinglePageAsync(nextLink).toBlocking().single().body();
}
};
}
/**
* Gets list of users for the current tenant.
*
* @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 nextLink) {
return listNextSinglePageAsync(nextLink);
}
},
serviceCallback);
}
/**
* Gets list of users for the current tenant.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<UserInner> object
*/
public Observable> listAsync() {
return listWithServiceResponseAsync()
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Gets list of users for the current tenant.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<UserInner> object
*/
public Observable>> listWithServiceResponseAsync() {
return listSinglePageAsync()
.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(listNextWithServiceResponseAsync(nextLink));
}
});
}
/**
* Gets list of users for the current tenant.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<UserInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable>> listSinglePageAsync() {
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.");
}
final String filter = null;
return service.list(this.client.tenantID(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = listDelegate(response);
return Observable.just(new ServiceResponse>(result.body(), result.response()));
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
/**
* Gets list of users for the current tenant.
*
* @param filter The filter to apply to the operation.
* @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 PagedList<UserInner> object if successful.
*/
public PagedList list(final String filter) {
ServiceResponse> response = listSinglePageAsync(filter).toBlocking().single();
return new PagedList(response.body()) {
@Override
public Page nextPage(String nextLink) {
return listNextSinglePageAsync(nextLink).toBlocking().single().body();
}
};
}
/**
* Gets list of users for the current tenant.
*
* @param filter The filter to apply to the operation.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
public ServiceFuture> listAsync(final String filter, final ListOperationCallback serviceCallback) {
return AzureServiceFuture.fromPageResponse(
listSinglePageAsync(filter),
new Func1>>>() {
@Override
public Observable>> call(String nextLink) {
return listNextSinglePageAsync(nextLink);
}
},
serviceCallback);
}
/**
* Gets list of users for the current tenant.
*
* @param filter The filter to apply to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<UserInner> object
*/
public Observable> listAsync(final String filter) {
return listWithServiceResponseAsync(filter)
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Gets list of users for the current tenant.
*
* @param filter The filter to apply to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<UserInner> object
*/
public Observable>> listWithServiceResponseAsync(final String filter) {
return listSinglePageAsync(filter)
.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(listNextWithServiceResponseAsync(nextLink));
}
});
}
/**
* Gets list of users for the current tenant.
*
ServiceResponse> * @param filter The filter to apply to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<UserInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable>> listSinglePageAsync(final String filter) {
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.list(this.client.tenantID(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = listDelegate(response);
return Observable.just(new ServiceResponse>(result.body(), result.response()));
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> listDelegate(Response response) throws GraphErrorException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory()., GraphErrorException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken>() { }.getType())
.registerError(GraphErrorException.class)
.build(response);
}
/**
* Gets user information from the directory.
*
* @param upnOrObjectId The object ID or principal name of the user for which to get information.
* @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 UserInner object if successful.
*/
public UserInner get(String upnOrObjectId) {
return getWithServiceResponseAsync(upnOrObjectId).toBlocking().single().body();
}
/**
* Gets user information from the directory.
*
* @param upnOrObjectId The object ID or principal name of the user for which to get information.
* @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 upnOrObjectId, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(getWithServiceResponseAsync(upnOrObjectId), serviceCallback);
}
/**
* Gets user information from the directory.
*
* @param upnOrObjectId The object ID or principal name of the user for which to get information.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the UserInner object
*/
public Observable getAsync(String upnOrObjectId) {
return getWithServiceResponseAsync(upnOrObjectId).map(new Func1, UserInner>() {
@Override
public UserInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Gets user information from the directory.
*
* @param upnOrObjectId The object ID or principal name of the user for which to get information.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the UserInner object
*/
public Observable> getWithServiceResponseAsync(String upnOrObjectId) {
if (upnOrObjectId == null) {
throw new IllegalArgumentException("Parameter upnOrObjectId 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.");
}
return service.get(upnOrObjectId, 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 = getDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse getDelegate(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);
}
/**
* Updates a user.
*
* @param upnOrObjectId The object ID or principal name of the user to update.
* @param parameters Parameters to update an existing 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
*/
public void update(String upnOrObjectId, UserUpdateParametersInner parameters) {
updateWithServiceResponseAsync(upnOrObjectId, parameters).toBlocking().single().body();
}
/**
* Updates a user.
*
* @param upnOrObjectId The object ID or principal name of the user to update.
* @param parameters Parameters to update an existing 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 updateAsync(String upnOrObjectId, UserUpdateParametersInner parameters, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(updateWithServiceResponseAsync(upnOrObjectId, parameters), serviceCallback);
}
/**
* Updates a user.
*
* @param upnOrObjectId The object ID or principal name of the user to update.
* @param parameters Parameters to update an existing user.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable updateAsync(String upnOrObjectId, UserUpdateParametersInner parameters) {
return updateWithServiceResponseAsync(upnOrObjectId, parameters).map(new Func1, Void>() {
@Override
public Void call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Updates a user.
*
* @param upnOrObjectId The object ID or principal name of the user to update.
* @param parameters Parameters to update an existing user.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable> updateWithServiceResponseAsync(String upnOrObjectId, UserUpdateParametersInner parameters) {
if (upnOrObjectId == null) {
throw new IllegalArgumentException("Parameter upnOrObjectId 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 (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.update(upnOrObjectId, 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 clientResponse = updateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse updateDelegate(Response response) throws GraphErrorException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(204, new TypeToken() { }.getType())
.registerError(GraphErrorException.class)
.build(response);
}
/**
* Delete a user.
*
* @param upnOrObjectId The object ID or principal name of the user to delete.
* @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
*/
public void delete(String upnOrObjectId) {
deleteWithServiceResponseAsync(upnOrObjectId).toBlocking().single().body();
}
/**
* Delete a user.
*
* @param upnOrObjectId The object ID or principal name of the user 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 upnOrObjectId, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(upnOrObjectId), serviceCallback);
}
/**
* Delete a user.
*
* @param upnOrObjectId The object ID or principal name of the user to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable deleteAsync(String upnOrObjectId) {
return deleteWithServiceResponseAsync(upnOrObjectId).map(new Func1, Void>() {
@Override
public Void call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Delete a user.
*
* @param upnOrObjectId The object ID or principal name of the user to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable> deleteWithServiceResponseAsync(String upnOrObjectId) {
if (upnOrObjectId == null) {
throw new IllegalArgumentException("Parameter upnOrObjectId 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.");
}
return service.delete(upnOrObjectId, 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 = deleteDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse deleteDelegate(Response response) throws GraphErrorException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(204, new TypeToken() { }.getType())
.registerError(GraphErrorException.class)
.build(response);
}
/**
* Gets a collection that contains the object IDs of the groups of which the user is a member.
*
* @param objectId The object ID of the user for which to get group membership.
* @param parameters User filtering parameters.
* @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 List<String> object if successful.
*/
public List getMemberGroups(String objectId, UserGetMemberGroupsParametersInner parameters) {
return getMemberGroupsWithServiceResponseAsync(objectId, parameters).toBlocking().single().body();
}
/**
* Gets a collection that contains the object IDs of the groups of which the user is a member.
*
* @param objectId The object ID of the user for which to get group membership.
* @param parameters User 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> getMemberGroupsAsync(String objectId, UserGetMemberGroupsParametersInner parameters, final ServiceCallback> serviceCallback) {
return ServiceFuture.fromResponse(getMemberGroupsWithServiceResponseAsync(objectId, parameters), serviceCallback);
}
/**
* Gets a collection that contains the object IDs of the groups of which the user is a member.
*
* @param objectId The object ID of the user for which to get group membership.
* @param parameters User filtering parameters.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<String> object
*/
public Observable> getMemberGroupsAsync(String objectId, UserGetMemberGroupsParametersInner parameters) {
return getMemberGroupsWithServiceResponseAsync(objectId, parameters).map(new Func1>, List>() {
@Override
public List call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Gets a collection that contains the object IDs of the groups of which the user is a member.
*
* @param objectId The object ID of the user for which to get group membership.
* @param parameters User filtering parameters.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<String> object
*/
public Observable>> getMemberGroupsWithServiceResponseAsync(String objectId, UserGetMemberGroupsParametersInner parameters) {
if (objectId == null) {
throw new IllegalArgumentException("Parameter objectId 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 (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.getMemberGroups(objectId, 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 = getMemberGroupsDelegate(response);
ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> getMemberGroupsDelegate(Response response) throws GraphErrorException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory()., GraphErrorException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken>() { }.getType())
.registerError(GraphErrorException.class)
.build(response);
}
/**
* Gets a list of users for the current tenant.
*
* @param nextLink Next link for the list operation.
* @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 PagedList<UserInner> object if successful.
*/
public PagedList listNext(final String nextLink) {
ServiceResponse> response = listNextSinglePageAsync(nextLink).toBlocking().single();
return new PagedList(response.body()) {
@Override
public Page nextPage(String nextLink) {
return listNextSinglePageAsync(nextLink).toBlocking().single().body();
}
};
}
/**
* Gets a list of users for the current tenant.
*
* @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> listNextAsync(final String nextLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) {
return AzureServiceFuture.fromPageResponse(
listNextSinglePageAsync(nextLink),
new Func1>>>() {
@Override
public Observable>> call(String nextLink) {
return listNextSinglePageAsync(nextLink);
}
},
serviceCallback);
}
/**
* Gets a list of users for the current tenant.
*
* @param nextLink Next link for the list operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<UserInner> object
*/
public Observable> listNextAsync(final String nextLink) {
return listNextWithServiceResponseAsync(nextLink)
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Gets a list of users for the current tenant.
*
* @param nextLink Next link for the list operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<UserInner> object
*/
public Observable>> listNextWithServiceResponseAsync(final String nextLink) {
return listNextSinglePageAsync(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(listNextWithServiceResponseAsync(nextLink));
}
});
}
/**
* Gets a list of users for the current tenant.
*
ServiceResponse> * @param nextLink Next link for the list operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<UserInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable>> listNextSinglePageAsync(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.listNext(nextUrl, this.client.apiVersion(), 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 GraphErrorException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory()., GraphErrorException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken>() { }.getType())
.registerError(GraphErrorException.class)
.build(response);
}
}