use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.
the class GroupsInner method addMemberWithServiceResponseAsync.
/**
* Add a member to a group.
*
* @param groupObjectId The object ID of the group to which to add the member.
* @param url A member object URL, such as "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the member (user, application, servicePrincipal, group) to be added.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable<ServiceResponse<Void>> addMemberWithServiceResponseAsync(String groupObjectId, String url) {
if (groupObjectId == null) {
throw new IllegalArgumentException("Parameter groupObjectId 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 (url == null) {
throw new IllegalArgumentException("Parameter url is required and cannot be null.");
}
GroupAddMemberParameters parameters = new GroupAddMemberParameters();
parameters.withUrl(url);
return service.addMember(groupObjectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
@Override
public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
try {
ServiceResponse<Void> clientResponse = addMemberDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.
the class UsersInner method getMemberGroupsWithServiceResponseAsync.
/**
* 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 securityEnabledOnly If true, only membership in security-enabled groups should be checked. Otherwise, membership in all groups should be checked.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<String> object
*/
public Observable<ServiceResponse<List<String>>> getMemberGroupsWithServiceResponseAsync(String objectId, boolean securityEnabledOnly) {
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.");
}
UserGetMemberGroupsParameters parameters = new UserGetMemberGroupsParameters();
parameters.withSecurityEnabledOnly(securityEnabledOnly);
return service.getMemberGroups(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<String>>>>() {
@Override
public Observable<ServiceResponse<List<String>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl1<String>> result = getMemberGroupsDelegate(response);
ServiceResponse<List<String>> clientResponse = new ServiceResponse<List<String>>(result.body().items(), result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.
the class RoleAssignmentsInner method createWithServiceResponseAsync.
/**
* Creates a role assignment.
*
* @param scope The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource.
* @param roleAssignmentName The name of the role assignment to create. It can be any valid GUID.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the RoleAssignmentInner object
*/
public Observable<ServiceResponse<RoleAssignmentInner>> createWithServiceResponseAsync(String scope, String roleAssignmentName) {
if (scope == null) {
throw new IllegalArgumentException("Parameter scope is required and cannot be null.");
}
if (roleAssignmentName == null) {
throw new IllegalArgumentException("Parameter roleAssignmentName 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 RoleAssignmentPropertiesInner properties = null;
RoleAssignmentCreateParameters parameters = new RoleAssignmentCreateParameters();
parameters.withProperties(null);
return service.create(scope, roleAssignmentName, this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<RoleAssignmentInner>>>() {
@Override
public Observable<ServiceResponse<RoleAssignmentInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<RoleAssignmentInner> clientResponse = createDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.
the class DatabaseAccountsInner method patchWithServiceResponseAsync.
/**
* Patches the properties of an existing Azure DocumentDB database account.
*
* @param resourceGroupName Name of an Azure resource group.
* @param accountName DocumentDB database account name.
* @param tags the Map<String, String> value
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<DatabaseAccountInner>> patchWithServiceResponseAsync(String resourceGroupName, String accountName, Map<String, String> tags) {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (accountName == null) {
throw new IllegalArgumentException("Parameter accountName 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 (tags == null) {
throw new IllegalArgumentException("Parameter tags is required and cannot be null.");
}
Validator.validate(tags);
DatabaseAccountPatchParameters updateParameters = new DatabaseAccountPatchParameters();
updateParameters.withTags(tags);
Observable<Response<ResponseBody>> observable = service.patch(this.client.subscriptionId(), resourceGroupName, accountName, this.client.apiVersion(), this.client.acceptLanguage(), updateParameters, this.client.userAgent());
return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<DatabaseAccountInner>() {
}.getType());
}
use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.
the class DatabaseAccountsInner method beginPatchWithServiceResponseAsync.
/**
* Patches the properties of an existing Azure DocumentDB database account.
*
* @param resourceGroupName Name of an Azure resource group.
* @param accountName DocumentDB database account name.
* @param tags the Map<String, String> value
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the DatabaseAccountInner object
*/
public Observable<ServiceResponse<DatabaseAccountInner>> beginPatchWithServiceResponseAsync(String resourceGroupName, String accountName, Map<String, String> tags) {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (accountName == null) {
throw new IllegalArgumentException("Parameter accountName 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 (tags == null) {
throw new IllegalArgumentException("Parameter tags is required and cannot be null.");
}
Validator.validate(tags);
DatabaseAccountPatchParameters updateParameters = new DatabaseAccountPatchParameters();
updateParameters.withTags(tags);
return service.beginPatch(this.client.subscriptionId(), resourceGroupName, accountName, this.client.apiVersion(), this.client.acceptLanguage(), updateParameters, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<DatabaseAccountInner>>>() {
@Override
public Observable<ServiceResponse<DatabaseAccountInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<DatabaseAccountInner> clientResponse = beginPatchDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
Aggregations