com.microsoft.azure.management.graphrbac.implementation.ServicePrincipalsInner 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.management.graphrbac.KeyCredentialsUpdateParameters;
import com.microsoft.azure.management.graphrbac.PasswordCredentialsUpdateParameters;
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 ServicePrincipals.
*/
public class ServicePrincipalsInner {
/** The Retrofit service to perform REST calls. */
private ServicePrincipalsService service;
/** The service client containing this operation class. */
private GraphRbacManagementClientImpl client;
/**
* Initializes an instance of ServicePrincipalsInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public ServicePrincipalsInner(Retrofit retrofit, GraphRbacManagementClientImpl client) {
this.service = retrofit.create(ServicePrincipalsService.class);
this.client = client;
}
/**
* The interface defining all the services for ServicePrincipals to be
* used by Retrofit to perform actually REST calls.
*/
interface ServicePrincipalsService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.graphrbac.ServicePrincipals create" })
@POST("{tenantID}/servicePrincipals")
Observable> create(@Path("tenantID") String tenantID, @Body ServicePrincipalCreateParametersInner 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.ServicePrincipals list" })
@GET("{tenantID}/servicePrincipals")
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.ServicePrincipals delete" })
@HTTP(path = "{tenantID}/servicePrincipals/{objectId}", method = "DELETE", hasBody = true)
Observable> delete(@Path("objectId") String objectId, @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.ServicePrincipals get" })
@GET("{tenantID}/servicePrincipals/{objectId}")
Observable> get(@Path("objectId") String objectId, @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.ServicePrincipals listOwners" })
@GET("{tenantID}/servicePrincipals/{objectId}/owners")
Observable> listOwners(@Path("objectId") String objectId, @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.ServicePrincipals listKeyCredentials" })
@GET("{tenantID}/servicePrincipals/{objectId}/keyCredentials")
Observable> listKeyCredentials(@Path("objectId") String objectId, @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.ServicePrincipals updateKeyCredentials" })
@PATCH("{tenantID}/servicePrincipals/{objectId}/keyCredentials")
Observable> updateKeyCredentials(@Path("objectId") String objectId, @Path("tenantID") String tenantID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCredentialsUpdateParameters parameters, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.graphrbac.ServicePrincipals listPasswordCredentials" })
@GET("{tenantID}/servicePrincipals/{objectId}/passwordCredentials")
Observable> listPasswordCredentials(@Path("objectId") String objectId, @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.ServicePrincipals updatePasswordCredentials" })
@PATCH("{tenantID}/servicePrincipals/{objectId}/passwordCredentials")
Observable> updatePasswordCredentials(@Path("objectId") String objectId, @Path("tenantID") String tenantID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body PasswordCredentialsUpdateParameters parameters, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.graphrbac.ServicePrincipals listNext" })
@GET
Observable> listNext(@Url String nextUrl, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
}
/**
* Creates a service principal in the directory.
*
* @param parameters Parameters to create a service principal.
* @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 ServicePrincipalInner object if successful.
*/
public ServicePrincipalInner create(ServicePrincipalCreateParametersInner parameters) {
return createWithServiceResponseAsync(parameters).toBlocking().single().body();
}
/**
* Creates a service principal in the directory.
*
* @param parameters Parameters to create a service principal.
* @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(ServicePrincipalCreateParametersInner parameters, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(createWithServiceResponseAsync(parameters), serviceCallback);
}
/**
* Creates a service principal in the directory.
*
* @param parameters Parameters to create a service principal.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ServicePrincipalInner object
*/
public Observable createAsync(ServicePrincipalCreateParametersInner parameters) {
return createWithServiceResponseAsync(parameters).map(new Func1, ServicePrincipalInner>() {
@Override
public ServicePrincipalInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Creates a service principal in the directory.
*
* @param parameters Parameters to create a service principal.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ServicePrincipalInner object
*/
public Observable> createWithServiceResponseAsync(ServicePrincipalCreateParametersInner 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 a list of service principals from 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<ServicePrincipalInner> 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 a list of service principals from 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 a list of service principals from the current tenant.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<ServicePrincipalInner> object
*/
public Observable> listAsync() {
return listWithServiceResponseAsync()
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Gets a list of service principals from the current tenant.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<ServicePrincipalInner> 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 a list of service principals from the current tenant.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<ServicePrincipalInner> 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 a list of service principals from 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<ServicePrincipalInner> 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 a list of service principals from 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 a list of service principals from 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<ServicePrincipalInner> object
*/
public Observable> listAsync(final String filter) {
return listWithServiceResponseAsync(filter)
.map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Gets a list of service principals from 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<ServicePrincipalInner> 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 a list of service principals from the current tenant.
*
ServiceResponse> * @param filter The filter to apply to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<ServicePrincipalInner> 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);
}
/**
* Deletes a service principal from the directory.
*
* @param objectId The object ID of the service principal 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 objectId) {
deleteWithServiceResponseAsync(objectId).toBlocking().single().body();
}
/**
* Deletes a service principal from the directory.
*
* @param objectId The object ID of the service principal 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 objectId, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(objectId), serviceCallback);
}
/**
* Deletes a service principal from the directory.
*
* @param objectId The object ID of the service principal to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable deleteAsync(String objectId) {
return deleteWithServiceResponseAsync(objectId).map(new Func1, Void>() {
@Override
public Void call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Deletes a service principal from the directory.
*
* @param objectId The object ID of the service principal to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable> deleteWithServiceResponseAsync(String objectId) {
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 (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
return service.delete(objectId, 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 service principal information from the directory.
*
* @param objectId The object ID of the service principal to get.
* @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 ServicePrincipalInner object if successful.
*/
public ServicePrincipalInner get(String objectId) {
return getWithServiceResponseAsync(objectId).toBlocking().single().body();
}
/**
* Gets service principal information from the directory.
*
* @param objectId The object ID of the service principal 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 objectId, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(getWithServiceResponseAsync(objectId), serviceCallback);
}
/**
* Gets service principal information from the directory.
*
* @param objectId The object ID of the service principal to get.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ServicePrincipalInner object
*/
public Observable getAsync(String objectId) {
return getWithServiceResponseAsync(objectId).map(new Func1, ServicePrincipalInner>() {
@Override
public ServicePrincipalInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Gets service principal information from the directory.
*
* @param objectId The object ID of the service principal to get.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ServicePrincipalInner object
*/
public Observable> getWithServiceResponseAsync(String objectId) {
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 (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
return service.get(objectId, 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);
}
/**
* Directory objects that are owners of this service principal.
* The owners are a set of non-admin users who are allowed to modify this object.
*
* @param objectId The object ID of the service principal for which to get owners.
* @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<DirectoryObjectInner> object if successful.
*/
public List listOwners(String objectId) {
return listOwnersWithServiceResponseAsync(objectId).toBlocking().single().body();
}
/**
* Directory objects that are owners of this service principal.
* The owners are a set of non-admin users who are allowed to modify this object.
*
* @param objectId The object ID of the service principal for which to get owners.
* @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> listOwnersAsync(String objectId, final ServiceCallback> serviceCallback) {
return ServiceFuture.fromResponse(listOwnersWithServiceResponseAsync(objectId), serviceCallback);
}
/**
* Directory objects that are owners of this service principal.
* The owners are a set of non-admin users who are allowed to modify this object.
*
* @param objectId The object ID of the service principal for which to get owners.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<DirectoryObjectInner> object
*/
public Observable> listOwnersAsync(String objectId) {
return listOwnersWithServiceResponseAsync(objectId).map(new Func1>, List>() {
@Override
public List call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Directory objects that are owners of this service principal.
* The owners are a set of non-admin users who are allowed to modify this object.
*
* @param objectId The object ID of the service principal for which to get owners.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<DirectoryObjectInner> object
*/
public Observable>> listOwnersWithServiceResponseAsync(String objectId) {
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 (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
return service.listOwners(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = listOwnersDelegate(response);
ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> listOwnersDelegate(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);
}
/**
* Get the keyCredentials associated with the specified service principal.
*
* @param objectId The object ID of the service principal for which to get keyCredentials.
* @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<KeyCredentialInner> object if successful.
*/
public List listKeyCredentials(String objectId) {
return listKeyCredentialsWithServiceResponseAsync(objectId).toBlocking().single().body();
}
/**
* Get the keyCredentials associated with the specified service principal.
*
* @param objectId The object ID of the service principal for which to get keyCredentials.
* @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> listKeyCredentialsAsync(String objectId, final ServiceCallback> serviceCallback) {
return ServiceFuture.fromResponse(listKeyCredentialsWithServiceResponseAsync(objectId), serviceCallback);
}
/**
* Get the keyCredentials associated with the specified service principal.
*
* @param objectId The object ID of the service principal for which to get keyCredentials.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<KeyCredentialInner> object
*/
public Observable> listKeyCredentialsAsync(String objectId) {
return listKeyCredentialsWithServiceResponseAsync(objectId).map(new Func1>, List>() {
@Override
public List call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Get the keyCredentials associated with the specified service principal.
*
* @param objectId The object ID of the service principal for which to get keyCredentials.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<KeyCredentialInner> object
*/
public Observable>> listKeyCredentialsWithServiceResponseAsync(String objectId) {
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 (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
return service.listKeyCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = listKeyCredentialsDelegate(response);
ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> listKeyCredentialsDelegate(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);
}
/**
* Update the keyCredentials associated with a service principal.
*
* @param objectId The object ID for which to get service principal information.
* @param value A collection of KeyCredentials.
* @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 updateKeyCredentials(String objectId, List value) {
updateKeyCredentialsWithServiceResponseAsync(objectId, value).toBlocking().single().body();
}
/**
* Update the keyCredentials associated with a service principal.
*
* @param objectId The object ID for which to get service principal information.
* @param value A collection of KeyCredentials.
* @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 updateKeyCredentialsAsync(String objectId, List value, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(updateKeyCredentialsWithServiceResponseAsync(objectId, value), serviceCallback);
}
/**
* Update the keyCredentials associated with a service principal.
*
* @param objectId The object ID for which to get service principal information.
* @param value A collection of KeyCredentials.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable updateKeyCredentialsAsync(String objectId, List value) {
return updateKeyCredentialsWithServiceResponseAsync(objectId, value).map(new Func1, Void>() {
@Override
public Void call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Update the keyCredentials associated with a service principal.
*
* @param objectId The object ID for which to get service principal information.
* @param value A collection of KeyCredentials.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable> updateKeyCredentialsWithServiceResponseAsync(String objectId, List value) {
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 (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
if (value == null) {
throw new IllegalArgumentException("Parameter value is required and cannot be null.");
}
Validator.validate(value);
KeyCredentialsUpdateParameters parameters = new KeyCredentialsUpdateParameters();
parameters.withValue(value);
return service.updateKeyCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = updateKeyCredentialsDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse updateKeyCredentialsDelegate(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 the passwordCredentials associated with a service principal.
*
* @param objectId The object ID of the service principal.
* @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<PasswordCredentialInner> object if successful.
*/
public List listPasswordCredentials(String objectId) {
return listPasswordCredentialsWithServiceResponseAsync(objectId).toBlocking().single().body();
}
/**
* Gets the passwordCredentials associated with a service principal.
*
* @param objectId The object ID of the service principal.
* @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> listPasswordCredentialsAsync(String objectId, final ServiceCallback> serviceCallback) {
return ServiceFuture.fromResponse(listPasswordCredentialsWithServiceResponseAsync(objectId), serviceCallback);
}
/**
* Gets the passwordCredentials associated with a service principal.
*
* @param objectId The object ID of the service principal.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<PasswordCredentialInner> object
*/
public Observable> listPasswordCredentialsAsync(String objectId) {
return listPasswordCredentialsWithServiceResponseAsync(objectId).map(new Func1>, List>() {
@Override
public List call(ServiceResponse> response) {
return response.body();
}
});
}
/**
* Gets the passwordCredentials associated with a service principal.
*
* @param objectId The object ID of the service principal.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<PasswordCredentialInner> object
*/
public Observable>> listPasswordCredentialsWithServiceResponseAsync(String objectId) {
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 (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
return service.listPasswordCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = listPasswordCredentialsDelegate(response);
ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> listPasswordCredentialsDelegate(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);
}
/**
* Updates the passwordCredentials associated with a service principal.
*
* @param objectId The object ID of the service principal.
* @param value A collection of PasswordCredentials.
* @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 updatePasswordCredentials(String objectId, List value) {
updatePasswordCredentialsWithServiceResponseAsync(objectId, value).toBlocking().single().body();
}
/**
* Updates the passwordCredentials associated with a service principal.
*
* @param objectId The object ID of the service principal.
* @param value A collection of PasswordCredentials.
* @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 updatePasswordCredentialsAsync(String objectId, List value, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(updatePasswordCredentialsWithServiceResponseAsync(objectId, value), serviceCallback);
}
/**
* Updates the passwordCredentials associated with a service principal.
*
* @param objectId The object ID of the service principal.
* @param value A collection of PasswordCredentials.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable updatePasswordCredentialsAsync(String objectId, List value) {
return updatePasswordCredentialsWithServiceResponseAsync(objectId, value).map(new Func1, Void>() {
@Override
public Void call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Updates the passwordCredentials associated with a service principal.
*
* @param objectId The object ID of the service principal.
* @param value A collection of PasswordCredentials.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable> updatePasswordCredentialsWithServiceResponseAsync(String objectId, List value) {
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 (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
if (value == null) {
throw new IllegalArgumentException("Parameter value is required and cannot be null.");
}
Validator.validate(value);
PasswordCredentialsUpdateParameters parameters = new PasswordCredentialsUpdateParameters();
parameters.withValue(value);
return service.updatePasswordCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = updatePasswordCredentialsDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse updatePasswordCredentialsDelegate(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 list of service principals from 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<ServicePrincipalInner> 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 service principals from 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 service principals from 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<ServicePrincipalInner> 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 service principals from 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<ServicePrincipalInner> 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 service principals from the current tenant.
*
ServiceResponse> * @param nextLink Next link for the list operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<ServicePrincipalInner> 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);
}
}